@Override public void pushMessage(LogMessage logMessage) { logTableModel.pushMessage(logMessage); // Scroll to bottom if nothing is selected if (!logTableModel.isPaused()) { logTable.scrollRectToVisible( logTable.getCellRect(logTableModel.getRowCount() - 1, 0, true) ); } }
public static void scrollToVisible(JTable table, int rowIndex, int vColIndex) { if (!(table.getParent() instanceof JViewport)) { return; } JViewport viewport = (JViewport)table.getParent(); // This rectangle is relative to the table where the // northwest corner of cell (0,0) is always (0,0). Rectangle rect = table.getCellRect(rowIndex, vColIndex, true); // The location of the viewport relative to the table Point pt = viewport.getViewPosition(); // Translate the cell location so that it is relative // to the view, assuming the northwest corner of the // view is (0,0) rect.setLocation(rect.x-pt.x, rect.y-pt.y); table.scrollRectToVisible(rect); // Scroll the area into view //viewport.scrollRectToVisible(rect); }
Rectangle cellRect = jTable_PromptSet.getCellRect(row + 4, column, false); jTable_PromptSet.scrollRectToVisible(cellRect); jTable_PromptSet.updateUI();
private JTable _table = new JTable(); ... JButton b = new JButton("Force scroll to bottom"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { _table.scrollRectToVisible(_table.getCellRect(_table.getRowCount()-1, 0, true)); } }); this.add(b);
private JTable _table = new JTable(); ... _table.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { _table.scrollRectToVisible(_table.getCellRect(_table.getRowCount()-1, 0, true)); } });
public void componentResized(ComponentEvent e) { table.scrollRectToVisible(new Rectangle(table.getCellRect(nbElements, 0, true))); } });
return label; Rectangle cellRect = jTable.getCellRect(row, col, false); BufferedImage bim = renderGlyph(path, bounds2D, cellRect); return new JLabel(new ImageIcon(bim), SwingConstants.CENTER); Rectangle cellRect = jTable.getCellRect(row, col, false); BufferedImage glyphImage = (BufferedImage) o; BufferedImage cellImage = new BufferedImage((int) cellRect.getWidth(), (int) cellRect.getHeight(), BufferedImage.TYPE_INT_RGB);
g2.setPaint(oldPaint); for (int row : getSelectedRows()) { Rectangle start = getCellRect(row, 0, true); Rectangle end = getCellRect(row, getColumnCount() - 1, true); g2.setPaint(new GradientPaint(start.x, 0, controlColor, (int) ((end.x + end.width - start.x) * 1.25), 0, Color.orange)); g2.fillRect(start.x, start.y, end.x + end.width - start.x, start.height);
g2.setPaint(oldPaint); for (int row : getSelectedRows()) { Rectangle start = getCellRect(row, 0, true); Rectangle end = getCellRect(row, getColumnCount() - 1, true); g2.setPaint(new GradientPaint(start.x, 0, controlColor, (int) ((end.x + end.width - start.x) * 1.25), 0, Color.orange)); g2.fillRect(start.x, start.y, end.x + end.width - start.x, start.height);
model.addRow(new Object[]{this.response.get("Method"), this.url, this.response.get("Content-Length"), this.response.get("Content-Type")}); Rectangle rect = table.getCellRect(table.getRowCount() - 1, 0, true); Point pt = viewport.getViewPosition(); rect.translate(-pt.x, -pt.y);
/** * Refers to the default implementation of getCellRect() * because overridden. * @param row the row index * @param column the column index * @param includeSpacing false to return the true cell bounds * @return the rectangle * @see JTable#getCellRect(int, int, boolean) */ public Rectangle getDefaultCellRect(int row, int column, boolean includeSpacing) { return super.getCellRect(row, column, includeSpacing); }
public Rectangle getCellBounds(int index0, int index1) { Rectangle r0= table.getCellRect(index0, COLUMN_FILENAME, false); Rectangle r1= table.getCellRect(index1, COLUMN_FILENAME, false); return r0.union(r1); }
/** * Returns the processor that user pointed to obtain a breakpoint */ private Processor getPointedProcessor(int X, int Y, JTable table) { final Processor[] processors = theModel.getProcessors(); for (int i = 0; i < processors.length; i++) if (table.getCellRect(i, 5, true).contains(X, Y)) return processors[i]; return null; }
public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h) { if ((flags & (FRAMEBITS | ALLBITS)) != 0) { Rectangle rect = table.getCellRect(row, col, false); table.repaint(rect); } return (flags & (ALLBITS | ABORT)) == 0; } }
@Override public void setSelectedIndex(int index) { table.getSelectionModel().setSelectionInterval(index, index); table.scrollRectToVisible(new Rectangle(table.getCellRect(index, 0, true))); }
private static Rectangle getRectangleAt(JTable table, int x, int y) { Rectangle rect = null; try { Point point = new Point(x, y); int row = table.rowAtPoint(point); int column = table.columnAtPoint(point); rect = table.getCellRect(row, column, true); } catch (Exception e) { } return rect; }
public void scrollToVisible(final JTable table, final int rowIndex, final int vColIndex) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { table.scrollRectToVisible(table.getCellRect(rowIndex, vColIndex, false)); } }); }
private void displaySearchResult(int row, int column) { quickSearchLastRow = row; quickSearchLastColumn = column; table.getSelectionModel().setSelectionInterval(row, row); table.getColumnModel().getSelectionModel().setSelectionInterval(column, column); table.scrollRectToVisible(table.getCellRect(row, column, true)); }
public void selectPlacement(Placement placement) { for (int i = 0; i < tableModel.getRowCount(); i++) { if (tableModel.getPlacement(i) == placement) { int index = table.convertRowIndexToView(i); table.getSelectionModel().setSelectionInterval(index, index); table.scrollRectToVisible(new Rectangle(table.getCellRect(index, 0, true))); break; } } }
@Override public void pushMessage(LogMessage logMessage) { logTableModel.pushMessage(logMessage); // Scroll to bottom if nothing is selected if (!logTableModel.isPaused()) { logTable.scrollRectToVisible( logTable.getCellRect(logTableModel.getRowCount() - 1, 0, true) ); } }