本文整理汇总了Java中javax.swing.ListSelectionModel.addListSelectionListener方法的典型用法代码示例。如果您正苦于以下问题:Java ListSelectionModel.addListSelectionListener方法的具体用法?Java ListSelectionModel.addListSelectionListener怎么用?Java ListSelectionModel.addListSelectionListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.ListSelectionModel
的用法示例。
在下文中一共展示了ListSelectionModel.addListSelectionListener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSelectionModel
import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
public void setSelectionModel(final ListSelectionModel selection) {
this.selection = selection;
selection.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
int index = selection.getMinSelectionIndex();
selected = index == -1 ? null : getElementAt(index);
}
}
});
}
示例2: subscribeActual
import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
@Override
protected void subscribeActual(Observer<? super ListSelectionEvent> observer) {
ListSelectionModel w = widget;
ListSelectionEventConsumer aec = new ListSelectionEventConsumer(observer, w);
observer.onSubscribe(aec);
w.addListSelectionListener(aec);
if (aec.get() == null) {
aec.onDispose(w);
}
}
示例3: SymbolPanel
import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
public SymbolPanel() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
mainPanel = new JPanel();
mainPanel.setBorder(BorderFactory.createLineBorder(Color.black));
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
Box box = Box.createHorizontalBox();
box.add(new JLabel("Items"));
mainPanel.add(box);
model = new SymbolTableModel();
table = new JTable(model);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
if (getValueList() != null && getValueList().size() > 0) {
table.getSelectionModel().setSelectionInterval(0, 0);
}
ListSelectionModel rowSM = table.getSelectionModel();
rowSM.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) return;
ListSelectionModel lsm = (ListSelectionModel) e.getSource();
if (lsm.isSelectionEmpty()) {
showItem(NO_CURRENT_ITEM);
}
else {
int selectedRow = lsm.getMinSelectionIndex();
showItem(selectedRow);
}
}
});
scrollPane = new ScrollPane(table);
table.setPreferredScrollableViewportSize(new Dimension(300, 100));
mainPanel.add(scrollPane);
detailPanel = new JPanel();
mainPanel.add(new ScrollPane(detailPanel));
add(mainPanel);
showItem(0);
}
示例4: 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);
}
示例5: 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();
}