当前位置: 首页>>代码示例>>Java>>正文


Java ListSelectionModel.addListSelectionListener方法代码示例

本文整理汇总了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);
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ClassMethodSelector.java

示例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);
    }
}
 
开发者ID:akarnokd,项目名称:RxJava2Swing,代码行数:13,代码来源:ListSelectionEventModelObservable.java

示例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);

}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:46,代码来源:InstanceConfigurer.java

示例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);
}
 
开发者ID:equella,项目名称:Equella,代码行数:42,代码来源:EntityWhereEditor.java

示例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();
}
 
开发者ID:equella,项目名称:Equella,代码行数:62,代码来源:AdvancedEditorPanel.java


注:本文中的javax.swing.ListSelectionModel.addListSelectionListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。