类javax.swing.event.ListSelectionListener源码实例Demo

下面列出了怎么用javax.swing.event.ListSelectionListener的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: netbeans   文件: ExitDialog.java
/** Constructs rest of dialog.
*/
private void draw () {
    list = new JList(listModel);
    list.setBorder(new EmptyBorder(2, 2, 2, 2));
    list.addListSelectionListener (new ListSelectionListener () {
        @Override
                                       public void valueChanged (ListSelectionEvent evt) {
                                           updateSaveButton ();
                                       }
                                   }
                                  );
    // bugfix 37941, select first item in list
    if (!listModel.isEmpty ()) {
        list.setSelectedIndex (0);
    } else {                              
        updateSaveButton ();
    }
    JScrollPane scroll = new JScrollPane (list);
    scroll.setBorder (new CompoundBorder (new EmptyBorder (12, 12, 11, 0), scroll.getBorder ()));
    add(scroll, BorderLayout.CENTER);
    list.setCellRenderer(new ExitDlgListCellRenderer());
    list.getAccessibleContext().setAccessibleName((NbBundle.getBundle(ExitDialog.class)).getString("ACSN_ListOfChangedFiles"));
    list.getAccessibleContext().setAccessibleDescription((NbBundle.getBundle(ExitDialog.class)).getString("ACSD_ListOfChangedFiles"));
    this.getAccessibleContext().setAccessibleDescription((NbBundle.getBundle(ExitDialog.class)).getString("ACSD_ExitDialog"));
}
 
源代码2 项目: netbeans   文件: ToDoCustomizer.java
/** Creates new form ToDoCustomizer */
public ToDoCustomizer() {
    initComponents();
    lblError.setVisible(false);
    table.getSelectionModel().setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
    table.getSelectionModel().addListSelectionListener( new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            enableButtons();
        }
    });
    table.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if ("tableCellEditor".equals(evt.getPropertyName())) { //NOI18N
                if (!table.isEditing()) { //  A cell has stopped editing
                    fireChanged();
                    firePropertyChange(OptionsPanelController.PROP_CHANGED, new Boolean(changed), Boolean.TRUE);
                    firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
                }
            }
        }
    });
    jScrollPane1.getViewport().setOpaque( false );
    enableButtons();
}
 
源代码3 项目: openAGV   文件: TextListInputPanel.java
/** 
 * Creates a new instance TextListInputPanel.
 * @param title the title of the panel
 */
private TextListInputPanel(String title) {
  super(title);
  resetable = false;
  initComponents();
  list.addListSelectionListener(new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent e) {
      if (!e.getValueIsAdjusting()) {
        Object selection = list.getSelectedValue();
        if (selection != null) {
          inputField.setText((String) selection);
        }
      }
    }
  });
}
 
源代码4 项目: Cafebabe   文件: InstructionList.java
public InstructionList(ClassNode cn, MethodNode mn) {
	this.mn = mn;
	this.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 13));
	this.setFocusable(false);
	this.refresh(mn);
	this.addListSelectionListener(new ListSelectionListener() {

		@Override
		public void valueChanged(ListSelectionEvent arg0) {
			InstructionNode in = getSelectedValue();
			if (!arg0.getValueIsAdjusting() && in != null) {
				Cafebabe.gui.smallEditorPanel.setViewportView(new InstructionEditorPanel(InstructionList.this, cn, mn, in.ain));
			}
		}
	});
	this.addMouseListener(new MouseAdapter() {
		@Override
		public void mousePressed(MouseEvent e) {
			if (SwingUtilities.isRightMouseButton(e)) {
				showPopupMenu();
			}
		}
	});
}
 
源代码5 项目: arcusplatform   文件: RulesViewBuilder.java
protected Component createContents() {
   Table<RuleModel> ruleTable = null; //new RuleTableBuilder(rules).build();
   ruleTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   ruleTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
      @Override
      public void valueChanged(ListSelectionEvent e) {
         if(e.getValueIsAdjusting()) {
            return;
         }
         int index = ruleTable.getSelectionModel().getMinSelectionIndex();
         // TODO this should probably go through the controller
         if(index == -1) {
            toolbar.clearModel();
         }
         else {
            RuleModel model = ruleTable.getModel().getValue(index);
            toolbar.setModel(model);
         }
      }
   });
   return new JScrollPane(ruleTable);
}
 
