本文整理匯總了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;
}