本文整理汇总了Java中javax.swing.JTable.setRowSelectionAllowed方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.setRowSelectionAllowed方法的具体用法?Java JTable.setRowSelectionAllowed怎么用?Java JTable.setRowSelectionAllowed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.setRowSelectionAllowed方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: jbInit
import javax.swing.JTable; //导入方法依赖的package包/类
void jbInit() throws Exception {
setBorder(BorderList.etchedBorder5);
ActionListener actionEventHandler = new ActionEventHandler();
MouseListener mouseEventHandler = new MouseEventHandler();
addButton = new JButton("Add");
addButton.setActionCommand("Add");
addButton.addActionListener(actionEventHandler);
removeButton = new JButton("Remove");
removeButton.setActionCommand("Remove");
removeButton.addActionListener(actionEventHandler);
//by lila
JPanel p1 = new JPanel();
p1.setLayout(new FlowLayout(FlowLayout.CENTER));
p1.add(addButton);
p1.add(removeButton);
model = new MyFieldTableModel();
fieldTable = new JTable(model);
fieldTable.setRowSelectionAllowed(true);
fieldTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
fieldTable.addMouseListener(mouseEventHandler);
fieldTable.setBorder(BorderList.bebelBorder);
scrollpane = new JScrollPane(fieldTable);
scrollpane.setPreferredSize(new Dimension(550,220));
//by lila
JPanel p2 = new JPanel();
p2.setLayout(new BorderLayout(0,5));
TitledBorder border = new TitledBorder(new EtchedBorder(),"Field Table");
border.setTitleFont(FontList.regularFont);
border.setTitleColor(Color.black);
p2.setBorder(border);
p2.add(p1,BorderLayout.SOUTH);
p2.add(scrollpane,BorderLayout.CENTER);
p2.add(new JPanel(),BorderLayout.EAST);
p2.add(new JPanel(),BorderLayout.WEST);
setLayout(new FlowLayout(FlowLayout.CENTER));
add(p2);
}
示例2: show
import javax.swing.JTable; //导入方法依赖的package包/类
public void show(int dif) {
ArrayList<record> rec = new ArrayList<record>();
String content = FileHelper.readFromFile("ranking.ini");
if (content != null ) {
if(!content.equals("")) {
String[] sp = content.split(",");
for (int i = 0; i < sp.length; i = i + 3) {
if (dif == Integer.parseInt(sp[i])) {
rec.add(new record(sp[i + 2], Integer.parseInt(sp[i + 1])));
}
}
}
Collections.sort(rec);
rank = new Object[rec.size()][COL];
for (int i = 0; i < rec.size(); i++) {
record temp = rec.get(i);
rank[i][0] = i + 1;
rank[i][2] = temp.date;
rank[i][1] = temp.score;
}
table = new JTable(rank, title);
centerPanel.removeAll();
centerPanel.setLayout(new BorderLayout());
centerPanel.add(new JScrollPane(table), BorderLayout.CENTER);
DefaultTableCellRenderer r = new DefaultTableCellRenderer();
r.setHorizontalAlignment(JLabel.CENTER);
table.setDefaultRenderer(Object.class, r);
table.setRowHeight(20);
table.setFont(new Font("微软雅黑", 0, 14));
table.setGridColor(Color.BLUE);
table.setSize(centerPanel.getWidth(), centerPanel.getHeight());
table.setRowSelectionAllowed(false);
}
setVisible(true);
}
示例3: setupBasicTableProperties
import javax.swing.JTable; //导入方法依赖的package包/类
/**
* setting up the table.
*
* @param table JTable to store this.correlationTableModel
*/
private void setupBasicTableProperties(JTable table) {
table.clearSelection();
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
TableRenderer cellRenderer = new TableRenderer(new JTextField());
table.setRowSelectionAllowed(true);
table.setColumnSelectionAllowed(false);
table.setVisible(true);
table.setModel(this.variationPerParameterTableModel);
initColumnSizes(table);
for (int i = 0; i < table.getColumnCount(); i++) {
TableColumn column = table.getColumnModel().getColumn(i);
column.setCellRenderer(cellRenderer);
}
TableColumn columnName = table.getColumnModel().getColumn(VariationPerParameterTableModel.COLUMN_NAME);
columnName.setCellEditor(new TextCellEditor());
TableColumn columnBasicValue = table.getColumnModel().getColumn(VariationPerParameterTableModel.COLUMN_BASIC_VALUE);
columnBasicValue.setCellEditor(new TextCellEditor());
setupVariationFunctionComboBoxColumn();
this.variationPerParameterTableModel.fireTableDataChanged();
table.setColumnSelectionAllowed(false);
table.setRowSelectionAllowed(true);
//select first row.
table.getSelectionModel().setSelectionInterval(0, 0);
}
示例4: GraphicTable
import javax.swing.JTable; //导入方法依赖的package包/类
public GraphicTable() {
graphicTable = new JTable();
graphicTable.setEnabled(false);
graphicTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
graphicTable.setMinimumSize(graphicTable.getPreferredScrollableViewportSize());
graphicTable.setPreferredScrollableViewportSize(graphicTable.getPreferredSize());
graphicTable.setFillsViewportHeight(true);
graphicTable.getTableHeader().setReorderingAllowed(false);
graphicTable.setColumnSelectionAllowed(true);
graphicTable.setRowSelectionAllowed(true);
graphicTable.setRowSelectionAllowed(true);
//(ListSelectionModel.SINGLE_SELECTION);
}
示例5: ResultsPane
import javax.swing.JTable; //导入方法依赖的package包/类
public ResultsPane(ResultsModel inModel)
{
setLayout(new BorderLayout());
mdl = inModel;
ColorTimeRenderer large = new ColorTimeRenderer(3);
ColorTimeRenderer medium = new ColorTimeRenderer(2);
//ColorTimeRenderer small = new ColorTimeRenderer(1);
DifferenceRenderer diff = new DifferenceRenderer();
tbl = new JTable(inModel) { public void tableChanged(TableModelEvent e) { super.tableChanged(e); scrollTable(); } };
tbl.setDefaultRenderer(ColorTime.class, new ColorTimeRenderer(1));
tbl.setRowHeight(140);
tbl.setRowSelectionAllowed(false);
//tbl.setIntercellSpacing(new Dimension(8, 8));
TableColumnModel tcm = tbl.getColumnModel();
columnStyle(tcm, 0, 50, 70, 200, medium);
columnStyle(tcm, 1, 50, 70, 200, medium);
columnStyle(tcm, 2, 80, 110, 280, large);
columnStyle(tcm, 3, 180, 230, 700, diff);
columnStyle(tcm, 4, 50, 70, 200, medium);
columnStyle(tcm, 5, 50, 70, 200, medium);
columnStyle(tcm, 6, 80, 110, 280, large);
JScrollPane scroll = new JScrollPane(tbl, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
add(scroll);
}