private Component createListPanel() {
    model = new DefaultListModel();
    list = new JList(model);

    list.setCellRenderer(new FilterRenderer());

    list.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                enableAppropriately();
            }
        }
    });

    return new JScrollPane(list);
}
 
private Component createListPanel() {
    model = new DefaultListModel();
    list = new JList(model);

    list.setCellRenderer(new FilterRenderer());

    list.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                enableAppropriately();
            }
        }
    });

    return new JScrollPane(list);
}
 
public PersistenceClientEntitySelectionVisual(String name, 
        WizardDescriptor wizard , boolean requireReferencedClasses ) 
{
    setName(name);
    initComponents();
    ListSelectionListener selectionListener = new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            updateButtons();
        }
    };
    listAvailable.getSelectionModel().addListSelectionListener(selectionListener);
    listSelected.getSelectionModel().addListSelectionListener(selectionListener);
    disableNoIdSelection = wizard.getProperty(PersistenceClientEntitySelection.DISABLENOIDSELECTION) == Boolean.TRUE;
    if ( requireReferencedClasses ){
        cbAddRelated.setSelected( true );
        cbAddRelated.setVisible( false );
    }
}
 
源代码9 项目: netbeans   文件: GlobalOptionsPanel.java
/** Creates new form GlobalOptionsPanel */
public GlobalOptionsPanel() {
    initComponents();
    DefaultListModel dlm = new DefaultListModel();
    descMap = new HashMap<String, String>();
    int i = 0;
    String[] desc = SettingsPanel.getAvailableOptionsDescriptions();
    for (String s : SettingsPanel.AVAILABLE_OPTIONS) {
        dlm.addElement(s);
        descMap.put(s, desc[i]);
        i = i + 1;
    }
    jList1.setModel(dlm);
    jList1.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            String val = (String) jList1.getSelectedValue();
            if (val != null) {
                jTextArea1.setText(descMap.get(val));
            } else {
                jTextArea1.setText("");
            }
        }
    });
}
 
源代码10 项目: netbeans   文件: Outline.java
private void init() {
    initialized = true;
    setDefaultRenderer(Object.class, new DefaultOutlineCellRenderer());
    ActionMap am = getActionMap();
    //make rows expandable with left/rigt arrow keys
    Action a = am.get("selectNextColumn"); //NOI18N
    am.put("selectNextColumn", new ExpandAction(true, a)); //NOI18N
    a = am.get("selectPreviousColumn"); //NOI18N
    am.put("selectPreviousColumn", new ExpandAction(false, a)); //NOI18N
    getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (getSelectedRowCount() == 1) {
                selectedRow = getSelectedRow();
            } else {
                selectedRow = -1;
            }
        }
    });
}
 
源代码11 项目: netbeans   文件: SiteTemplateWizard.java
private void initListeners() {
    // radios
    ItemListener defaultItemListener = new DefaultItemListener();
    noTemplateRadioButton.addItemListener(defaultItemListener);
    archiveTemplateRadioButton.addItemListener(defaultItemListener);
    onlineTemplateRadioButton.addItemListener(defaultItemListener);
    // online templates
    onlineTemplateList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            setSiteTemplate(getSelectedOnlineTemplate());
            fireChange();
            updateOnlineTemplateDescription();
        }
    });
}
 
源代码12 项目: netbeans   文件: SuiteCustomizerSources.java
/**
 * Creates new form SuiteCustomizerSources
 */
SuiteCustomizerSources(final SuiteProperties suiteProps, ProjectCustomizer.Category cat) {
    super(suiteProps, SuiteCustomizerSources.class, cat);
    initComponents();
    initAccesibility();
    prjFolderValue.setText(suiteProps.getProjectDirectory());
    refresh();
    moduleList.setCellRenderer(CustomizerComponentFactory.getModuleCellRenderer());
    moduleList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(javax.swing.event.ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                updateEnabled();
            } 
        }
    });
}
 
源代码13 项目: netbeans   文件: DiffColorsPanel.java
public DiffColorsPanel() {
    initComponents ();

    setName(loc("LBL_DiffOptions_Tab")); //NOI18N
    
    lCategories.setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
    lCategories.setVisibleRowCount (6);
    lCategories.addListSelectionListener (new ListSelectionListener() {
        public void valueChanged (ListSelectionEvent e) {
            if (!listen) return;
            refreshUI ();
        }
    });
    lCategories.setCellRenderer (new CategoryRenderer());
    cbBackground.addActionListener (this);
    btnResetToDefaults.addActionListener(this);
}
 
