本文整理匯總了Java中javax.swing.ListSelectionModel.setSelectionMode方法的典型用法代碼示例。如果您正苦於以下問題:Java ListSelectionModel.setSelectionMode方法的具體用法?Java ListSelectionModel.setSelectionMode怎麽用?Java ListSelectionModel.setSelectionMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.ListSelectionModel
的用法示例。
在下文中一共展示了ListSelectionModel.setSelectionMode方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setTo
import javax.swing.ListSelectionModel; //導入方法依賴的package包/類
public void setTo(ListSelectionModel sm) {
sm.clearSelection();
sm.setSelectionMode(selectionMode);
for (int[] itv : intervals) {
sm.addSelectionInterval(itv[0], itv[1]);
}
sm.setAnchorSelectionIndex(anchor);
sm.setLeadSelectionIndex(lead);
}
示例2: setup
import javax.swing.ListSelectionModel; //導入方法依賴的package包/類
private void setup(Class<U> protoScript, String entityDisplayName)
{
JButton add = new JButton(addAction);
JButton remove = new JButton(removeAction);
model = new MyTableModel<T, U>(cache, protoScript, entityDisplayName);
table = new JTable(model);
table.addMouseListener(new TablePopupListener(table, addAction, removeAction));
ListSelectionModel selModel = table.getSelectionModel();
selModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
selModel.addListSelectionListener(new ListSelectionListener()
{
@Override
public void valueChanged(ListSelectionEvent e)
{
removeAction.update();
}
});
TableColumn c1 = table.getColumnModel().getColumn(1);
c1.setCellRenderer(new ScriptingTableCellRenderer(model));
c1.setCellEditor(new ScriptingCellEditor(this, clientService, model));
final int height1 = add.getPreferredSize().height;
final int width1 = remove.getPreferredSize().width;
final int[] rows = {TableLayout.FILL, height1,};
final int[] cols = {TableLayout.FILL, width1, width1,};
setLayout(new TableLayout(rows, cols));
add(new JScrollPane(table), new Rectangle(0, 0, 3, 1));
add(add, new Rectangle(1, 1, 1, 1));
add(remove, new Rectangle(2, 1, 1, 1));
changeDetector = new ChangeDetector();
changeDetector.watch(model);
}
示例3: setupGUI
import javax.swing.ListSelectionModel; //導入方法依賴的package包/類
@SuppressWarnings("nls")
private void setupGUI(Node privNode, PrivilegeList accessModel)
{
JButton add = new JButton(addAction);
JButton remove = new JButton(removeAction);
JButton up = new JTextlessButton(upAction);
JButton down = new JTextlessButton(downAction);
privilegeModel = new MyTableModel(privNode, accessModel);
privilegeTable = new JTable(privilegeModel);
privilegeTable.addMouseListener(new TablePopupListener(privilegeTable, actions));
ListSelectionModel selectionModel = privilegeTable.getSelectionModel();
selectionModel.addListSelectionListener(this);
selectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
TableColumn actionColumn = privilegeTable.getColumnModel().getColumn(0);
actionColumn.setCellRenderer(new ActionTableCellRenderer());
actionColumn.setCellEditor(new ActionTableCellEditor());
TableColumn whoColumn = privilegeTable.getColumnModel().getColumn(1);
whoColumn.setCellRenderer(new ExpressionTableCellRenderer(userService));
whoColumn.setCellEditor(new WhoTableCellEditor(userService, this));
JScrollPane scroller = new JScrollPane(privilegeTable);
final int height1 = add.getPreferredSize().height;
final int width1 = remove.getPreferredSize().width;
final int[] rows = {height1, height1, height1, height1, TableLayout.FILL,};
final int[] cols = {TableLayout.FILL, width1,};
JPanel all = new JPanel(new TableLayout(rows, cols));
all.add(scroller, new Rectangle(0, 0, 1, 5));
all.add(add, new Rectangle(1, 0, 1, 1));
all.add(remove, new Rectangle(1, 1, 1, 1));
all.add(up, new Rectangle(1, 2, 1, 1));
all.add(down, new Rectangle(1, 3, 1, 1));
showOverrides = new JCheckBox(
CurrentLocale.get("com.tle.admin.security.editors.advancededitorpanel.overriding"));
showDefaults = new JCheckBox(CurrentLocale.get("com.tle.admin.security.editors.advancededitorpanel.default"));
showOverrides.addActionListener(this);
showDefaults.addActionListener(this);
final int mainHeight1 = showOverrides.getPreferredSize().height;
final int[] mainRows = {TableLayout.INVISIBLE, TableLayout.FILL, TableLayout.INVISIBLE, mainHeight1,};
final int[] mainCols = {TableLayout.FILL, TableLayout.FILL, width1,};
layout = new TableLayout(mainRows, mainCols);
setLayout(layout);
add(new JLabel(CurrentLocale.get("com.tle.admin.security.editors.advancededitorpanel.overrides")),
new Rectangle(2, 0, 1, 1));
add(all, new Rectangle(0, 1, 3, 1));
add(new JLabel(CurrentLocale.get("com.tle.admin.security.editors.advancededitorpanel.defaults")),
new Rectangle(2, 2, 1, 1));
add(showOverrides, new Rectangle(0, 3, 1, 1));
add(showDefaults, new Rectangle(1, 3, 1, 1));
updateButtons();
}