本文整理了Java中javax.swing.JTable.scrollRectToVisible()
方法的一些代码示例,展示了JTable.scrollRectToVisible()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTable.scrollRectToVisible()
方法的具体详情如下:
包路径:javax.swing.JTable
类名称:JTable
方法名:scrollRectToVisible
暂无
代码示例来源:origin: 4thline/cling
@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)
);
}
}
代码示例来源:origin: stackoverflow.com
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);
}
代码示例来源:origin: marytts/marytts
int column = 1; // jTable_PromptSet.getSelectedColumn();
Rectangle cellRect = jTable_PromptSet.getCellRect(row + 4, column, false);
jTable_PromptSet.scrollRectToVisible(cellRect);
jTable_PromptSet.updateUI();
} catch (Exception ex) {
代码示例来源:origin: stackoverflow.com
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);
代码示例来源:origin: stackoverflow.com
private JTable _table = new JTable();
...
_table.addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
_table.scrollRectToVisible(_table.getCellRect(_table.getRowCount()-1, 0, true));
}
});
代码示例来源:origin: Nilhcem/FakeSMTP
public void componentResized(ComponentEvent e) {
table.scrollRectToVisible(new Rectangle(table.getCellRect(nbElements, 0, true)));
}
});
代码示例来源:origin: com.anrisoftware.prefdialog/prefdialog-misc-swing
@Override
public void setSelectedIndex(int index) {
table.getSelectionModel().setSelectionInterval(index, index);
table.scrollRectToVisible(new Rectangle(table.getCellRect(index, 0,
true)));
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mercurial
private void setSelectedIndex(int currentIndex) {
if (currentIndex == table.getSelectedRow()) return;
table.getSelectionModel().setSelectionInterval(currentIndex, currentIndex);
table.scrollRectToVisible(table.getCellRect(currentIndex, 0, true));
}
代码示例来源:origin: caprica/vlcj-player
private void addMessage(String message) {
int bra = message.indexOf('[');
int ket = message.indexOf(']');
if (bra != -1 && ket != -1) {
message = message.substring(bra+1, ket);
}
eventList.add(new DebugMessage(message));
int lastRow = table.convertRowIndexToView(table.getModel().getRowCount()-1);
table.scrollRectToVisible(table.getCellRect(lastRow, 0, true));
}
代码示例来源:origin: stackoverflow.com
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));
}
});
}
代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij
/** finds if project list contains the project with given name, selects and scrolls to it. */
@VisibleForTesting
void showProjectInList(String projectName) {
for (int i = 0; i < projectListTableModel.getRowCount(); i++) {
String projectNameAtRow = projectListTableModel.getProjectNameAtRow(i);
if (projectNameAtRow.equals(projectName)) {
projectListTable.getSelectionModel().setSelectionInterval(i, i);
projectListTable.scrollRectToVisible(projectListTable.getCellRect(i, 0, true));
break;
}
}
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
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));
}
代码示例来源:origin: protegeproject/protege
public void moveSelectionDown() {
int size = model.getRowCount();
if (size == 0) {
return;
}
int selectedIndex = resultsTable.getSelectionModel().getLeadSelectionIndex();
int nextSelIndex = selectedIndex + 1;
if (nextSelIndex == size) {
nextSelIndex = 0;
}
resultsTable.getSelectionModel().setSelectionInterval(nextSelIndex, nextSelIndex);
resultsTable.scrollRectToVisible(resultsTable.getCellRect(nextSelIndex, 0, true));
}
代码示例来源:origin: caprica/vlcj-player
@Override
public void run() {
eventList.add(new NativeLogMessage(module, name, level, message));
int lastRow = table.convertRowIndexToView(table.getModel().getRowCount()-1);
table.scrollRectToVisible(table.getCellRect(lastRow, 0, true));
}
});
代码示例来源:origin: openpnp/openpnp
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;
}
}
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
public void actionAdd() {
final int n = model_.getRowCount();
if (model_.actionAdd()) {
table_.getSelectionModel().setSelectionInterval(n, n);
table_.scrollRectToVisible(table_.getCellRect(n, 0, true));
}
}
代码示例来源:origin: joel-costigliola/assertj-swing
@RunsInEDT
@Nonnull private static Point pointAtName(final @Nonnull JTableHeader tableHeader,
final @Nonnull TextMatcher matcher,
final @Nonnull JTableHeaderLocation location) {
Point result = execute(() -> {
Pair<Integer, Point> indexAndLocation = location.pointAt(tableHeader, matcher);
checkEnabledAndShowing(tableHeader);
tableHeader.getTable().scrollRectToVisible(tableHeader.getHeaderRect(indexAndLocation.first));
return indexAndLocation.second;
});
return checkNotNull(result);
}
代码示例来源:origin: org.fourthline.cling/cling-support
@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)
);
}
}
代码示例来源:origin: org.seamless/seamless-swing
public void run() {
logTableModel.pushMessage(message);
// Scroll to bottom if nothing is selected
if (!logTableModel.isPaused()) {
logTable.scrollRectToVisible(
logTable.getCellRect(logTableModel.getRowCount() - 1, 0, true)
);
}
}
});
代码示例来源:origin: otros-systems/otroslogviewer
public void adjustmentValueChanged(AdjustmentEvent e) {
if (e.getSource() == umlModel.getScrollPane().getVerticalScrollBar()) {
JScrollBar bar = (JScrollBar) e.getSource();
int row = logUmlMapper.getLogId(bar.getValue());
Rectangle r = table.getCellRect(row, 0, true);
table.scrollRectToVisible(r);
} else if (e.getSource() == table) {
}
}
内容来源于网络,如有侵权,请联系作者删除!