源代码14 项目: netbeans   文件: OptionsPanel.java
/** Creates new form OptionsPanel */
public OptionsPanel(Object[] columnNames, List<WsimportOption> options, List<String> reservedOptions, WsimportOptions wsimportOptions) {
    initComponents();
    this.reservedOptions = reservedOptions;
    this.columnNames = columnNames;
    this.options = options;
    this.wsimportOptions = wsimportOptions;
    optionsTableModel = new OptionsTableModel(columnNames, options);
    optionsTable.setModel(optionsTableModel);
    optionsTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); // NOI18N
    ListSelectionListener listSelectionListener = new ListSelectionListenerImpl();
    optionsTable.getSelectionModel().addListSelectionListener(listSelectionListener);
    optionsTable.getColumnModel().getSelectionModel().addListSelectionListener(listSelectionListener);
    addListener = new AddButtonActionListener();
    ActionListener al = (ActionListener) WeakListeners.create(ActionListener.class, addListener,
            addBtn);
    addBtn.addActionListener(al);
    removeListener = new RemoveButtonActionListener();
    ActionListener rl = (ActionListener) WeakListeners.create(ActionListener.class, removeListener,
            removeBtn);
    removeBtn.addActionListener(rl);
    removeBtn.setEnabled(false);

}
 
源代码15 项目: netbeans   文件: SyncPanel.java
private void initTableSelections() {
    itemTable.setColumnSelectionAllowed(false);
    itemTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent event) {
            if (event.getValueIsAdjusting()) {
                return;
            }
            if (selectionIsAdjusting) {
                return;
            }
            updateSyncInfo();
            setEnabledOperationButtons();
            setEnabledDiffButton();
        }
    });
}
 
源代码16 项目: netcdf-java   文件: GridTable.java
public GridTable(String actionName) {
  // the main delegate
  table = new JTableSorted(colName, list);

  // event management
  actionSource = new ActionSourceListener(actionName) {
    public void actionPerformed(ActionValueEvent e) {
      if (list == null)
        return;
      String want = e.getValue().toString();
      int count = 0;
      for (Row row : list) {
        if (want.equals(row.gg.getFullName())) {
          eventOK = false;
          table.setSelected(count);
          eventOK = true;
          break;
        }
        count++;
      }
    }
  };

  // send event when selected row changes
  table.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      if (eventOK && !e.getValueIsAdjusting()) {
        // new variable is selected
        Row row = (Row) table.getSelected();
        if (row != null) {
          if (debug)
            System.out.println(" GridTable new gg = " + row.gg.getFullName());
          actionSource.fireActionValueEvent(ActionSourceListener.SELECTED, row.gg.getFullName());
        }
      }
    }
  });
}
 
源代码17 项目: netbeans   文件: PropertyEditorPanel.java
public PropertyEditorPanel(Properties initalValue, boolean editable) {
    initComponents();
    this.value = initalValue;
    this.editable = editable;
    propertyTable.putClientProperty(
            "terminateEditOnFocusLost", Boolean.TRUE);              //NOI18N
    updateTableFromEditor();
    final TableModel tm = propertyTable.getModel();
    tm.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent tme) {
            synchronized (PropertyEditorPanel.this) {
                if (updateing) {
                    return;
                }
                updateing = true;
                Properties p = new Properties();
                for (int i = 0; i < tm.getRowCount(); i++) {
                    p.setProperty((String) tm.getValueAt(i, 0), (String) tm.getValueAt(i, 1));
                }
                Properties oldValue = value;
                value = p;
                firePropertyChange(PROP_VALUE, oldValue, value);
                updateing = false;
            }
        }
    });
    propertyTable.getSelectionModel().addListSelectionListener(
            new ListSelectionListener() {
                @Override
                public void valueChanged(ListSelectionEvent lse) {
                    updateRemoveButtonSensible();
                }
            });
    updateAddButtonSensible();
    updateRemoveButtonSensible();
}
 
源代码18 项目: openAGV   文件: AttributesTable.java
/**
 * Konfiguriert das Erscheinungsbild der Tabelle.
 */
