本文整理汇总了Java中javax.swing.JTable.setSelectionBackground方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.setSelectionBackground方法的具体用法?Java JTable.setSelectionBackground怎么用?Java JTable.setSelectionBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.setSelectionBackground方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getClustDetTable
import javax.swing.JTable; //导入方法依赖的package包/类
private JTable getClustDetTable() {
tableClusters = new JTable(new clustDetModel(info.numElem, info.percent)) {
/**
*
*/
private static final long serialVersionUID = 1L;
{
setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
getColumnModel().getColumn(0).setPreferredWidth(170);
getColumnModel().getColumn(1).setPreferredWidth(110);
getColumnModel().getColumn(2).setPreferredWidth(110);
getColumnModel().getColumn(3).setPreferredWidth(55);
}
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
if (column == 3) {
return new ColorRenderer();
}
return getDefaultRenderer(String.class);
}
};
tableClusters.setSelectionBackground(new Color(83, 126, 126));
tableClusters.setSelectionForeground(Color.BLACK);
tableClusters.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
tableClusters.setFont(new Font(tableClusters.getFont().getName(), tableClusters.getFont().getStyle(), tableClusters.getFont().getSize() + 1));
tableClusters.setRowSelectionInterval(0, 0);
return tableClusters;
}
示例2: getVarsDetTable
import javax.swing.JTable; //导入方法依赖的package包/类
private JTable getVarsDetTable() {
double[] p = new double[numClust];
for (int i = 0; i < numClust; i++) {
p[i] = info.infoCluster[i].percVar[listVars.getSelectedIndex()];
}
tableVars = new JTable(new varsDetModel(p)) {
/**
*
*/
private static final long serialVersionUID = 1L;
{
setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
getColumnModel().getColumn(0).setPreferredWidth(170);
getColumnModel().getColumn(1).setPreferredWidth(100);
getColumnModel().getColumn(2).setPreferredWidth(55);
}
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
if (column == 2) {
return new ColorRenderer();
}
return getDefaultRenderer(String.class);
}
};
tableVars.setSelectionBackground(new Color(83, 126, 126));
tableVars.setSelectionForeground(Color.BLACK);
tableVars.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
tableVars.setFont(new Font(tableVars.getFont().getName(), tableVars.getFont().getStyle(), tableVars.getFont().getSize() + 1));
tableVars.setRowSelectionInterval(0, 0);
return tableVars;
}
示例3: getUpperTable
import javax.swing.JTable; //导入方法依赖的package包/类
private JScrollPane getUpperTable() {
clusteringFinalTable = new JTable(new clustDetModel(infos.numElem, infos.percent));
clusteringFinalTable.setSelectionBackground(new Color(83, 126, 126));
clusteringFinalTable.setSelectionForeground(Color.BLACK);
clusteringFinalTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
return new JScrollPane(clusteringFinalTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
}
示例4: DeviceTable
import javax.swing.JTable; //导入方法依赖的package包/类
public DeviceTable(TableModel tableModel) {
super();
panel = new JPanel();
panel.setBorder(new TitledBorder(null, "Table", TitledBorder.CENTER, TitledBorder.TOP));
panel.setLayout(new GridBagLayout());
// panel.setSize(new java.awt.Dimension(350, 100));
// panel.setPreferredSize(new java.awt.Dimension(350, 100));
table = new JTable(tableModel);
// table.setFillsViewportHeight(true);
table.setSelectionBackground(java.awt.Color.YELLOW);
initCellEditor(tableModel);
scrollPane = new JScrollPane(table);
GridBagLayout gbLayout = new GridBagLayout();
GridBagConstraints gbConst = new GridBagConstraints();
gbConst.gridx = 0; gbConst.gridy = 0;
gbLayout.setConstraints(table, gbConst);
// scrollPane.setSize(new java.awt.Dimension(400, 100));
// scrollPane.setPreferredSize(new java.awt.Dimension(400, 100));
panel.add(scrollPane);
}