Java Code Examples for javax.swing.table.DefaultTableCellRenderer#setHorizontalAlignment()
The following examples show how to use
javax.swing.table.DefaultTableCellRenderer#setHorizontalAlignment() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpMsgForm.java From WePush with MIT License | 6 votes |
/** * 初始化CookieTable */ public static void initCookieTable() { JTable paramTable = getInstance().getCookieTable(); paramTable.setRowHeight(36); String[] headerNames = {"Name", "Value", "Domain", "Path", "Expiry", ""}; DefaultTableModel model = new DefaultTableModel(null, headerNames); paramTable.setModel(model); paramTable.updateUI(); DefaultTableCellRenderer hr = (DefaultTableCellRenderer) paramTable.getTableHeader().getDefaultRenderer(); // 表头列名居左 hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); TableColumnModel tableColumnModel = paramTable.getColumnModel(); tableColumnModel.getColumn(headerNames.length - 1). setCellRenderer(new TableInCellButtonColumn(paramTable, headerNames.length - 1)); tableColumnModel.getColumn(headerNames.length - 1). setCellEditor(new TableInCellButtonColumn(paramTable, headerNames.length - 1)); // 设置列宽 tableColumnModel.getColumn(headerNames.length - 1).setPreferredWidth(46); tableColumnModel.getColumn(headerNames.length - 1).setMaxWidth(46); }
Example 2
Source File: MaTemplateMsgForm.java From WePush with MIT License | 6 votes |
/** * 初始化模板消息数据table */ public static void initTemplateDataTable() { JTable msgDataTable = getInstance().getTemplateMsgDataTable(); String[] headerNames = {"Name", "Value", "Color", "操作"}; DefaultTableModel model = new DefaultTableModel(null, headerNames); msgDataTable.setModel(model); msgDataTable.updateUI(); DefaultTableCellRenderer hr = (DefaultTableCellRenderer) msgDataTable.getTableHeader().getDefaultRenderer(); // 表头列名居左 hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); TableColumnModel tableColumnModel = msgDataTable.getColumnModel(); tableColumnModel.getColumn(headerNames.length - 1). setCellRenderer(new TableInCellButtonColumn(msgDataTable, headerNames.length - 1)); tableColumnModel.getColumn(headerNames.length - 1). setCellEditor(new TableInCellButtonColumn(msgDataTable, headerNames.length - 1)); // 设置列宽 tableColumnModel.getColumn(3).setPreferredWidth(46); tableColumnModel.getColumn(3).setMaxWidth(46); }
Example 3
Source File: BdYunMsgForm.java From WePush with MIT License | 6 votes |
/** * 初始化模板消息数据table */ public static void initTemplateDataTable() { JTable msgDataTable = getInstance().getTemplateMsgDataTable(); String[] headerNames = {"模板参数", "参数对应的值", "操作"}; DefaultTableModel model = new DefaultTableModel(null, headerNames); msgDataTable.setModel(model); msgDataTable.updateUI(); DefaultTableCellRenderer hr = (DefaultTableCellRenderer) msgDataTable.getTableHeader().getDefaultRenderer(); // 表头列名居左 hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); TableColumnModel tableColumnModel = msgDataTable.getColumnModel(); tableColumnModel.getColumn(headerNames.length - 1). setCellRenderer(new TableInCellButtonColumn(msgDataTable, headerNames.length - 1)); tableColumnModel.getColumn(headerNames.length - 1). setCellEditor(new TableInCellButtonColumn(msgDataTable, headerNames.length - 1)); // 设置列宽 tableColumnModel.getColumn(2).setPreferredWidth(46); tableColumnModel.getColumn(2).setMaxWidth(46); }
Example 4
Source File: QiNiuYunMsgForm.java From WePush with MIT License | 6 votes |
/** * 初始化模板消息数据table */ public static void initTemplateDataTable() { JTable msgDataTable = getInstance().getTemplateMsgDataTable(); String[] headerNames = {"模板参数", "参数对应的值", "操作"}; DefaultTableModel model = new DefaultTableModel(null, headerNames); msgDataTable.setModel(model); msgDataTable.updateUI(); DefaultTableCellRenderer hr = (DefaultTableCellRenderer) msgDataTable.getTableHeader().getDefaultRenderer(); // 表头列名居左 hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); TableColumnModel tableColumnModel = msgDataTable.getColumnModel(); tableColumnModel.getColumn(headerNames.length - 1). setCellRenderer(new TableInCellButtonColumn(msgDataTable, headerNames.length - 1)); tableColumnModel.getColumn(headerNames.length - 1). setCellEditor(new TableInCellButtonColumn(msgDataTable, headerNames.length - 1)); // 设置列宽 tableColumnModel.getColumn(2).setPreferredWidth(46); tableColumnModel.getColumn(2).setMaxWidth(46); }
Example 5
Source File: HttpMsgForm.java From WePush with MIT License | 6 votes |
/** * 初始化HeaderTable */ public static void initHeaderTable() { JTable paramTable = getInstance().getHeaderTable(); paramTable.setRowHeight(36); String[] headerNames = {"Name", "Value", ""}; DefaultTableModel model = new DefaultTableModel(null, headerNames); paramTable.setModel(model); paramTable.updateUI(); DefaultTableCellRenderer hr = (DefaultTableCellRenderer) paramTable.getTableHeader().getDefaultRenderer(); // 表头列名居左 hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); TableColumnModel tableColumnModel = paramTable.getColumnModel(); tableColumnModel.getColumn(headerNames.length - 1). setCellRenderer(new TableInCellButtonColumn(paramTable, headerNames.length - 1)); tableColumnModel.getColumn(headerNames.length - 1). setCellEditor(new TableInCellButtonColumn(paramTable, headerNames.length - 1)); // 设置列宽 tableColumnModel.getColumn(headerNames.length - 1).setPreferredWidth(46); tableColumnModel.getColumn(headerNames.length - 1).setMaxWidth(46); }
Example 6
Source File: WxCpAppDialog.java From WePush with MIT License | 6 votes |
/** * 应用列表表格 */ public void renderTable() { String[] headerNames = {"id", "应用名称", "AgentId", "Secret"}; DefaultTableModel model = new DefaultTableModel(null, headerNames); appsTable.setModel(model); DefaultTableCellRenderer hr = (DefaultTableCellRenderer) appsTable.getTableHeader() .getDefaultRenderer(); // 表头列名居左 hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); List<TWxCpApp> wxCpAppList = wxCpAppMapper.selectAll(); Object[] data; for (TWxCpApp tWxCpApp : wxCpAppList) { data = new Object[4]; data[0] = tWxCpApp.getId(); data[1] = tWxCpApp.getAppName(); data[2] = tWxCpApp.getAgentId(); data[3] = tWxCpApp.getSecret(); model.addRow(data); } // 隐藏id列 JTableUtil.hideColumn(appsTable, 0); }
Example 7
Source File: MaSubscribeMsgForm.java From WePush with MIT License | 6 votes |
/** * 初始化模板消息数据table */ public static void initTemplateDataTable() { JTable msgDataTable = getInstance().getTemplateMsgDataTable(); String[] headerNames = {"Name", "Value", "Color", "操作"}; DefaultTableModel model = new DefaultTableModel(null, headerNames); msgDataTable.setModel(model); msgDataTable.updateUI(); DefaultTableCellRenderer hr = (DefaultTableCellRenderer) msgDataTable.getTableHeader().getDefaultRenderer(); // 表头列名居左 hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); TableColumnModel tableColumnModel = msgDataTable.getColumnModel(); tableColumnModel.getColumn(headerNames.length - 1). setCellRenderer(new TableInCellButtonColumn(msgDataTable, headerNames.length - 1)); tableColumnModel.getColumn(headerNames.length - 1). setCellEditor(new TableInCellButtonColumn(msgDataTable, headerNames.length - 1)); // 设置列宽 tableColumnModel.getColumn(3).setPreferredWidth(46); tableColumnModel.getColumn(3).setMaxWidth(46); }
Example 8
Source File: AliYunMsgForm.java From WePush with MIT License | 6 votes |
/** * 初始化模板消息数据table */ public static void initTemplateDataTable() { JTable msgDataTable = getInstance().getTemplateMsgDataTable(); String[] headerNames = {"模板参数", "参数对应的值", "操作"}; DefaultTableModel model = new DefaultTableModel(null, headerNames); msgDataTable.setModel(model); msgDataTable.updateUI(); DefaultTableCellRenderer hr = (DefaultTableCellRenderer) msgDataTable.getTableHeader().getDefaultRenderer(); // 表头列名居左 hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); TableColumnModel tableColumnModel = msgDataTable.getColumnModel(); tableColumnModel.getColumn(headerNames.length - 1). setCellRenderer(new TableInCellButtonColumn(msgDataTable, headerNames.length - 1)); tableColumnModel.getColumn(headerNames.length - 1). setCellEditor(new TableInCellButtonColumn(msgDataTable, headerNames.length - 1)); // 设置列宽 tableColumnModel.getColumn(2).setPreferredWidth(46); tableColumnModel.getColumn(2).setMaxWidth(46); }
Example 9
Source File: HttpRequestForm.java From MooTool with MIT License | 6 votes |
/** * 初始化ParamTable */ public static void initParamTable() { JTable paramTable = getInstance().getParamTable(); paramTable.setRowHeight(36); String[] headerNames = {"Name", "Value", ""}; DefaultTableModel model = new DefaultTableModel(null, headerNames); paramTable.setModel(model); paramTable.updateUI(); DefaultTableCellRenderer hr = (DefaultTableCellRenderer) paramTable.getTableHeader().getDefaultRenderer(); // 表头列名居左 hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); TableColumnModel tableColumnModel = paramTable.getColumnModel(); tableColumnModel.getColumn(headerNames.length - 1). setCellRenderer(new TableInCellButtonColumn(paramTable, headerNames.length - 1)); tableColumnModel.getColumn(headerNames.length - 1). setCellEditor(new TableInCellButtonColumn(paramTable, headerNames.length - 1)); // 设置列宽 tableColumnModel.getColumn(headerNames.length - 1).setPreferredWidth(46); tableColumnModel.getColumn(headerNames.length - 1).setMaxWidth(46); }
Example 10
Source File: GameStatsJTable.java From magarena with GNU General Public License v3.0 | 5 votes |
private void setDefaultColumnProperties() { final TableColumnModel cm = getColumnModel(); // set initial column widths. for (int i = 0; i < cm.getColumnCount(); i++) { cm.getColumn(i).setMinWidth(50); cm.getColumn(i).setPreferredWidth(50); } final JTableHeader header = getTableHeader(); header.setReorderingAllowed(true); final DefaultTableCellRenderer renderer = (DefaultTableCellRenderer) header.getDefaultRenderer(); // center the column header captions. renderer.setHorizontalAlignment(SwingConstants.CENTER); }
Example 11
Source File: RegistrationExplorerPanel.java From SPIM_Registration with GNU General Public License v2.0 | 5 votes |
public void initComponent( final ViewRegistrations viewRegistrations ) { tableModel = new RegistrationTableModel( viewRegistrations, this ); table = new JTable(); table.setModel( tableModel ); table.setSurrendersFocusOnKeystroke( true ); table.setSelectionMode( ListSelectionModel.SINGLE_INTERVAL_SELECTION ); final DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer(); centerRenderer.setHorizontalAlignment( JLabel.CENTER ); // center all columns for ( int column = 0; column < tableModel.getColumnCount(); ++column ) table.getColumnModel().getColumn( column ).setCellRenderer( centerRenderer ); table.setPreferredScrollableViewportSize( new Dimension( 1020, 300 ) ); table.getColumnModel().getColumn( 0 ).setPreferredWidth( 300 ); for ( int i = 1; i < table.getColumnCount(); ++i ) table.getColumnModel().getColumn( i ).setPreferredWidth( 100 ); final Font f = table.getFont(); table.setFont( new Font( f.getName(), f.getStyle(), 11 ) ); this.setLayout( new BorderLayout() ); this.label = new JLabel( "View Description --- " ); this.add( label, BorderLayout.NORTH ); this.add( new JScrollPane( table ), BorderLayout.CENTER ); addPopupMenu( table ); }
Example 12
Source File: PeakListTableColumnModel.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
/** * */ PeakListTableColumnModel(GroupableTableHeader header, PeakListTableModel tableModel, ParameterSet parameters, PeakList peakList) { this.parameters = parameters; this.peakList = peakList; this.header = header; header.addMouseListener(this); // prepare formatters NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat(); NumberFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat(); // prepare cell renderers mzRenderer = new FormattedCellRenderer(mzFormat); rtRenderer = new FormattedCellRenderer(rtFormat); intensityRenderer = new FormattedCellRenderer(intensityFormat); peakShapeRenderer = new PeakShapeCellRenderer(peakList, parameters); identityRenderer = new CompoundIdentityCellRenderer(); peakStatusRenderer = new PeakStatusCellRenderer(); defaultRenderer = new DefaultTableCellRenderer(); defaultRenderer.setHorizontalAlignment(SwingConstants.CENTER); defaultRendererLeft = new DefaultTableCellRenderer(); defaultRendererLeft.setHorizontalAlignment(SwingConstants.LEFT); datapointsRenderer = new FormattedCellRenderer(new DecimalFormat()); qcRenderer = new FormattedCellRenderer(new DecimalFormat()); }
Example 13
Source File: CardsJTable.java From magarena with GNU General Public License v3.0 | 5 votes |
private void setDefaultColumnProperties() { final TableColumnModel cm = getColumnModel(); // set initial column widths. for (int i = 0; i < cm.getColumnCount(); i++) { cm.getColumn(i).setMinWidth(CardTableColumn.getMinWidth(i)); cm.getColumn(i).setPreferredWidth(CardTableColumn.getMinWidth(i)); } final JTableHeader header = getTableHeader(); header.setReorderingAllowed(true); final DefaultTableCellRenderer renderer = (DefaultTableCellRenderer) header.getDefaultRenderer(); // center the column header captions. renderer.setHorizontalAlignment(SwingConstants.CENTER); }
Example 14
Source File: PeakListTableColumnModel.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
/** * */ PeakListTableColumnModel(GroupableTableHeader header, PeakListTableModel tableModel, ParameterSet parameters, PeakList peakList) { this.parameters = parameters; this.peakList = peakList; this.header = header; header.addMouseListener(this); // prepare formatters NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat(); NumberFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat(); // prepare cell renderers mzRenderer = new FormattedCellRenderer(mzFormat); rtRenderer = new FormattedCellRenderer(rtFormat); intensityRenderer = new FormattedCellRenderer(intensityFormat); peakShapeRenderer = new PeakShapeCellRenderer(peakList, parameters); identityRenderer = new CompoundIdentityCellRenderer(); peakStatusRenderer = new PeakStatusCellRenderer(); defaultRenderer = new DefaultTableCellRenderer(); defaultRenderer.setHorizontalAlignment(SwingConstants.CENTER); defaultRendererLeft = new DefaultTableCellRenderer(); defaultRendererLeft.setHorizontalAlignment(SwingConstants.LEFT); datapointsRenderer = new FormattedCellRenderer(new DecimalFormat()); qcRenderer = new FormattedCellRenderer(new DecimalFormat()); }
Example 15
Source File: JPanel_AppManager.java From MobyDroid with Apache License 2.0 | 4 votes |
/** * Creates new form JPanel_ManageApps * */ public JPanel_AppManager() { // initialize components initComponents(); // table dimension jTable_Apps.setRowHeight(GuiUtils.APK_ICON_HEIGTH + 6); setColumnWidth(0, 32, 32); setColumnWidth(1, 256, -1); setColumnWidth(2, 64, 128); setColumnWidth(3, 64, 128); setColumnWidth(4, 64, 128); setColumnWidth(5, 96, 128); // set Table Row Sorter TableRowSorter tableRowSorter = new PackageTableRowSorter(jTable_Apps.getModel()); jTable_Apps.setRowSorter(tableRowSorter); tableRowSorter.setComparator(2, (Comparator<Long>) (o1, o2) -> o1.compareTo(o2)); // set table header for 0nd column jTable_Apps.getColumnModel().getColumn(jTable_Apps.convertColumnIndexToView(0)).setHeaderRenderer(new JCheckBoxTableHeaderCellRenderer()); // set cell render 1th column jTable_Apps.getColumnModel().getColumn(jTable_Apps.convertColumnIndexToView(1)).setCellRenderer(new ApkLablelCellRenderer()); // right align 3rd column DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setHorizontalAlignment(JLabel.RIGHT); jTable_Apps.getColumnModel().getColumn(jTable_Apps.convertColumnIndexToView(3)).setCellRenderer(renderer); // center align 4th & 5th column renderer.setHorizontalAlignment(JLabel.CENTER); jTable_Apps.getColumnModel().getColumn(jTable_Apps.convertColumnIndexToView(4)).setCellRenderer(renderer); jTable_Apps.getColumnModel().getColumn(jTable_Apps.convertColumnIndexToView(5)).setCellRenderer(renderer); // header click event jTable_Apps.getTableHeader().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent mouseEvent) { int column = jTable_Apps.convertColumnIndexToModel(jTable_Apps.getColumnModel().getColumnIndexAtX(mouseEvent.getX())); if (mouseEvent.getClickCount() == 1 && column != -1) { packageTableModel.headerClicked(column); } } }); // set tab action to change focus component outside jtable jTable_Apps.getActionMap().put(jTable_Apps.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).get(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0)), new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { KeyboardFocusManager.getCurrentKeyboardFocusManager().focusNextComponent(); } }); // KeyBinding jTable_Apps.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "none"); jTable_Apps.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), "none"); jTable_Apps.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0), "none"); // set table selection listner listSelectionListener = (ListSelectionEvent lse) -> { setPackageDetails(packageTableModel.getPackage(jTable_Apps.getSelectionModel().getLeadSelectionIndex())); }; jTable_Apps.getSelectionModel().addListSelectionListener(listSelectionListener); // hide for non expert if (!Boolean.valueOf(Settings.get("Expert_Settings"))) { materialButtonH_Backup.setVisible(false); materialButtonH_Restore.setVisible(false); jTable_Apps.removeColumn(jTable_Apps.getColumnModel().getColumn(5)); } }
Example 16
Source File: DetailsPanel.java From WhiteRabbit with Apache License 2.0 | 4 votes |
public void initialise() { setLayout(new BorderLayout()); JPanel generalInfoPanel = new JPanel(); generalInfoPanel.setLayout(new BorderLayout(5,5)); generalInfoPanel.setBorder(BorderFactory.createTitledBorder("General information")); JPanel fieldInfo = new JPanel(); fieldInfo.setLayout(new GridLayout(0,2)); fieldInfo.add(new JLabel("Field name: ")); fieldInfo.add(nameLabel); fieldInfo.add(new JLabel("Field type: ")); fieldInfo.add(typeLabel); generalInfoPanel.add(fieldInfo, BorderLayout.NORTH); JPanel sourceDetailsPanel = new JPanel(); sourceDetailsPanel.setLayout(new GridLayout(0,2)); sourceDetailsPanel.add(new JLabel("Unique values: ")); sourceDetailsPanel.add(valueDetailLabel); generalInfoPanel.add(sourceDetailsPanel); JPanel descriptionInfo = new JPanel(); descriptionInfo.setLayout(new GridLayout(0,2)); descriptionInfo.add(new JLabel("Description: ")); descriptionInfo.add(description); generalInfoPanel.add(descriptionInfo,BorderLayout.SOUTH); add(generalInfoPanel, BorderLayout.NORTH); JTable table = new JTable(valueTable); JScrollPane fieldListPanel = new JScrollPane(table); table.setFont(font); table.setRowHeight(24); table.setBorder(new MatteBorder(1, 0, 1, 0, Color.BLACK)); table.setCellSelectionEnabled(true); if (isTargetFieldPanel) { // Wide columns for concept name and class id table.getColumnModel().getColumn(1).setPreferredWidth(300); table.getColumnModel().getColumn(2).setPreferredWidth(100); } else { // Wide column for value name table.getColumnModel().getColumn(0).setPreferredWidth(500); // Right align the frequency and percentage DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer(); rightRenderer.setHorizontalAlignment(SwingConstants.RIGHT); table.getColumnModel().getColumn(1).setCellRenderer(rightRenderer); table.getColumnModel().getColumn(2).setCellRenderer(rightRenderer); } String title = isTargetFieldPanel ? "Concept ID Hints" : "Value Counts"; fieldListPanel.setBorder(BorderFactory.createTitledBorder(title)); add(fieldListPanel, BorderLayout.CENTER); JScrollPane commentsPanel = new JScrollPane(commentsArea); commentsArea.setFont(font); commentsArea.getDocument().addDocumentListener(this); commentsArea.setWrapStyleWord(true); commentsArea.setLineWrap(true); addUndoToTextArea(commentsArea); commentsPanel.setBorder(BorderFactory.createTitledBorder("Comments")); commentsPanel.setPreferredSize(new Dimension(100, 200)); add(commentsPanel, BorderLayout.SOUTH); }
Example 17
Source File: UwExperimentTab.java From FoxTelem with GNU General Public License v3.0 | 4 votes |
protected void addTables(AbstractTableModel radTableModel, AbstractTableModel radPacketTableModel) { super.addTables(radTableModel, radPacketTableModel); DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer(); centerRenderer.setHorizontalAlignment( JLabel.CENTER ); TableColumn column = null; column = table.getColumnModel().getColumn(0); column.setPreferredWidth(45); column.setCellRenderer( centerRenderer ); column = table.getColumnModel().getColumn(1); column.setPreferredWidth(55); column.setCellRenderer( centerRenderer ); column = table.getColumnModel().getColumn(2); column.setPreferredWidth(55); column.setCellRenderer( centerRenderer ); column = table.getColumnModel().getColumn(3); column.setPreferredWidth(75); column.setCellRenderer( centerRenderer ); column = table.getColumnModel().getColumn(4); column.setPreferredWidth(75); column.setCellRenderer( centerRenderer ); column = table.getColumnModel().getColumn(5); column.setPreferredWidth(55); column.setCellRenderer( centerRenderer ); for (int i=0; i<8; i++) { column = table.getColumnModel().getColumn(i+6); column.setPreferredWidth(45); } // This is the table that shows CAN Packets and counts column = packetTable.getColumnModel().getColumn(0); column.setPreferredWidth(100); column.setCellRenderer( centerRenderer ); column = packetTable.getColumnModel().getColumn(1); column.setPreferredWidth(150); column.setCellRenderer( centerRenderer ); column = packetTable.getColumnModel().getColumn(2); column.setPreferredWidth(150); column = packetTable.getColumnModel().getColumn(3); column.setPreferredWidth(150); column = packetTable.getColumnModel().getColumn(4); column.setPreferredWidth(155); column = packetTable.getColumnModel().getColumn(5); column.setPreferredWidth(55); column.setCellRenderer( centerRenderer ); }
Example 18
Source File: DiagnosticTable.java From FoxTelem with GNU General Public License v3.0 | 4 votes |
private JTable addErrorTable() { if (conversionType == BitArrayLayout.CONVERT_IHU_DIAGNOSTIC) tableModel = new DiagnosticTableModel(); else if (conversionType == BitArrayLayout.CONVERT_HARD_ERROR) tableModel = new HardErrorTableModel(); else if (conversionType == BitArrayLayout.CONVERT_SOFT_ERROR) tableModel = new SoftErrorTableModel(); else if (conversionType == BitArrayLayout.CONVERT_SOFT_ERROR_84488) tableModel = new SoftError84488TableModel(); else if (conversionType == BitArrayLayout.CONVERT_ICR_DIAGNOSTIC) tableModel = new IcrDiagnosticTableModel(); else if (conversionType == BitArrayLayout.CONVERT_COM1_ISIS_ANT_STATUS) tableModel = new IsisAntennaStatusTableModel(); JTable table = new JTable(tableModel); table.setAutoCreateRowSorter(true); scrollPane = new JScrollPane (table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); table.setFillsViewportHeight(true); table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); add(scrollPane, BorderLayout.CENTER); //add(table, BorderLayout.CENTER); TableColumn column = null; column = table.getColumnModel().getColumn(0); column.setPreferredWidth(45); column = table.getColumnModel().getColumn(1); column.setPreferredWidth(55); DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer(); centerRenderer.setHorizontalAlignment( SwingConstants.CENTER ); if (conversionType == BitArrayLayout.CONVERT_IHU_DIAGNOSTIC) { column = table.getColumnModel().getColumn(2); column.setPreferredWidth(250); } else if (conversionType == BitArrayLayout.CONVERT_HARD_ERROR) for (int i=0; i<6; i++) { column = table.getColumnModel().getColumn(i+2); column.setPreferredWidth(60); column.setCellRenderer(centerRenderer); column.setHeaderRenderer(centerRenderer); } else if (conversionType == BitArrayLayout.CONVERT_SOFT_ERROR) { for (int i=0; i<4; i++) { column = table.getColumnModel().getColumn(i+2); column.setPreferredWidth(60); column.setCellRenderer(centerRenderer); column.setHeaderRenderer(centerRenderer); } if (conversionType == BitArrayLayout.CONVERT_SOFT_ERROR_84488) { column = table.getColumnModel().getColumn(6); column.setPreferredWidth(60); column.setCellRenderer(centerRenderer); column.setHeaderRenderer(centerRenderer); } } else if (conversionType == BitArrayLayout.CONVERT_ICR_DIAGNOSTIC) { for (int i=0; i<4; i++) { column = table.getColumnModel().getColumn(i+2); column.setPreferredWidth(60); column.setCellRenderer(centerRenderer); column.setHeaderRenderer(centerRenderer); } } else if (conversionType == BitArrayLayout.CONVERT_COM1_ISIS_ANT_STATUS) { for (int i=0; i<15; i++) { column = table.getColumnModel().getColumn(i+2); column.setPreferredWidth(60); column.setCellRenderer(centerRenderer); column.setHeaderRenderer(centerRenderer); } } return table; }
Example 19
Source File: CBreakpointTable.java From binnavi with Apache License 2.0 | 4 votes |
/** * Creates a new breakpoint management table. * * @param debuggerProvider Provides all the debuggers that manage breakpoints which are displayed * in the table. * @param graph Graph shown in the window of the breakpoint table. * @param viewContainer View container of the graph. */ public CBreakpointTable(final BackEndDebuggerProvider debuggerProvider, final ZyGraph graph, final IViewContainer viewContainer) { m_debuggerProvider = Preconditions.checkNotNull(debuggerProvider, "IE01335: Debugger provider can't be null"); m_graph = Preconditions.checkNotNull(graph, "IE02093: Graph argument can not be null"); m_viewContainer = Preconditions.checkNotNull(viewContainer, "IE02099: View container argument can not be null"); m_tableModel = new CBreakpointTableModel(debuggerProvider); setModel(m_tableModel); // Since each debugger that is available in the view can be used to set // breakpoints, it is necessary to add listeners to the breakpoint // managers of all debuggers. for (final IDebugger debugger : debuggerProvider.getDebuggers()) { addDebuggerListeners(debugger); } debuggerProvider.addListener(m_debuggerListener); getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); // Make sure that the status cells are colored. getColumnModel().getColumn(CBreakpointTableModel.COLUMN_STATUS).setCellRenderer( new CBreakpointStatusRenderer()); // Center some fields in the table final DefaultTableCellRenderer tcrColumn = new DefaultTableCellRenderer(); tcrColumn.setHorizontalAlignment(SwingConstants.CENTER); getColumnModel().getColumn(CBreakpointTableModel.COLUMN_UNRELOCATED_ADDRESS).setCellRenderer( tcrColumn); getColumnModel().getColumn(CBreakpointTableModel.COLUMN_RELOCATED_ADDRESS).setCellRenderer( tcrColumn); getColumnModel().getColumn(CBreakpointTableModel.COLUMN_MODULE_NAME).setCellRenderer(tcrColumn); getColumnModel().getColumn(CBreakpointTableModel.COLUMN_DEBUGGER).setCellRenderer(tcrColumn); getColumnModel().getColumn(CBreakpointTableModel.COLUMN_CONDITION).setCellEditor( new CConditionEditor()); addMouseListener(new InternalMouseListener()); }
Example 20
Source File: ResultWindow.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
public ResultWindow(String title, PeakListRow peakListRow, double searchedMass, int charge, Task searchTask) { super(title); this.title = title; this.peakListRow = peakListRow; this.searchTask = searchTask; setDefaultCloseOperation(DISPOSE_ON_CLOSE); setBackground(Color.white); JPanel pnlLabelsAndList = new JPanel(new BorderLayout()); pnlLabelsAndList.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); pnlLabelsAndList.add(new JLabel("List of possible formulas"), BorderLayout.NORTH); resultsTableModel = new ResultTableModel(searchedMass); resultsTable = new JTable(); // int rowHeight = resultsTable.getRowHeight(); resultsTable.setRowHeight(22); resultsTable.setModel(resultsTableModel); resultsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); resultsTable.getTableHeader().setReorderingAllowed(false); resultsTableSorter = new TableRowSorter<ResultTableModel>(resultsTableModel); // set descending order by isotope score resultsTableSorter.toggleSortOrder(3); resultsTableSorter.toggleSortOrder(3); resultsTable.setRowSorter(resultsTableSorter); TableColumnModel columnModel = resultsTable.getColumnModel(); DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setHorizontalAlignment(SwingConstants.LEFT); resultsTable.setDefaultRenderer(Double.class, renderer); columnModel.getColumn(4).setCellRenderer(new PercentageCellRenderer(1)); columnModel.getColumn(5).setCellRenderer(new PercentageCellRenderer(1)); JScrollPane listScroller = new JScrollPane(resultsTable); listScroller.setPreferredSize(new Dimension(350, 100)); listScroller.setAlignmentX(LEFT_ALIGNMENT); JPanel listPanel = new JPanel(); listPanel.setLayout(new BoxLayout(listPanel, BoxLayout.PAGE_AXIS)); listPanel.add(listScroller); listPanel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); pnlLabelsAndList.add(listPanel, BorderLayout.CENTER); JPanel pnlButtons = new JPanel(); pnlButtons.setLayout(new BoxLayout(pnlButtons, BoxLayout.X_AXIS)); pnlButtons.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); GUIUtils.addButton(pnlButtons, "Add identity", null, this, "ADD"); GUIUtils.addButton(pnlButtons, "Copy to clipboard", null, this, "COPY"); GUIUtils.addButton(pnlButtons, "Export all", null, this, "EXPORT"); GUIUtils.addButton(pnlButtons, "View isotope pattern", null, this, "SHOW_ISOTOPES"); GUIUtils.addButton(pnlButtons, "Show MS/MS", null, this, "SHOW_MSMS"); setLayout(new BorderLayout()); setSize(500, 200); add(pnlLabelsAndList, BorderLayout.CENTER); add(pnlButtons, BorderLayout.SOUTH); pack(); }