protected final void setStyle() {
  setRowHeight(20);
  setCellSelectionEnabled(false);
  getTableHeader().setReorderingAllowed(false);
  setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

  ListSelectionModel model = getSelectionModel();
  model.addListSelectionListener(new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent e) {
      if (e.getValueIsAdjusting()) {
        return;
      }

      ListSelectionModel l = (ListSelectionModel) e.getSource();

      if (l.isSelectionEmpty()) {
        fireSelectionChanged(null);
      }
      else {
        int selectedRow = l.getMinSelectionIndex();
        fireSelectionChanged(getModel().getValueAt(selectedRow, 1));
      }
    }
  });
}
 
源代码19 项目: MogwaiERDesignerNG   文件: ModelCheckEditor.java
public ModelCheckEditor(Component aParent, Model aModel) {
    super(aParent, ERDesignerBundle.MODELCHECKRESULT);

    model = aModel;

    initialize();

    view.getCloseButton().setAction(closeAction);
    view.getQuickFixButton().setAction(quickFixAction);

    quickFixAction.setEnabled(false);

    ModelChecker theChecker = new ModelChecker();
    theChecker.check(model);

    DefaultListModel theModel = view.getErrorList().getModel();
    theChecker.getErrors().forEach(theModel::add);
    view.getErrorList().setCellRenderer(new ErrorRenderer());
    view.getErrorList().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    view.getErrorList().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            List<Object> theSelection = view.getErrorList().getSelectedValuesList();
            quickFixAction
                    .setEnabled(theSelection != null && theSelection.size() > 0);
        }
    });

}
 
源代码20 项目: NBANDROID-V2   文件: DeviceUiChooser.java
private void setupDevicesTable() {
    DefaultTableModel tableModel = (DefaultTableModel) devicesTable.getModel();
    tableModel.setRowCount(0);
    for (IDevice device : devices) {
        String name;
        String target;
        if (device.isEmulator()) {
            name = device.getAvdName();
            AvdInfo info = avdManager.getAvd(device.getAvdName(), true /*validAvdOnly*/);
            target = info == null ? "?" : device.getAvdName();
        } else {
            name = "N/A";
            String deviceBuild = device.getProperty(IDevice.PROP_BUILD_VERSION);
            target = deviceBuild == null ? "unknown" : deviceBuild;
        }
        String state;
        if (DeviceState.BOOTLOADER.equals(device.getState())) {
            state = "bootloader";
        } else if (DeviceState.OFFLINE.equals(device.getState())) {
            state = "offline";
        } else if (DeviceState.ONLINE.equals(device.getState())) {
            state = "online";
        } else {
            state = "unknown";
        }

        tableModel.addRow(new Object[]{
            // TODO nulls?
            device.getSerialNumber(), name, target,
            Boolean.valueOf("1".equals(device.getProperty(IDevice.PROP_DEBUGGABLE))),
            state
        });
    }
    devicesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            DeviceUiChooser.this.updateState();
        }
    });
}
 
源代码21 项目: MogwaiERDesignerNG   文件: DomainEditor.java
public DomainEditor(Model aModel, Component aParent) {
    super(aParent, ERDesignerBundle.DOMAINEDITOR);
    initialize();

    DefaultComboBoxModel theDataTypes = editingView.getDataTypesModel();
    for (DataType theType : aModel.getDomainDataTypes()) {
        theDataTypes.addElement(theType);
    }

    DomainTableModel theModel = editingView.getDomainTableModel();
    for (Domain theDomain : aModel.getDomains()) {
        theModel.add(theDomain.clone());
    }

    model = aModel;
    domainEditor = new ModelItemNameCellEditor<>(model.getDialect());
    editingView.getDomainTable().getColumnModel().getColumn(0).setCellRenderer(ModelItemDefaultCellRenderer.getInstance());
    editingView.getDomainTable().getColumnModel().getColumn(0).setCellEditor(domainEditor);
    editingView.getDomainTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            updateDomainEditFields();
        }
    });

    updateDomainEditFields();

    UIInitializer.getInstance().initialize(this);
}
 
