本文整理了Java中javax.swing.JTable.convertRowIndexToView()
方法的一些代码示例,展示了JTable.convertRowIndexToView()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTable.convertRowIndexToView()
方法的具体详情如下:
包路径:javax.swing.JTable
类名称:JTable
方法名:convertRowIndexToView
暂无
代码示例来源:origin: magefree/mage
public static int getViewRowFromModel(JTable table, int modelRow) {
if (modelRow != -1 && modelRow < table.getModel().getRowCount()) {
return table.convertRowIndexToView(modelRow);
}
return -1;
}
}
代码示例来源:origin: stackoverflow.com
comp.setBackground(row % 2 == 0 ? getBackground() : getBackground().darker());
dialogTable.convertRowIndexToView(0);
} else {
comp.setForeground(Color.blue);
代码示例来源:origin: chatty/chatty
/**
* Convert a model index to view index.
*
* @param index The index to convert
* @return The corresponding index of the view, or {@code -1} if the row
* isn't visible
*/
private int indexToView(int index) {
return table.convertRowIndexToView(index);
}
代码示例来源:origin: cpesch/RouteConverter
public static List<RouteModel> getSelectedRouteModels(JTable table) {
int[] selectedRows = table.getSelectedRows();
List<RouteModel> routeModels = new ArrayList<>();
for (int selectedRow : selectedRows) {
int row = table.convertRowIndexToView(selectedRow);
Object value = table.getModel().getValueAt(row, 1);
if (value instanceof RouteModel)
routeModels.add((RouteModel) value);
}
return routeModels;
}
代码示例来源:origin: org.nuiton.jaxx/jaxx-runtime
/**
* Select the given row index {@code rowIndex} (from the model coordinate)
* in the selection of the given table.
*
* @param table the table where to set the selection
* @param rowIndex the row index in the model coordinate to set as selection
* @since 2.5.29
*/
public static void setSelectionInterval(JTable table, int rowIndex) {
int rowViewIndex = table.convertRowIndexToView(rowIndex);
table.getSelectionModel().setSelectionInterval(rowViewIndex, rowViewIndex);
}
代码示例来源:origin: io.ultreia.java4all.jaxx/jaxx-runtime
/**
* Add the given row index {@code rowIndex} (from the model coordinate)
* in the selection of the given table.
*
* @param table the table where to set the selection
* @param rowIndex the row index in the model coordinate to add to selection
* @since 2.5.29
*/
public static void addRowSelectionInterval(JTable table, int rowIndex) {
int rowViewIndex = table.convertRowIndexToView(rowIndex);
table.getSelectionModel().addSelectionInterval(rowViewIndex, rowViewIndex);
}
代码示例来源:origin: stackoverflow.com
public class TableModelDecorator implements TableModel{
private TableModel delegate;
private JTable table;
@Override
public Object getValueAt( int rowIndex, int columnIndex ) {
return delegate.getValueAt( table.convertRowIndexToView( rowIndex ), table.convertColumnIndexToView( columnIndex ) );
}
}
代码示例来源:origin: org.nuiton.jaxx/jaxx-runtime
/**
* Add the given row index {@code rowIndex} (from the model coordinate)
* in the selection of the given table.
*
* @param table the table where to set the selection
* @param rowIndex the row index in the model coordinate to add to selection
* @since 2.5.29
*/
public static void addRowSelectionInterval(JTable table, int rowIndex) {
int rowViewIndex = table.convertRowIndexToView(rowIndex);
table.getSelectionModel().addSelectionInterval(rowViewIndex, rowViewIndex);
}
代码示例来源:origin: MegaMek/megamek
private void searchFor(String search) {
for (int i = 0; i < mechs.length; i++) {
if (mechs[i].getName().toLowerCase().startsWith(search)) {
int selected = tableUnits.convertRowIndexToView(i);
if (selected > -1) {
tableUnits.changeSelection(selected, 0, false, false);
break;
}
}
}
}
代码示例来源:origin: openpnp/openpnp
/**
* Select the last row in a table. Handy for selecting a row that was just added.
*
* @param table
*/
public static void selectLastTableRow(JTable table) {
table.clearSelection();
int index = table.getRowCount() - 1;
index = table.convertRowIndexToView(index);
table.addRowSelectionInterval(index, index);
}
代码示例来源: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: com.github.danielpacak.osgi.swingconsole/osgi.swingconsole
public void setSelectedBundle(BundleDTO bundle) {
int modelRowIndex = tableModel.getRowIndex(bundle);
if (modelRowIndex >= 0) {
int viewRowIndex = table.convertRowIndexToView(modelRowIndex);
table.setRowSelectionInterval(viewRowIndex, viewRowIndex);
}
}
代码示例来源:origin: bedatadriven/activityinfo
public void setSelection(int targetRowIndex) {
if(targetRowIndex != -1) {
int modelRow = tableModel.convertTableIndexToModel(targetRowIndex);
if (modelRow != -1) {
int viewRow = table.convertRowIndexToView(modelRow);
table.setRowSelectionInterval(viewRow, viewRow);
}
}
}
代码示例来源:origin: openpnp/openpnp
public static void selectFirstTableRow(JTable table) {
table.clearSelection();
int index = 0;
index = table.convertRowIndexToView(index);
table.addRowSelectionInterval(index, index);
}
代码示例来源: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: cpesch/RouteConverter
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting())
return;
int selectedRow = tableDownloadableMaps.getSelectedRow();
if (selectedRow == -1)
return;
int row = tableDownloadableMaps.convertRowIndexToView(selectedRow);
RemoteMap map = getMapsforgeMapManager().getDownloadableMapsModel().getItem(row);
r.showMapBorder(map.getBoundingBox());
updateLabel();
}
});
代码示例来源:origin: openpnp/openpnp
private void selectBoardLocation(BoardLocation boardLocation) {
for (int i = 0; i < boardLocationsTableModel.getRowCount(); i++) {
if (boardLocationsTableModel.getBoardLocation(i) == boardLocation) {
int index = boardLocationsTable.convertRowIndexToView(i);
boardLocationsTable.getSelectionModel().setSelectionInterval(index, index);
boardLocationsTable.scrollRectToVisible(
new Rectangle(boardLocationsTable.getCellRect(index, 0, true)));
break;
}
}
}
代码示例来源: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: cpesch/RouteConverter
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting())
return;
int selectedRow = tableAvailableOnlineMaps.getSelectedRow();
if (selectedRow == -1)
return;
int row = tableAvailableOnlineMaps.convertRowIndexToView(selectedRow);
LocalMap map = getMapsforgeMapManager().getAvailableOnlineMapsModel().getItem(row);
r.showMapBorder(map.isVector() ? map.getBoundingBox() : null);
}
});
代码示例来源:origin: aterai/java-swing-tips
@Override public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) {
if (!table.isShowing()) {
return false; // @see javax.swing.JLabel#imageUpdate(...)
}
if ((infoflags & (FRAMEBITS | ALLBITS)) != 0) { // @see java.awt.Component#imageUpdate(...)
int vr = table.convertRowIndexToView(row); // JDK 1.6.0
int vc = table.convertColumnIndexToView(col);
table.repaint(table.getCellRect(vr, vc, false));
}
return (infoflags & (ALLBITS | ABORT)) == 0;
}
});
内容来源于网络,如有侵权,请联系作者删除!