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