Java Code Examples for javax.swing.JTable#setDefaultRenderer()
The following examples show how to use
javax.swing.JTable#setDefaultRenderer() .
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: TaskList.java From swift-k with Apache License 2.0 | 8 votes |
public TaskList(TaskHandler handler) { this(); this.handler = handler; model = new SingleHandlerTaskModel(handler); table = new JTable(model); table.setAutoCreateColumnsFromModel(true); table.setDefaultRenderer(String.class, new DefaultTableCellRenderer()); getContentPane().add(new JScrollPane(table), BorderLayout.CENTER); update(0,0); table.setSize(640,200); table.setPreferredSize(new Dimension(640, 200)); pack(); }
Example 2
Source File: GuiShowImagesOverviewAction.java From WorldGrower with GNU General Public License v3.0 | 6 votes |
@Override public void actionPerformed(ActionEvent e) { JFrame frame = new JFrame(); JTable table = new JTable(new ImageModel(Arrays.asList(ImageIds.values()))); table.setBounds(50, 50, 1000, 800); table.setRowHeight(100); ImageCellRenderer renderer = new ImageCellRenderer(imageInfoReader); table.setDefaultRenderer(ImageIcon.class, renderer); frame.add(new JScrollPane(table)); frame.setBounds(100, 100, 900, 900); frame.setVisible(true); Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { renderer.incrementImageIndex(); table.repaint(); } }, 0, 100); }
Example 3
Source File: QFixMessengerFrame.java From quickfix-messenger with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void initBottomPanel() { MessagesTableModel messagesTableModel = new MessagesTableModel(); messagesTable = new JTable(messagesTableModel); messagesTable.getColumnModel().getColumn(0).setPreferredWidth(90); messagesTable.getColumnModel().getColumn(1).setPreferredWidth(5); messagesTable.getColumnModel().getColumn(2).setPreferredWidth(75); messagesTable.getColumnModel().getColumn(3).setPreferredWidth(5); messagesTable.getColumnModel().getColumn(4).setPreferredWidth(510); messagesTable.setDefaultRenderer(String.class, new MessagesTableCellRender()); messagesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); messagesTable.addMouseListener(new MessagesTableMouseListener(this)); messenger.getApplication().addMessageListener(messagesTableModel); bottomPanelScrollPane = new JScrollPane(messagesTable); bottomPanelScrollPane.setPreferredSize(new Dimension( bottomPanelScrollPane.getPreferredSize().width, 120)); bottomPanelScrollPane.getViewport().add(messagesTable); add(bottomPanelScrollPane, BorderLayout.SOUTH); }
Example 4
Source File: PropertiesTable.java From netbeans with Apache License 2.0 | 6 votes |
private void init(JLabel label, String[] columns) { tableModel = new PropertiesTableModel(columns); tableModel.addTableModelListener(this); table = new JTable(tableModel); table.getTableHeader().setReorderingAllowed(false); table.setDefaultRenderer(String.class, new PropertiesTableCellRenderer()); //table.setDefaultEditor(CommitOptions.class, new CommitOptionsCellEditor()); table.setRowHeight(table.getRowHeight()); table.addAncestorListener(this); component = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); component.setPreferredSize(new Dimension(340, 150)); table.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PropertiesTable.class, "ACSD_PropertiesTable")); // NOI18N table.getAccessibleContext().setAccessibleName(NbBundle.getMessage(PropertiesTable.class, "ACSN_PropertiesTable")); // NOI18N label.setLabelFor(table); setColumns(columns); }
Example 5
Source File: Continuous1BandTabularForm.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
public Continuous1BandTabularForm(final ColorManipulationForm parentForm) { this.parentForm = parentForm; tableModel = new ImageInfoTableModel(); tableModelListener = e -> { tableModel.removeTableModelListener(tableModelListener); parentForm.applyChanges(); tableModel.addTableModelListener(tableModelListener); }; moreOptionsForm = new MoreOptionsForm(this, parentForm.getFormModel().canUseHistogramMatching()); discreteCheckBox = new DiscreteCheckBox(parentForm); moreOptionsForm.addRow(discreteCheckBox); parentForm.getFormModel().modifyMoreOptionsForm(moreOptionsForm); final JTable table = new JTable(tableModel); table.setDefaultRenderer(Color.class, new ColorTableCellRenderer()); table.setDefaultEditor(Color.class, new ColorTableCellEditor()); table.getTableHeader().setReorderingAllowed(false); table.getColumnModel().getColumn(0).setPreferredWidth(140); table.getColumnModel().getColumn(1).setPreferredWidth(140); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); final JScrollPane tableScrollPane = new JScrollPane(table); tableScrollPane.getViewport().setPreferredSize(table.getPreferredSize()); contentPanel = tableScrollPane; }
Example 6
Source File: GfxdTop.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public GfxdTop() { super(new GridLayout(1,0)); tmodel = new StatementTableModel(); queryStats = new ClusterStatistics(); JTable table = new JTable(tmodel); table.setPreferredScrollableViewportSize(new Dimension(500, 300)); table.setDefaultRenderer(Double.class, new DoubleRenderer()); table.setIntercellSpacing(new Dimension(6,3)); table.setRowHeight(table.getRowHeight() + 4); JScrollPane scrollPane = new JScrollPane(table); add(scrollPane); }
Example 7
Source File: Discrete1BandTabularForm.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
public Discrete1BandTabularForm(ColorManipulationForm parentForm) { this.parentForm = parentForm; tableModel = new ImageInfoTableModel(); moreOptionsForm = new MoreOptionsForm(this, false); final JTable table = new JTable(tableModel); table.setRowSorter(new TableRowSorter<>(tableModel)); table.setDefaultRenderer(Color.class, new ColorTableCellRenderer()); table.setDefaultEditor(Color.class, new ColorTableCellEditor()); table.getTableHeader().setReorderingAllowed(false); table.getColumnModel().getColumn(1).setPreferredWidth(140); table.getColumnModel().getColumn(3).setCellRenderer(new PercentageRenderer()); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); final JScrollPane tableScrollPane = new JScrollPane(table); tableScrollPane.getViewport().setPreferredSize(table.getPreferredSize()); contentPanel = tableScrollPane; }
Example 8
Source File: MainFrameView.java From pgptool with GNU General Public License v3.0 | 6 votes |
private JScrollPane initTableComponent() { table = new JTable(); // Adjust some visual appearence table.setRowHeight(22); // Add listeners selectionModel = new DefaultListSelectionModel(); selectionModel.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); selectionModel.addListSelectionListener(rowSelectionListener); table.setSelectionModel(selectionModel); table.addMouseListener(listMouseListener); table.setDefaultRenderer(EncryptBackAction.class, new EncryptBackActionCellRenderer()); table.addMouseListener(encrBackClickHandler); initTableKeyListener(); // Envelope in scrollpane scrollPane = new JScrollPane(); scrollPane.addMouseListener(listMouseListener); scrollPane.setViewportView(table); return scrollPane; }
Example 9
Source File: IKTaskSetPanel.java From opensim-gui with Apache License 2.0 | 5 votes |
/** Creates new form IKCoordinateTaskPanel */ public IKTaskSetPanel(IKCommonModel ikCommonModel) { this.ikCommonModel = ikCommonModel; ikMarkerTasksTableModel = new IKTasksTableModel(ikCommonModel.getIKMarkerTasksModel(), "Marker"); ikCoordinateTasksTableModel = new IKTasksTableModel(ikCommonModel.getIKCoordinateTasksModel(), "Coordinate"); if (numFormat instanceof DecimalFormat) { ((DecimalFormat) numFormat).applyPattern("###0.#########"); } initComponents(); ikMarkerTasksTable.setModel(ikMarkerTasksTableModel); ikCoordinateTasksTable.setModel(ikCoordinateTasksTableModel); for(JTable table : new JTable[]{ikMarkerTasksTable, ikCoordinateTasksTable}) { table.getSelectionModel().addListSelectionListener(this); table.getModel().addTableModelListener(this); table.setDefaultRenderer(IKTasksNameCell.class, new IKTasksNameCellRenderer()); table.setDefaultRenderer(IKTasksValueCell.class, new IKTasksValueCellRenderer()); table.setDefaultRenderer(IKTasksWeightCell.class, new IKTasksWeightCellRenderer()); table.getColumnModel().getColumn(0).setPreferredWidth(enabledColumnWidth); table.getColumnModel().getColumn(0).setMinWidth(enabledColumnWidth); table.getColumnModel().getColumn(0).setMaxWidth(enabledColumnWidth); table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); } updatePanel(); }
Example 10
Source File: TaskProgressTable.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
/** * Constructor */ public TaskProgressTable() { super(new BorderLayout()); add(new JLabel("Tasks in progress..."), BorderLayout.NORTH); TaskControllerImpl taskController = (TaskControllerImpl) MZmineCore.getTaskController(); taskTable = new JTable(taskController.getTaskQueue()); taskTable.setCellSelectionEnabled(false); taskTable.setColumnSelectionAllowed(false); taskTable.setRowSelectionAllowed(true); taskTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); taskTable.setDefaultRenderer(JComponent.class, new ComponentCellRenderer()); taskTable.getTableHeader().setReorderingAllowed(false); JScrollPane jJobScroll = new JScrollPane(taskTable); add(jJobScroll, BorderLayout.CENTER); // Create popup menu and items popupMenu = new JPopupMenu(); priorityMenu = new JMenu("Set priority..."); highPriorityMenuItem = GUIUtils.addMenuItem(priorityMenu, "High", this); normalPriorityMenuItem = GUIUtils.addMenuItem(priorityMenu, "Normal", this); popupMenu.add(priorityMenu); cancelTaskMenuItem = GUIUtils.addMenuItem(popupMenu, "Cancel task", this); cancelAllMenuItem = GUIUtils.addMenuItem(popupMenu, "Cancel all tasks", this); // Addd popup menu to the task table taskTable.setComponentPopupMenu(popupMenu); // Set the width for first column (task description) taskTable.getColumnModel().getColumn(0).setPreferredWidth(350); jJobScroll.setPreferredSize(new Dimension(600, 120)); }
Example 11
Source File: DrawGridLInesTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void checkTableGridLines() { TableModel dataModel = new AbstractTableModel() { public int getColumnCount() { return 10; } public int getRowCount() { return 10; } public Object getValueAt(int row, int col) { return " "; } }; DefaultTableCellRenderer r = new DefaultTableCellRenderer(); r.setOpaque(true); r.setBackground(CELL_RENDERER_BACKGROUND_COLOR); JTable table = new JTable(dataModel); table.setSize(WIDTH, HEIGHT); table.setDefaultRenderer(Object.class, r); table.setGridColor(GRID_COLOR); table.setShowGrid(true); table.setShowHorizontalLines(true); table.setShowVerticalLines(true); table.setBackground(TABLE_BACKGROUND_COLOR); checkTableGridLines(table); }
Example 12
Source File: DemandsDialog.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
public void initializeGUI(ImageInfoReader imageInfoReader, SoundIdReader soundIdReader) { DemandsModel worldModel = new DemandsModel(demands); JTable table = JTableFactory.createJTable(worldModel); table.setDefaultRenderer(ImageIds.class, new ImageTableRenderer(imageInfoReader)); table.setAutoCreateRowSorter(true); table.setRowHeight(50); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.getColumnModel().getColumn(0).setPreferredWidth(100); table.getColumnModel().getColumn(1).setPreferredWidth(200); table.getColumnModel().getColumn(2).setPreferredWidth(100); table.getRowSorter().toggleSortOrder(1); TableCellEditor fce = new PositiveIntegerCellEditor(JTextFieldFactory.createJTextField()); table.setDefaultEditor(Integer.class, fce); JScrollPane scrollPane = JScrollPaneFactory.createScrollPane(table); scrollPane.setBounds(15, 15, 418, 700); addComponent(scrollPane); JPanel buttonPane = new JPanel(); buttonPane.setOpaque(false); buttonPane.setBounds(0, 720, 428, 75); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); addComponent(buttonPane); JButton okButton = JButtonFactory.createButton("OK", imageInfoReader, soundIdReader); okButton.setActionCommand("OK"); buttonPane.add(okButton); addActionHandlers(okButton, worldModel, this, demands); getRootPane().setDefaultButton(okButton); SwingUtils.makeTransparant(table, scrollPane); }
Example 13
Source File: Tree.java From TrakEM2 with GNU General Public License v3.0 | 4 votes |
void setCellRenderer(final JTable t, final DefaultTableCellRenderer ccr) { t.setDefaultRenderer(t.getColumnClass(8), ccr); }
Example 14
Source File: PhotoList.java From mvisc with GNU General Public License v3.0 | 4 votes |
public PhotoList(ZooracleContentPanel zooracleContentPanel) { this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.zooracleContentPanel = zooracleContentPanel; // Set the frame characteristics // setSize(150, 600); setBackground(Color.gray); // Create a panel to hold all other components topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS)); this.add(topPanel); // Create some data // String dataValues[][] = { { "12", "234", "67" }, { "-123", "43", "853" }, { "93", "89.2", "109" }, { "279", "9033", "3092" } }; // Create a new table instance table = new JTable(null, columnNames); // table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // table.setMinimumSize(new Dimension(150, 600)); // table.setPreferredSize(new Dimension(150, 600)); // table.setD selectionModel = new DefaultListSelectionModel(); model = new DefaultTableModel(); // table.setC selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); selectionModel.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { int selectionIndex = table.getSelectedRow(); if (lastSelectionIndex != selectionIndex) { lastSelectionIndex = selectionIndex; if (selectionIndex==-1) return; System.out.println(table.getValueAt(selectionIndex, 0)); System.out.println("sele:" + selectionIndex); if (PhotoList.this.zooracleContentPanel instanceof ImportView) { ((ImportView)(PhotoList.this.zooracleContentPanel)).setCurrentPhoto(selectionIndex); } // if (selectionIndex > 2) // PhotoList.this.maximize(false); } } }); // table.setDefaultRenderer(Object.class, new EditedCellRenderer(this)); table.setSelectionModel(selectionModel); table.setDefaultRenderer(String.class, new BoardTableCellRenderer()); table.setDefaultRenderer(Object.class, new BoardTableCellRenderer()); table.setModel(model); // table.setMaximumSize(new Dimension(100, 300)); // Add the table to a scrolling pane scrollPane = new JScrollPane(); // scrollPane.add(table.getTableHeader()); // scrollPane.add(table); // topPanel.add(scrollPane); topPanel.add(table.getTableHeader()); topPanel.add(new JScrollPane(table)); }
Example 15
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(); }
Example 16
Source File: SalvageTabPanel.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void initializeUI() { uiDone = true; Salvagable salvageItem = (Salvagable) unit; SalvageInfo salvageInfo = salvageItem.getSalvageInfo(); // Create the salvage header panel. JPanel salvageHeaderPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 10)); topContentPanel.add(salvageHeaderPanel); // Create the salvage header label. JLabel salvageHeaderLabel = new JLabel(unit.getName() + " has been salvaged.", JLabel.CENTER); salvageHeaderPanel.add(salvageHeaderLabel); // Create the salvage info panel. JPanel salvageInfoPanel = new JPanel(new BorderLayout(0, 0)); topContentPanel.add(salvageInfoPanel); // Create the time panel. JPanel timePanel = new JPanel(new GridLayout(2, 1, 0, 0)); salvageInfoPanel.add(timePanel, BorderLayout.NORTH); // Create the start time label. String startTimeString = salvageInfo.getStartTime().getDateTimeStamp(); JLabel startTimeLabel = new JLabel("Start Time: " + startTimeString, JLabel.LEFT); timePanel.add(startTimeLabel); // Create the finish time label. MarsClock finishTime = salvageInfo.getFinishTime(); finishTimeString = ""; if (finishTime != null) finishTimeString = finishTime.getDateTimeStamp(); finishTimeLabel = new JLabel("Finish Time: " + finishTimeString, JLabel.LEFT); timePanel.add(finishTimeLabel); // Create the settlement panel. JPanel settlementPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); salvageInfoPanel.add(settlementPanel); // Create the settlement label. JLabel settlementLabel = new JLabel("Settlement: "); settlementPanel.add(settlementLabel); // Create the settlement button. JButton settlementButton = new JButton(salvageInfo.getSettlement().getName()); settlementButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { SalvageInfo info = ((Salvagable) getUnit()).getSalvageInfo(); getDesktop().openUnitWindow(info.getSettlement(), false); } }); settlementPanel.add(settlementButton); // Create the parts panel. JPanel partsPanel = new JPanel(new BorderLayout(0, 10)); partsPanel.setBorder(new MarsPanelBorder()); topContentPanel.add(partsPanel); // Create the parts label. JLabel partsLabel = new JLabel("Salvaged Parts", JLabel.CENTER); partsPanel.add(partsLabel, BorderLayout.NORTH); // Create the parts table panel. JScrollPane partsTablePanel = new JScrollPane(); partsPanel.add(partsTablePanel, BorderLayout.CENTER); // Create the parts table. partTableModel = new PartTableModel(salvageInfo); JTable partsTable = new JTable(partTableModel); partsTable.setPreferredScrollableViewportSize(new Dimension(150, 75)); partsTable.getColumnModel().getColumn(0).setPreferredWidth(100); partsTable.getColumnModel().getColumn(1).setPreferredWidth(50); partsTable.setCellSelectionEnabled(false); partsTable.setDefaultRenderer(Double.class, new NumberCellRenderer(1)); partsTablePanel.setViewportView(partsTable); }
Example 17
Source File: Main_CustomersFrame.java From Hotel-Properties-Management-System with GNU General Public License v2.0 | 4 votes |
public Main_CustomersFrame() { this.setAutoscrolls(true); this.setMinimumSize(new Dimension(800, 600)); /*make it default size of frame maximized */ this.setMaximumSize(new Dimension(1000, 900)); this.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null)); setLayout(new BorderLayout(0, 0)); bean = LocaleBean.getInstance(); loggingEngine = LoggingEngine.getInstance(); componentOrientation = new ChangeComponentOrientation(); componentOrientation.setThePanel(this); searchPanel.setDoubleBuffered(false); searchPanel.setAutoscrolls(true); add(searchPanel, BorderLayout.NORTH); searchPanel.setPreferredSize(new Dimension(10, 30)); lblTableFilter = new JLabel("Type to search : "); lblTableFilter.setForeground(new Color(178, 34, 34)); lblTableFilter.setSize(new Dimension(130, 25)); lblTableFilter.setPreferredSize(new Dimension(130, 22)); lblTableFilter.setHorizontalTextPosition(SwingConstants.CENTER); lblTableFilter.setAutoscrolls(true); lblTableFilter.setHorizontalAlignment(SwingConstants.LEFT); lblTableFilter.setFont(new Font("Dialog", Font.BOLD, 15)); searchFilterField = new JTextField(); searchFilterField.setDragEnabled(true); searchFilterField.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, new Color(0, 191, 255), null, null, null)); searchFilterField.setPreferredSize(new Dimension(200, 22)); searchFilterField.setIgnoreRepaint(true); searchFilterField.setColumns(10); searchFilterField.setFont(new Font("Dialog", Font.BOLD, 13)); searchFilterField.setHorizontalAlignment(SwingConstants.LEFT); GroupLayout gl_searchPanel = new GroupLayout(searchPanel); gl_searchPanel.setHorizontalGroup( gl_searchPanel.createParallelGroup(Alignment.LEADING) .addGroup(gl_searchPanel.createSequentialGroup() .addContainerGap() .addComponent(lblTableFilter, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(searchFilterField, GroupLayout.DEFAULT_SIZE, 208, Short.MAX_VALUE) .addGap(118)) ); gl_searchPanel.setVerticalGroup( gl_searchPanel.createParallelGroup(Alignment.LEADING) .addGroup(gl_searchPanel.createSequentialGroup() .addGap(5) .addGroup(gl_searchPanel.createParallelGroup(Alignment.BASELINE) .addComponent(lblTableFilter, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(searchFilterField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); searchPanel.setLayout(gl_searchPanel); searchFilterField.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { final String searchedWord = searchFilterField.getText(); filter(searchedWord); } }); scrollPane = new JScrollPane(); add(scrollPane); //populate main table model with custom method populateMainTable(model); customerTable = new JTable(model); customerTable.setFillsViewportHeight(true); customerTable.setRowSelectionAllowed(true); THR.setHorizontalAlignment(SwingConstants.CENTER); customerTable.setDefaultRenderer(Object.class, renderer); customerTable.getTableHeader().setDefaultRenderer(THR); customerTable.setFont(new Font("Dialog", Font.PLAIN, 14)); customerTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); customerTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); customerTable.setBackground(new Color(245, 245, 245)); customerTable.addMouseListener(openCustomerListener()); scrollPane.setViewportView(customerTable); //change component orientation with locale. if (bean.getLocale().toString().equals("ar_IQ")) { componentOrientation.changeOrientationOfJPanelToRight(); } else { componentOrientation.changeOrientationOfJPanelToLeft(); } //inject action event to Customers detail window to save all changes custWindow.setActionListener(saveChanges()); this.setVisible(true); }
Example 18
Source File: EquipmentModels.java From pcgen with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void actionPerformed(ActionEvent e) { EquipmentSetFacade equipSet = character.getEquipmentSetRef().get(); List<EquipNode> paths = getSelectedEquipmentSetNodes(); if (!paths.isEmpty()) { Object[][] data = new Object[paths.size()][3]; for (int i = 0; i < paths.size(); i++) { EquipNode path = paths.get(i); data[i][0] = path.getEquipment(); data[i][1] = equipSet.getQuantity(path); } Object[] columns = {LanguageBundle.getString("in_equipItem"), //$NON-NLS-1$ LanguageBundle.getString("in_equipQuantityAbbrev"), //$NON-NLS-1$ }; DefaultTableModel tableModel = new DefaultTableModel(data, columns) { @Override public Class<?> getColumnClass(int columnIndex) { if (columnIndex == 1) { return Integer.class; } return Object.class; } @Override public boolean isCellEditable(int row, int column) { return column != 0; } }; JTable table = new JTable(tableModel); table.setFocusable(false); table.setCellSelectionEnabled(false); table.setDefaultRenderer(Integer.class, new TableCellUtilities.SpinnerRenderer()); table.setDefaultEditor(Integer.class, new SpinnerEditor(equipSet.getEquippedItems())); table.setRowHeight(22); table.getColumnModel().getColumn(0).setPreferredWidth(140); table.getColumnModel().getColumn(1).setPreferredWidth(50); table.setPreferredScrollableViewportSize(table.getPreferredSize()); JTableHeader header = table.getTableHeader(); header.setReorderingAllowed(false); JScrollPane pane = EquipmentModels.prepareScrollPane(table); JPanel panel = new JPanel(new BorderLayout()); JLabel help = new JLabel(LanguageBundle.getString("in_equipSelectUnequipQty")); //$NON-NLS-1$ panel.add(help, BorderLayout.NORTH); panel.add(pane, BorderLayout.CENTER); int res = JOptionPane.showConfirmDialog(JOptionPane.getFrameForComponent(equipmentTable), panel, LanguageBundle.getString("in_equipUnequipSel"), //$NON-NLS-1$ JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (res == JOptionPane.OK_OPTION) { for (int i = 0; i < paths.size(); i++) { equipSet.removeEquipment(paths.get(i), (Integer) tableModel.getValueAt(i, 1)); } } } }
Example 19
Source File: PixelExtractionParametersForm.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
private JComponent[] createCoordinatesComponents() { Product selectedProduct = appContext.getSelectedProduct(); if (selectedProduct != null) { final PlacemarkGroup pinGroup = selectedProduct.getPinGroup(); for (int i = 0; i < pinGroup.getNodeCount(); i++) { coordinateTableModel.addPlacemark(pinGroup.get(i)); } } JTable coordinateTable = new JTable(coordinateTableModel); coordinateTable.setName("coordinateTable"); coordinateTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN); coordinateTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); coordinateTable.setRowSelectionAllowed(true); coordinateTable.getTableHeader().setReorderingAllowed(false); coordinateTable.setDefaultRenderer(Double.class, new DecimalTableCellRenderer(new DecimalFormat("0.0000"))); coordinateTable.setPreferredScrollableViewportSize(new Dimension(250, 100)); coordinateTable.getColumnModel().getColumn(1).setCellEditor(new DecimalCellEditor(-90, 90)); coordinateTable.getColumnModel().getColumn(2).setCellEditor(new DecimalCellEditor(-180, 180)); final DateFormat dateFormat = ProductData.UTC.createDateFormat("yyyy-MM-dd'T'HH:mm:ss"); // ISO 8601 final DateFormat timeFormat = ProductData.UTC.createDateFormat("HH:mm:ss"); // ISO 8601 DateTimePickerCellEditor cellEditor = new DateTimePickerCellEditor(dateFormat, timeFormat); cellEditor.setClickCountToStart(1); coordinateTable.getColumnModel().getColumn(3).setCellEditor(cellEditor); coordinateTable.getColumnModel().getColumn(3).setPreferredWidth(200); final DateCellRenderer dateCellRenderer = new DateCellRenderer(dateFormat); dateCellRenderer.setHorizontalAlignment(SwingConstants.RIGHT); coordinateTable.getColumnModel().getColumn(3).setCellRenderer(dateCellRenderer); final JScrollPane rasterScrollPane = new JScrollPane(coordinateTable); final AbstractButton addButton = ToolButtonFactory.createButton(ADD_ICON, false); addButton.addActionListener(new AddPopupListener()); final AbstractButton removeButton = ToolButtonFactory.createButton(REMOVE_ICON, false); removeButton.addActionListener(new RemovePlacemarksListener(coordinateTable, coordinateTableModel)); final JPanel buttonPanel = new JPanel(); final BoxLayout layout = new BoxLayout(buttonPanel, BoxLayout.Y_AXIS); buttonPanel.setLayout(layout); buttonPanel.add(addButton); buttonPanel.add(removeButton); return new JComponent[]{rasterScrollPane, buttonPanel}; }
Example 20
Source File: BBoxDBGui.java From bboxdb with Apache License 2.0 | 4 votes |
/** * Build the BBoxDB dialog, init GUI components * and assemble the dialog */ public void run() { mainframe = new JFrame("BBoxDB - GUI Client"); setupMenu(); mainPanel = buildSplitPane(); updateMainPanel(); tableModel = getTableModel(); final JTable table = new JTable(tableModel); table.getColumnModel().getColumn(0).setMaxWidth(40); table.getColumnModel().getColumn(2).setMinWidth(100); table.getColumnModel().getColumn(2).setMaxWidth(100); table.setDefaultRenderer(Object.class, new InstanceTableRenderer()); final JScrollPane tableScrollPane = new JScrollPane(table); final Dimension dimension = table.getPreferredSize(); if(dimension != null) { tableScrollPane.setPreferredSize( new Dimension(dimension.width, table.getRowHeight() * 7)); } mainframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainframe.setLayout(new BorderLayout()); mainframe.add(mainPanel, BorderLayout.CENTER); final JPanel southPanel = new JPanel(); southPanel.setLayout(new BorderLayout()); southPanel.add(tableScrollPane, BorderLayout.CENTER); final JPanel statusPanel = new JPanel(); statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED)); statusPanel.setPreferredSize(new Dimension(southPanel.getWidth(), 20)); statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS)); statusLabel = new JLabel(""); statusLabel.setHorizontalAlignment(SwingConstants.LEFT); statusPanel.add(statusLabel); southPanel.add(statusPanel, BorderLayout.SOUTH); mainframe.add(southPanel, BorderLayout.SOUTH); mainframe.pack(); mainframe.setLocationRelativeTo(null); mainframe.setVisible(true); }