源代码22 项目: netbeans   文件: CompletionScrollPane.java
public CompletionScrollPane(JTextComponent editorComponent,
ListSelectionListener listSelectionListener, MouseListener mouseListener) {
    
    setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER);
    setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_AS_NEEDED);
    
    // Use maximumSize property to store the limit of the preferred size
    setMaximumSize(CompletionSettings.getInstance(editorComponent).completionPaneMaximumSize());
    // At least 2 items; do -1 for title height
    int maxVisibleRowCount = Math.max(2,
        getMaximumSize().height / CompletionLayout.COMPLETION_ITEM_HEIGHT - 1);

    // Add the completion view
    view = new CompletionJList(maxVisibleRowCount, mouseListener, editorComponent);

    // Apply selection colors as CompletionJList selecion also means focused
    Color selBg = UIManager.getColor("nb.completion.selectedBackground"); //NOI18N
    if (selBg != null) {
        view.setSelectionBackground(selBg);
    }
    Color selFg = UIManager.getColor("nb.completion.selectedForeground"); //NOI18N
    if (selFg != null) {
        view.setSelectionForeground(selFg);
    }

    if (listSelectionListener != null) {
        view.addListSelectionListener(listSelectionListener);
    }
    setViewportView(view);
    installKeybindings(editorComponent);
}
 
源代码23 项目: ghidra   文件: ListPanel.java
/**
 * Sets the listener to be notified when the selection changes.
 * @param listener the Listener to be notified.  If listener can be null, which
 * means no one is to be notified.
 */
public void setListSelectionListener(ListSelectionListener listener) {
	if (listSelectionListener != null)
		list.removeListSelectionListener(listSelectionListener);
	if (listener != null)
		list.addListSelectionListener(listener);
	listSelectionListener = listener;
}
 
void registerListeners() {
    tableModel.addTableModelListener(this);
    tableMultiProperties.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent lse) {
            if (!lse.getValueIsAdjusting()) {
                updateRemoveButton();
            }
        }
    });
    cellEditor.registerCellEditorListener();
}
 
源代码25 项目: arcusplatform   文件: SearchingPage.java
private Component createPairingQueue() {
	TableModel<PairingDeviceModel> model =
		TableModelBuilder
			.builder(ServiceLocator.getInstance(PairingDeviceController.class).getStore())
			.columnBuilder()
				.withName("Product")
				.withGetter(PairingDeviceModel::getProductAddress)
				.add()
			.columnBuilder()
				.withName("Pairing State")
				.withGetter(PairingDeviceModel::getPairingState)
				.add()
			.columnBuilder()
				.withName("Pairing Phase")
				.withGetter(PairingDeviceModel::getPairingPhase)
				.add()
			.build();
	Table<PairingDeviceModel> table = new Table<>(model);
	table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
		@Override
		public void valueChanged(ListSelectionEvent e) {
			if(e.getValueIsAdjusting()) {
				return;
			}
			int selected = table.getSelectedRow();
			if(selected == -1) {
				selectionModel.clearSelection();
			}
			else {
				selectionModel.setSelection(table.getModel().getValue(selected));
			}
		}
	});
	return new JScrollPane(table);
}
 
源代码26 项目: netbeans   文件: AnnotationsPanel.java
/** Creates new form AnnotationsPanel1 */
   public AnnotationsPanel() {
       initComponents();

       setName(loc("Annotations_tab")); //NOI18N
       
       // 1) init components
       cbForeground.getAccessibleContext ().setAccessibleName (loc ("AN_Foreground_Chooser"));
       cbForeground.getAccessibleContext ().setAccessibleDescription (loc ("AD_Foreground_Chooser"));
       cbBackground.getAccessibleContext ().setAccessibleName (loc ("AN_Background_Chooser"));
       cbBackground.getAccessibleContext ().setAccessibleDescription (loc ("AD_Background_Chooser"));
       cbEffectColor.getAccessibleContext ().setAccessibleName (loc ("AN_Wave_Underlined"));
       cbEffectColor.getAccessibleContext ().setAccessibleDescription (loc ("AD_Wave_Underlined"));
       lCategories.getAccessibleContext ().setAccessibleName (loc ("AN_Categories"));
       lCategories.getAccessibleContext ().setAccessibleDescription (loc ("AD_Categories"));
       lCategories.setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
       lCategories.setVisibleRowCount (3);
       lCategories.addListSelectionListener (new ListSelectionListener () {
           public void valueChanged (ListSelectionEvent e) {
               if (!listen) return;
               refreshUI ();
           }
       });
lCategories.setCellRenderer (new CategoryRenderer ());
       cbForeground.addItemListener(this);
       cbBackground.addItemListener(this);
       cbEffectColor.addItemListener(this);
       
       lCategory.setLabelFor (lCategories);
       loc(lCategory, "CTL_Category");
       loc(lForeground, "CTL_Foreground_label");
       loc(lEffectColor, "CTL_Effects_color");
       loc(lbackground, "CTL_Background_label");
       
       cbEffects.addItem (loc ("CTL_Effects_None"));
       cbEffects.addItem (loc ("CTL_Effects_Wave_Underlined"));
       cbEffects.getAccessibleContext ().setAccessibleName (loc ("AN_Effects"));
       cbEffects.getAccessibleContext ().setAccessibleDescription (loc ("AD_Effects"));
       cbEffects.addActionListener (this);
   }
 
