本文整理汇总了Java中javax.swing.JTable.isRowSelected方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.isRowSelected方法的具体用法?Java JTable.isRowSelected怎么用?Java JTable.isRowSelected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.isRowSelected方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTableCellRendererComponent
import javax.swing.JTable; //导入方法依赖的package包/类
/**
* @see javax.swing.table.TableCellRenderer.getTableCellRendererComponent(JTable, Object, boolean, boolean, int, int)
*/
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
Icon icon = null;
String tooltipText = null;
String labelText = "";
JLabel tableCellRendererComponent = (JLabel) super.getTableCellRendererComponent(
table, value, isSelected, hasFocus, row, column);
if (value instanceof GitChangeType) {
RenderingInfo renderingInfo = getRenderingInfo((GitChangeType) value);
if (renderingInfo != null) {
icon = renderingInfo.getIcon();
tooltipText = renderingInfo.getTooltip();
}
} else if (value instanceof String) {
tooltipText = (String) value;
String fileName = tooltipText.substring(tooltipText.lastIndexOf('/') + 1);
if (!fileName.equals(tooltipText)) {
tooltipText = tooltipText.replace("/" + fileName, "");
tooltipText = fileName + " - " + tooltipText;
}
labelText = (String) value;
}
tableCellRendererComponent.setIcon(icon);
tableCellRendererComponent.setToolTipText(tooltipText);
tableCellRendererComponent.setText(labelText);
// Active/inactive table selection
if (table.isRowSelected(row)) {
if (table.hasFocus()) {
tableCellRendererComponent.setBackground(table.getSelectionBackground());
} else if (!isContextMenuShowing) {
Color defaultColor = table.getSelectionBackground();
tableCellRendererComponent.setBackground(getInactiveSelectionColor(defaultColor));
}
} else {
tableCellRendererComponent.setBackground(table.getBackground());
}
return tableCellRendererComponent;
}