當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。