源代码27 项目: jdk8u60   文件: bug7027139.java
public static void main(String[] args) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            JTable orderTable = new JTable(new String[][]{
                    {"Item 1 1", "Item 1 2"},
                    {"Item 2 1", "Item 2 2"},
                    {"Item 3 1", "Item 3 2"},
                    {"Item 4 1", "Item 4 2"},
            },
                    new String[]{"Col 1", "Col 2"});

            ListSelectionModel selectionModel = orderTable.getSelectionModel();
            selectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            selectionModel.addListSelectionListener(new ListSelectionListener() {
                public void valueChanged(ListSelectionEvent e) {
                    if (e.getValueIsAdjusting()) {
                        return;
                    }

                    if (e.getFirstIndex() < 0) {
                        throw new RuntimeException("Test bug7027139 failed");
                    }
                }
            });

            orderTable.selectAll();
        }
    });

    System.out.println("Test bug7027139 passed");
}
 
源代码28 项目: openjdk-jdk8u   文件: bug7027139.java
public static void main(String[] args) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            JTable orderTable = new JTable(new String[][]{
                    {"Item 1 1", "Item 1 2"},
                    {"Item 2 1", "Item 2 2"},
                    {"Item 3 1", "Item 3 2"},
                    {"Item 4 1", "Item 4 2"},
            },
                    new String[]{"Col 1", "Col 2"});

            ListSelectionModel selectionModel = orderTable.getSelectionModel();
            selectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            selectionModel.addListSelectionListener(new ListSelectionListener() {
                public void valueChanged(ListSelectionEvent e) {
                    if (e.getValueIsAdjusting()) {
                        return;
                    }

                    if (e.getFirstIndex() < 0) {
                        throw new RuntimeException("Test bug7027139 failed");
                    }
                }
            });

            orderTable.selectAll();
        }
    });

    System.out.println("Test bug7027139 passed");
}
 
源代码29 项目: netbeans   文件: TreeNodeFilterCustomEditor.java
/**
     */
    private void ownInitComponents () {
        tableModel = (NodeTypesTableModel)nodeTypesTable.getModel();

        ListSelectionModel selModel = nodeTypesTable.getSelectionModel();
        selModel.addListSelectionListener (new ListSelectionListener () {
                public void valueChanged (ListSelectionEvent e) {
                    if (e.getValueIsAdjusting())
                        return;
                    ListSelectionModel lsm = (ListSelectionModel)e.getSource();
                    if (lsm.isSelectionEmpty()) {
                        removeButton.setEnabled (false);
                    } else {
                        removeButton.setEnabled (true);
                    }
                }
            });
            
//          Object[] array = publicNodeTypeNamesMap.keySet().toArray();
//          for (int i = 0; i < array.length; i++) {
//              array[i] = new NamedClass ((Class)array[i]);
//          }
//          Arrays.sort (array, new NamedClassComparator());
//          JComboBox cb = new JComboBox (array);

        JComboBox cb = new JComboBox (getPublicNodeTypesInheritanceTree());
        cb.setEditable (false);
        DefaultCellEditor dce = new DefaultCellEditor (cb);
//          dce.setClickCountToStart (2);
        nodeTypesTable.getColumnModel().getColumn (0).setCellEditor (dce);     
    }
 
源代码30 项目: dctb-utfpr-2018-1   文件: Container.java
private void createJList() {
    String[] type = {"A", "B", "C"};
    JList list = new JList<String>(type);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent le) {
            int idx = list.getSelectedIndex();
            if (idx != -1)
                titulo.setText(titulo.getText() + type[idx]);
        }
    });
    bottom.add(list);
}
 
 类所在包
 同包方法