本文整理汇总了Java中javax.swing.JTable.setColumnSelectionAllowed方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.setColumnSelectionAllowed方法的具体用法?Java JTable.setColumnSelectionAllowed怎么用?Java JTable.setColumnSelectionAllowed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.setColumnSelectionAllowed方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addMouseListenerToHeaderInTable
import javax.swing.JTable; //导入方法依赖的package包/类
public void addMouseListenerToHeaderInTable(JTable table) {
final TableSorter sorter = this;
final JTable tableView = table;
tableView.setColumnSelectionAllowed(false);
MouseAdapter listMouseListener = new MouseAdapter() {
boolean ascending = false;
public void mouseClicked(MouseEvent e) {
TableColumnModel columnModel = tableView.getColumnModel();
int viewColumn = columnModel.getColumnIndexAtX(e.getX());
int column = tableView.convertColumnIndexToModel(viewColumn);
if (e.getClickCount() == 1 && column != -1) {
//System.out.println("Sorting ...");
//int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK;
//boolean ascending = (shiftPressed == 0);
if (column == sortBy)
ascending = !ascending;
else
ascending = true;
sorter.sortByColumn(column, ascending);
tableView.getTableHeader().updateUI();
}
}
};
JTableHeader th = tableView.getTableHeader();
th.addMouseListener(listMouseListener);
}
示例2: init
import javax.swing.JTable; //导入方法依赖的package包/类
private void init() {
this.setLayout(new BorderLayout());
tableListTable = new JTable(this.tableModel);
tableListTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
tableListTable.setFillsViewportHeight(false);
tableListTable.setDragEnabled(false);
tableListTable.setColumnSelectionAllowed(false);
tableListTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
// //
// // Set the column widths
// //
// tableListTable.getColumnModel().getColumn(0).setPreferredWidth(40);
// tableListTable.getColumnModel().getColumn(1).setPreferredWidth(20);
// tableListTable.getColumnModel().getColumn(3).setPreferredWidth(40);
JScrollPane scrollPane = new JScrollPane(tableListTable);
//scrollPane.setPreferredSize(new Dimension(DesignerVisualization.WINDOW_WIDTH, 175));
//scrollPane.setMaximumSize(this.columnSetTable.getPreferredScrollableViewportSize());
this.add(scrollPane, BorderLayout.CENTER);
}
示例3: addMouseListenerToHeaderInTable
import javax.swing.JTable; //导入方法依赖的package包/类
public void addMouseListenerToHeaderInTable(JTable table) {
final TableSorter sorter = this;
final JTable tableView = table;
tableView.setColumnSelectionAllowed(false);
MouseAdapter listMouseListener = new MouseAdapter() {
boolean ascending = false;
public void mouseClicked(MouseEvent e) {
TableColumnModel columnModel = tableView.getColumnModel();
int viewColumn = columnModel.getColumnIndexAtX(e.getX());
int column = tableView.convertColumnIndexToModel(viewColumn);
if (e.getClickCount() == 1 && column != -1) {
//Util.debug("Sorting ...");
//int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK;
//boolean ascending = (shiftPressed == 0);
if (column == sortBy)
ascending = !ascending;
else
ascending = true;
sorter.sortByColumn(column, ascending);
tableView.getTableHeader().updateUI();
}
}
};
JTableHeader th = tableView.getTableHeader();
th.addMouseListener(listMouseListener);
}
示例4: addMouseListenerToHeaderInTable
import javax.swing.JTable; //导入方法依赖的package包/类
public void addMouseListenerToHeaderInTable(JTable table) {
final TableSorter sorter = this;
final JTable tableView = table;
tableView.setColumnSelectionAllowed(false);
MouseAdapter listMouseListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
TableColumnModel columnModel = tableView.getColumnModel();
int viewColumn = columnModel.getColumnIndexAtX(e.getX());
int column = tableView.convertColumnIndexToModel(viewColumn);
if (e.getClickCount() == 1 && column != -1) {
System.out.println("Sorting ...");
int shiftPressed = e.getModifiers() & InputEvent.SHIFT_MASK;
boolean ascending = (shiftPressed == 0);
sorter.sortByColumn(column, ascending);
}
}
};
JTableHeader th = tableView.getTableHeader();
th.addMouseListener(listMouseListener);
}
示例5: 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);
}
示例6: 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);
}