org.jdesktop.swingx.JXTable Java Examples
The following examples show how to use
org.jdesktop.swingx.JXTable.
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: DesktopRowsCount.java From cuba with Apache License 2.0 | 6 votes |
private void onNextClick() { if (!(datasource instanceof CollectionDatasource.SupportsPaging)) { return; } CollectionDatasource.SupportsPaging ds = (CollectionDatasource.SupportsPaging) datasource; int firstResult = ds.getFirstResult(); ds.setFirstResult(ds.getFirstResult() + ds.getMaxResults()); if (refreshDatasource(ds)) { if (state == State.LAST && size == 0) { ds.setFirstResult(firstResult); int maxResults = ds.getMaxResults(); ds.setMaxResults(maxResults + 1); refreshDatasource(ds); ds.setMaxResults(maxResults); } if (owner instanceof DesktopAbstractTable) { JXTable table = (JXTable) ((DesktopAbstractTable) owner).getComponent(); table.scrollRowToVisible(0); } } else { ds.setFirstResult(firstResult); } }
Example #2
Source File: DesktopRowsCount.java From cuba with Apache License 2.0 | 6 votes |
private void onPrevClick() { if (!(datasource instanceof CollectionDatasource.SupportsPaging)) { return; } CollectionDatasource.SupportsPaging ds = (CollectionDatasource.SupportsPaging) datasource; int firstResult = ds.getFirstResult(); int newStart = ds.getFirstResult() - ds.getMaxResults(); ds.setFirstResult(newStart < 0 ? 0 : newStart); if (refreshDatasource(ds)) { if (owner instanceof DesktopAbstractTable) { JXTable table = (JXTable) ((DesktopAbstractTable) owner).getComponent(); table.scrollRowToVisible(0); } } else { ds.setFirstResult(firstResult); } }
Example #3
Source File: DesktopRowsCount.java From cuba with Apache License 2.0 | 6 votes |
protected void onFirstClick() { if (!(datasource instanceof CollectionDatasource.SupportsPaging)) { return; } CollectionDatasource.SupportsPaging ds = (CollectionDatasource.SupportsPaging) datasource; int firstResult = ds.getFirstResult(); ds.setFirstResult(0); if (refreshDatasource(ds)) { if (owner instanceof DesktopAbstractTable) { JXTable table = (JXTable) ((DesktopAbstractTable) owner).getComponent(); table.scrollRowToVisible(0); } } else { ds.setFirstResult(firstResult); } }
Example #4
Source File: DesktopRowsCount.java From cuba with Apache License 2.0 | 6 votes |
protected void onLastClick() { if (!(datasource instanceof CollectionDatasource.SupportsPaging)) { return; } CollectionDatasource.SupportsPaging ds = (CollectionDatasource.SupportsPaging) datasource; int count = ((CollectionDatasource.SupportsPaging) datasource).getCount(); int itemsToDisplay = count % ds.getMaxResults(); if (itemsToDisplay == 0) itemsToDisplay = ds.getMaxResults(); int firstResult = ds.getFirstResult(); ds.setFirstResult(count - itemsToDisplay); if (refreshDatasource(ds)) { if (owner instanceof DesktopAbstractTable) { JXTable table = (JXTable) ((DesktopAbstractTable) owner).getComponent(); table.scrollRowToVisible(0); } } else { ds.setFirstResult(firstResult); } }
Example #5
Source File: ImportPanel.java From BART with MIT License | 6 votes |
private void initJTableFiles() { jTableFiles = new JXTable(); jTableFilesTableModel = new DBMSImportTableModel(jTableFiles); jTableFiles.setColumnControlVisible(true); jTableFiles.setEditable(false); jTableFiles.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTableFiles.setModel(jTableFilesTableModel); jTableFiles.setShowGrid(true); jTableFiles.setDragEnabled(false); jTableFiles.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if(jTableFiles.getSelectedRow() < 0) { delFileButton.setEnabled(false); }else{ delFileButton.setEnabled(true); } } }); scrollPaneFiles.setViewportView(jTableFiles); }
Example #6
Source File: CardsDeckCheckerPanel.java From MtgDesktopCompanion with GNU General Public License v3.0 | 6 votes |
public CardsDeckCheckerPanel() { setLayout(new BorderLayout(0, 0)); buzyLabel = AbstractBuzyIndicatorComponent.createLabelComponent(); JPanel panel = new JPanel(); manager = new MTGDeckManager(); model = new DeckSelectionTableModel(); table = new JXTable(model); table.getColumnModel().getColumn(1).setCellRenderer(new ManaCellRenderer()); add(panel, BorderLayout.NORTH); panel.add(buzyLabel); add(new JScrollPane(table), BorderLayout.CENTER); addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent componentEvent) { init(); } }); }
Example #7
Source File: ShowCallHierarchyAction.java From otroslogviewer with Apache License 2.0 | 6 votes |
@Override public void action(ActionEvent e, CallHierarchyLogFilter filter, LogData... selectedLogData) throws Exception { Optional<JXTable> maybeTable = getOtrosApplication().getSelectPaneJXTable(); Optional<LogDataTableModel> dataT2ableModel = getOtrosApplication().getSelectedPaneLogDataTableModel(); maybeTable.ifPresent(jTable -> dataT2ableModel.ifPresent(dataTableModel -> { int selected = jTable.getSelectedRow(); selected = jTable.convertRowIndexToModel(selected); ArrayList<Integer> listOfEvents2 = new ArrayList<>(); HashSet<Integer> listEntryEvents = new HashSet<>(); try { findCallHierarchyEvents(selected, dataTableModel, listEntryEvents, listOfEvents2); } catch (NoSuchElementException e1) { LOGGER.error("Log file do not have consistent Entry/Return in logs"); getOtrosApplication().getStatusObserver().updateStatus("Log file does not have consistent Entry/Return in logs", StatusObserver.LEVEL_ERROR); } filter.setListId(listEntryEvents, listOfEvents2); filterEnableCheckBox.setSelected(true); filter.setEnable(true); })); }
Example #8
Source File: MarkRowAction.java From otroslogviewer with Apache License 2.0 | 6 votes |
@Override protected void actionPerformedHook(ActionEvent e) { Optional<LogDataTableModel> maybeModel = getOtrosApplication().getSelectedPaneLogDataTableModel(); Optional<JXTable> maybeTable = getOtrosApplication().getSelectPaneJXTable(); maybeTable.ifPresent(table -> maybeModel.ifPresent(model -> { StatusObserver observer = getOtrosApplication().getStatusObserver(); if (model == null || table == null) { return; } int[] selected = table.getSelectedRows(); for (int i = 0; i < selected.length; i++) { selected[i] = table.convertRowIndexToModel(selected[i]); } model.markRows(getOtrosApplication().getSelectedMarkColors(), selected); if (observer != null) { observer.updateStatus(selected.length + " rows marked"); } })); }
Example #9
Source File: UnMarkRowAction.java From otroslogviewer with Apache License 2.0 | 6 votes |
@Override protected void actionPerformedHook(ActionEvent e) { Optional<JXTable> maybeTable = getOtrosApplication().getSelectPaneJXTable(); Optional<LogDataTableModel> maybeModel = getOtrosApplication().getSelectedPaneLogDataTableModel(); maybeTable.ifPresent(table -> maybeModel.ifPresent(model -> { StatusObserver observer = getOtrosApplication().getStatusObserver(); int[] selected = table.getSelectedRows(); for (int i = 0; i < selected.length; i++) { selected[i] = table.convertRowIndexToModel(selected[i]); } model.unmarkRows(selected); if (observer != null) { observer.updateStatus(selected.length + " rows unmarked"); } })); }
Example #10
Source File: FocusOnThisAbstractAction.java From otroslogviewer with Apache License 2.0 | 6 votes |
@Override protected void actionPerformedHook(ActionEvent e) { Optional<JXTable> maybeTable = getOtrosApplication().getSelectPaneJXTable(); final Optional<LogDataTableModel> maybeTableModel = getOtrosApplication().getSelectedPaneLogDataTableModel(); maybeTable.ifPresent(jxTable -> maybeTableModel.ifPresent(tableModel -> { int[] selectedRows = jxTable.getSelectedRows(); if (selectedRows.length <= 0) { return; } LogData[] selectedLogData = new LogData[selectedRows.length]; for (int i = 0; i < selectedRows.length; i++) { selectedLogData[i] = tableModel.getLogData(jxTable.convertRowIndexToModel(selectedRows[i])); } try { action(e, filter, selectedLogData); filterEnableCheckBox.setSelected(true); filter.setEnable(true); } catch (Exception e1) { LOGGER.error("Error occurred when focusing on events ", e1); JOptionPane.showMessageDialog(getOtrosApplication().getApplicationJFrame(), e1.getLocalizedMessage(), "Error", JOptionPane.ERROR_MESSAGE); } })); }
Example #11
Source File: MarkRowBySpaceKeyListener.java From otroslogviewer with Apache License 2.0 | 6 votes |
private void markUnmarkRow() { Optional<LogDataTableModel> maybeDataTableModel = otrosApplication.getSelectedPaneLogDataTableModel(); Optional<JXTable> maybeTable = otrosApplication.getSelectPaneJXTable(); maybeTable.ifPresent(table -> maybeDataTableModel.ifPresent(dataTableModel -> { int[] selected = table.getSelectedRows(); if (selected.length == 0) { return; } boolean modeMark = !dataTableModel.isMarked(selected[0]); if (modeMark) { dataTableModel.markRows(otrosApplication.getSelectedMarkColors(), selected); } else { dataTableModel.unmarkRows(selected); } } )); }
Example #12
Source File: UIHelper.java From dsworkbench with Apache License 2.0 | 5 votes |
public static void initTableColums(JXTable table, int width, String... headers) { for (String caption : headers) { TableColumnExt columns = table.getColumnExt(caption); columns.setPreferredWidth(width); columns.setMaxWidth(width); columns.setWidth(width); } }
Example #13
Source File: RelativePainterHighlighter.java From BART with MIT License | 5 votes |
private int getColumnLocation(ComponentAdapter adapter, int visualColumn) { if (!(adapter.getComponent() instanceof JXTable)) { return 0; } JXTable table = (JXTable) adapter.getComponent(); // PENDING JW: guard against null header return table.getTableHeader().getHeaderRect(visualColumn).x; }
Example #14
Source File: TableDataView.java From BART with MIT License | 5 votes |
private void initJTable() { valueTable = new JXTable(); valueTable.setColumnControlVisible(true); valueTable.setEditable(false); valueTable.setDefaultRenderer(Object.class, new TableValueCellRender()); valueTable.setCellSelectionEnabled(true); valueTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); valueTable.setModel(dataModel); valueTable.setShowGrid(true); valueTable.setDragEnabled(false); valueTable.setSelectionBackground(new Color(214, 217, 223)); valueTable.setVisibleRowCount(20); pageCtrlPanel.setVisibleRow(20+""); }
Example #15
Source File: AlertedCardsTrendingDashlet.java From MtgDesktopCompanion with GNU General Public License v3.0 | 5 votes |
@Override public void initGUI() { JScrollPane scrollPane = new JScrollPane(); getContentPane().add(scrollPane, BorderLayout.CENTER); model = new CardAlertTableModel(); JXTable table = new JXTable(model); scrollPane.setViewportView(table); HistoryPricesPanel historyPricesPanel = new HistoryPricesPanel(false); historyPricesPanel.setPreferredSize(new Dimension(119, 200)); getContentPane().add(historyPricesPanel, BorderLayout.SOUTH); table.getColumnModel().getColumn(4).setCellRenderer(new CardShakeRenderer()); table.getColumnModel().getColumn(5).setCellRenderer(new CardShakeRenderer()); table.getColumnModel().getColumn(1).setCellRenderer(new MagicEditionsComboBoxCellRenderer(false)); table.getSelectionModel().addListSelectionListener(event -> { if (!event.getValueIsAdjusting()) { ThreadManager.getInstance().invokeLater(() -> { int row = table.getSelectedRow(); MagicCardAlert alt = (MagicCardAlert) table.getValueAt(row, 0); historyPricesPanel.init(alt.getCard(), alt.getCard().getCurrentSet(),alt.getCard().toString()); historyPricesPanel.revalidate(); }); } }); if (getProperties().size() > 0) { Rectangle r = new Rectangle((int) Double.parseDouble(getString("x")), (int) Double.parseDouble(getString("y")), (int) Double.parseDouble(getString("w")), (int) Double.parseDouble(getString("h"))); setBounds(r); } table.packAll(); }
Example #16
Source File: SimilarityCardPanel.java From MtgDesktopCompanion with GNU General Public License v3.0 | 5 votes |
public SimilarityCardPanel() { setLayout(new BorderLayout(0, 0)); model = new SimilarityCardsTableModel(); tableSimilarity = new JXTable(model); add(new JScrollPane(tableSimilarity), BorderLayout.CENTER); addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent componentEvent) { init(currentCard); } }); }
Example #17
Source File: IndexationDashlet.java From MtgDesktopCompanion with GNU General Public License v3.0 | 5 votes |
public void initGUI() { JPanel panneauHaut = new JPanel(); getContentPane().add(panneauHaut, BorderLayout.NORTH); try { cboField = UITools.createCombobox(MTGControler.getInstance().getEnabled(MTGCardsIndexer.class).listFields()); } catch(Exception e) { cboField.addItem("NO INDEXER FILE FOUND"); } panneauHaut.add(cboField); indexModel = new MapTableModel<>(); indexModel.setColumnNameAt(0, "Term"); indexModel.setColumnNameAt(1, "Occurences"); JXTable table = new JXTable(indexModel); getContentPane().add(new JScrollPane(table), BorderLayout.CENTER); cboField.addItemListener(ie -> { if (ie.getStateChange() == ItemEvent.SELECTED) { init(); } }); if (getProperties().size() > 0) { Rectangle r = new Rectangle((int) Double.parseDouble(getString("x")), (int) Double.parseDouble(getString("y")), (int) Double.parseDouble(getString("w")), (int) Double.parseDouble(getString("h"))); setBounds(r); } }
Example #18
Source File: MkmOversightDashlet.java From MtgDesktopCompanion with GNU General Public License v3.0 | 5 votes |
@Override public void initGUI() { getContentPane().setLayout(new BorderLayout(0, 0)); model=new GenericTableModel<>(); JPanel panneauHaut = new JPanel(); getContentPane().add(panneauHaut, BorderLayout.NORTH); comboBox = UITools.createCombobox(INSIGHT_SELECTION.values()); panneauHaut.add(comboBox); service = new InsightService(); JXTable table = new JXTable(model); getContentPane().add(new JScrollPane(table), BorderLayout.CENTER); comboBox.addItemListener(pcl->{ if (pcl.getStateChange() == ItemEvent.SELECTED) { init(); } }); if (getProperties().size() > 0) { Rectangle r = new Rectangle((int) Double.parseDouble(getString("x")), (int) Double.parseDouble(getString("y")), (int) Double.parseDouble(getString("w")), (int) Double.parseDouble(getString("h"))); setBounds(r); if(getString(INSIGHT_SELECTION_KEY)!=null) comboBox.setSelectedItem(INSIGHT_SELECTION.valueOf(getString(INSIGHT_SELECTION_KEY))); } }
Example #19
Source File: TokenGenMessagesTable.java From zap-extensions with Apache License 2.0 | 5 votes |
@Override protected int getRowCount(final JXTable table) { final int rowCount = super.getRowCount(table); if (rowCount > MAX_CONFIG_ROW_COUNT) { return MAX_CONFIG_ROW_COUNT; } return rowCount; }
Example #20
Source File: PropertyHelper.java From dsworkbench with Apache License 2.0 | 5 votes |
public static void storeTableProperties(JXTable pTable, Configuration pConfig, String pPrefix) { List<TableColumn> cols = ((TableColumnModelExt) pTable.getColumnModel()).getColumns(true); for (TableColumn c : cols) { TableColumnExt col = (TableColumnExt) c; String title = col.getTitle(); pConfig.setProperty(pPrefix + ".table.col." + title + ".width", col.getWidth()); pConfig.setProperty(pPrefix + ".table.col." + title + ".visible", col.isVisible()); } int sortedCol = pTable.getSortedColumnIndex(); if (sortedCol < 0) { return; } pConfig.setProperty(pPrefix + ".table.sort.col", sortedCol); int sortOrder = 0; switch (pTable.getSortOrder(sortedCol)) { case ASCENDING: sortOrder = 1; break; case DESCENDING: sortOrder = -1; break; default: sortOrder = 0; } pConfig.setProperty(pPrefix + ".table.sort.order", sortOrder); pConfig.setProperty(pPrefix + ".table.horizontal.scroll", pTable.isHorizontalScrollEnabled()); }
Example #21
Source File: RelativePainterHighlighter.java From BART with MIT License | 5 votes |
private int getColumnWidth(ComponentAdapter adapter, int visualColumn) { if (!(adapter.getComponent() instanceof JXTable)) { return adapter.getComponent().getWidth(); } JXTable table = (JXTable) adapter.getComponent(); return table.getColumn(visualColumn).getWidth(); }
Example #22
Source File: RelativePainterHighlighter.java From BART with MIT License | 5 votes |
private int getColumnAt(ComponentAdapter adapter, int pixelLocation) { if (!(adapter.getComponent() instanceof JXTable)) { return 0; } JXTable table = (JXTable) adapter.getComponent(); // PENDING JW: guard against null header return table.getTableHeader().columnAtPoint( new Point(pixelLocation, 10)); }
Example #23
Source File: VioGenQueriesWPanel.java From BART with MIT License | 5 votes |
private void initTable() { table = new JXTable(); table.setColumnControlVisible(true); table.setEditable(true); table.setCellSelectionEnabled(true); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setShowGrid(true); table.setDragEnabled(false); table.setSelectionBackground(new Color(214, 217, 223)); highlighterControl = new HighlighterControl(); }
Example #24
Source File: ChartTopComponent.java From BART with MIT License | 5 votes |
private void initTable() { cellChangesTable = new JXTable(); cellChangesTable.setEditable(false); cellChangesTable.setColumnControlVisible(true); cellChangesTable.setShowGrid(true); cellChangesTable.setDragEnabled(false); cellChangesTable.setSelectionBackground(new Color(214, 217, 223)); cellChangesTable.setModel(model); }
Example #25
Source File: Example_7a_View.java From Java_MVVM_with_Swing_and_RxJava_Examples with Apache License 2.0 | 5 votes |
public Example_7a_View() { super(); setTitle(getClass().getSimpleName() + " " + ManagementFactory.getRuntimeMXBean().getName()); setBounds(100, 100, 700, 500); setDefaultCloseOperation(StrictThreadingJFrame.EXIT_ON_CLOSE); getContentPane().setLayout(new BorderLayout(0, 0)); final JXTable table = new JXTable(myTableModel); table.setHighlighters(HighlighterFactory.createSimpleStriping()); table.setSortable(false); table.getTableHeader().setReorderingAllowed(false); myTableModel.addTableModelListener(new TableModelListener() { int lastRowCountScrolledTo = -1; @Override public void tableChanged(final TableModelEvent e) { if (TableUtilities.isInsert(e)) { final int currentRowCount = myTableModel.getRowCount(); if (currentRowCount != lastRowCountScrolledTo) { lastRowCountScrolledTo = currentRowCount; SwingUtilities.invokeLater(() -> table.scrollRectToVisible(table.getCellRect(myTableModel.getRowCount() - 1, 0, false))); } } } }); JScrollPane scrollPane = new JScrollPane(table); getContentPane().add(scrollPane, BorderLayout.CENTER); }
Example #26
Source File: Example_7_View.java From Java_MVVM_with_Swing_and_RxJava_Examples with Apache License 2.0 | 5 votes |
public Example_7_View() { super(); setTitle(getClass().getSimpleName() + " " + ManagementFactory.getRuntimeMXBean().getName()); setBounds(100, 100, 700, 500); setDefaultCloseOperation(StrictThreadingJFrame.EXIT_ON_CLOSE); getContentPane().setLayout(new BorderLayout(0, 0)); final JXTable table = new JXTable(myTableModel); table.setHighlighters(HighlighterFactory.createSimpleStriping()); table.setSortable(false); table.getTableHeader().setReorderingAllowed(false); myTableModel.addTableModelListener(new TableModelListener() { int lastRowCountScrolledTo = -1; @Override public void tableChanged(final TableModelEvent e) { if (TableUtilities.isInsert(e)) { final int currentRowCount = myTableModel.getRowCount(); if (currentRowCount != lastRowCountScrolledTo) { lastRowCountScrolledTo = currentRowCount; SwingUtilities.invokeLater(() -> table.scrollRectToVisible(table.getCellRect(myTableModel.getRowCount() - 1, 0, false))); } } } }); JScrollPane scrollPane = new JScrollPane(table); getContentPane().add(scrollPane, BorderLayout.CENTER); }
Example #27
Source File: Example_8_View.java From Java_MVVM_with_Swing_and_RxJava_Examples with Apache License 2.0 | 5 votes |
public Example_8_View() { super(); setTitle(getClass().getSimpleName() + " " + ManagementFactory.getRuntimeMXBean().getName()); setBounds(100, 100, 700, 500); setDefaultCloseOperation(StrictThreadingJFrame.EXIT_ON_CLOSE); getContentPane().setLayout(new BorderLayout(0, 0)); final JXTable table = new JXTable(myTableModel); table.setHighlighters(HighlighterFactory.createSimpleStriping()); table.setSortable(false); table.getTableHeader().setReorderingAllowed(false); myTableModel.addTableModelListener(new TableModelListener() { int lastRowCountScrolledTo = -1; @Override public void tableChanged(final TableModelEvent e) { if (TableUtilities.isInsert(e)) { final int currentRowCount = myTableModel.getRowCount(); if (currentRowCount != lastRowCountScrolledTo) { lastRowCountScrolledTo = currentRowCount; SwingUtilities.invokeLater(() -> table.scrollRectToVisible(table.getCellRect(myTableModel.getRowCount() - 1, 0, false))); } } } }); JScrollPane scrollPane = new JScrollPane(table); getContentPane().add(scrollPane, BorderLayout.CENTER); }
Example #28
Source File: CSVSettingsPanel.java From ganttproject with GNU General Public License v3.0 | 5 votes |
JComponent createTaskExportFieldsPanel(TableModel tableModel, String id) { JXTable table = new JXTable(tableModel); table.setTableHeader(null); table.setVisibleRowCount(10); JScrollPane scrollPane = new JScrollPane(table); JPanel panel = new JPanel(new BorderLayout()); panel.add(BorderLayout.CENTER, scrollPane); UIUtil.createTitle(panel, language.getText(id)); return panel; }
Example #29
Source File: ParametersPanel.java From nextreports-designer with Apache License 2.0 | 5 votes |
private void createTable() { model = new ParametersTableModel(); table = new JXTable(model); table.setSortable(false); //table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setRolloverEnabled(true); table.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.RED)); }
Example #30
Source File: ImportPreviewTable.java From chipster with MIT License | 5 votes |
public ImportPreviewTable(ImportScreen importScreen, TableInternalFrame tableFrame){ super(); this.screen = importScreen; this.conversionModel = importScreen.getConversionModel(); this.tableFrame = tableFrame; this.columnTypeManager = screen.getColumnTypeManager(); this.setAutoResizeMode(JXTable.AUTO_RESIZE_OFF); this.setSortable(false); this.setTableHeader(new EditableHeader(this.getColumnModel())); this.getTableHeader().setReorderingAllowed(false); this.getTableHeader().setEnabled(false); this.defaultInitialDelay = ToolTipManager.sharedInstance().getInitialDelay(); this.defaultDismissDelay = ToolTipManager.sharedInstance().getDismissDelay(); // Renderers for data, headers and footers setDefaultRenderer(String.class, new ImportCellRenderer()); setDefaultRenderer(Double.class, new ImportCellRenderer()); // Renderer for row numbers setDefaultRenderer(Integer.class, new RowNumberRenderer()); // Mouse listeners this.addMouseListener(this); this.addMouseMotionListener(this); }