List of usage examples for javax.swing JTable getRowCount
@BeanProperty(bound = false) public int getRowCount()
JTable
, given unlimited space. From source file:pl.otros.logview.api.gui.LogViewPanelWrapper.java
private void addRowAutoScroll() { dataTableModel.addTableModelListener(e -> { if (follow.isSelected() && e.getType() == TableModelEvent.INSERT) { final Runnable r = () -> { try { JTable table = logViewPanel.getTable(); int row = table.getRowCount() - 1; if (row > 0) { Rectangle rect = table.getCellRect(row, 0, true); table.scrollRectToVisible(rect); table.clearSelection(); table.setRowSelectionInterval(row, row); }/* w w w. j ava2 s. co m*/ } catch (IllegalArgumentException iae) { // ignore..out of bounds iae.printStackTrace(); } }; // Wait for JViewPort size update // TODO Find way to invoke this listener after viewport is notified about changes Runnable r2 = () -> { try { Thread.sleep(300); } catch (InterruptedException ignore) { } SwingUtilities.invokeLater(r); }; new Thread(r2).start(); } }); }
From source file:pl.otros.logview.gui.actions.MarkAllFoundAction.java
public int markAllFound(JTable table, LogDataTableModel dataTableModel, String string, MarkerColors markerColors) {// w w w .ja va2 s . c om string = string.trim().toLowerCase(); if (string.length() == 0) { return 0; } SearchMatcher searchMatcher; if (SearchMode.STRING_CONTAINS.equals(searchMode)) { searchMatcher = new StringContainsSearchMatcher(string); } else if (SearchMode.REGEX.equals(searchMode)) { try { searchMatcher = new RegexMatcher(string); } catch (Exception e) { getOtrosApplication().getStatusObserver() .updateStatus("Error in regular expression: " + e.getMessage(), StatusObserver.LEVEL_ERROR); return 0; } } else if (SearchMode.QUERY.equals(searchMode)) { QueryAcceptCondition acceptCondition; try { acceptCondition = new QueryAcceptCondition(string); searchMatcher = new AcceptConditionSearchMatcher(acceptCondition); } catch (RuleException e) { getOtrosApplication().getStatusObserver().updateStatus("Wrong query rule: " + e.getMessage(), StatusObserver.LEVEL_ERROR); return 0; } } else { getOtrosApplication().getStatusObserver().updateStatus("Unknown search mode", StatusObserver.LEVEL_ERROR); return 0; } ArrayList<Integer> toMark = new ArrayList<Integer>(); for (int i = 0; i < table.getRowCount(); i++) { int row = table.convertRowIndexToModel(i); if (searchMatcher.matches(dataTableModel.getLogData(row))) { toMark.add(row); } } if (toMark.size() > 0) { int[] rows = new int[toMark.size()]; for (int i = 0; i < rows.length; i++) { rows[i] = toMark.get(i); } dataTableModel.markRows(markerColors, rows); } return toMark.size(); }
From source file:pl.otros.logview.gui.LogViewPanelWrapper.java
private void addRowScroller() { dataTableModel.addTableModelListener(new TableModelListener() { @Override//ww w .ja v a2s.co m public void tableChanged(final TableModelEvent e) { if (follow.isSelected() && e.getType() == TableModelEvent.INSERT) { final Runnable r = new Runnable() { @Override public void run() { try { JTable table = logViewPanel.getTable(); int row = table.getRowCount() - 1; if (row > 0) { Rectangle rect = table.getCellRect(row, 0, true); table.scrollRectToVisible(rect); table.clearSelection(); table.setRowSelectionInterval(row, row); } } catch (IllegalArgumentException iae) { // ignore..out of bounds iae.printStackTrace(); } } }; // Wait for JViewPort size update // TODO Find way to invoke this listener after viewport is notified about changes Runnable r2 = new Runnable() { @Override public void run() { try { Thread.sleep(300); } catch (InterruptedException ignore) { } SwingUtilities.invokeLater(r); } }; new Thread(r2).start(); } } }); }