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

项目:incubator-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"));
}
项目:Reer    文件:AbstractFilterEditorPanel.java   
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);
}
项目:incubator-netbeans    文件:PersistenceClientEntitySelectionVisual.java   
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 );
    }
}
项目:incubator-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();
            } 
        }
    });
}
项目:incubator-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("");
            }
        }
    });
}
项目:incubator-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);
}
项目:incubator-netbeans    文件:QueryParameter.java   
public ListParameter(JList list, String parameter, String encoding) {
    super(parameter, encoding);
    this.list = list;
    list.setModel(new DefaultListModel());
    list.addListSelectionListener(new ListSelectionListener(){
        @Override
        public void valueChanged(ListSelectionEvent e) {
            int[] s = ListParameter.this.list.getSelectedIndices();
            if(e.getValueIsAdjusting()) {
                return;
            }
            fireStateChanged();
        };
    });
    original = list.getSelectedIndices();
    fireStateChanged();
}
项目:incubator-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();
}
项目:SE2Project    文件:RueckgabeWerkzeug.java   
/**
 * Registriert die Aktion die ausgeführt wird, wenn Verleihkarten selektiert
 * werden.
 */
private void registriereVerleihkartenAnzeigenAktion()
{
    _rueckgabeUI.getVerleihkartenAuflisterTable()
        .getSelectionModel()
        .addListSelectionListener(new ListSelectionListener()
        {

            @Override
            public void valueChanged(ListSelectionEvent e)
            {
                zeigeAusgewaehlteVerleihkarten();
                aktualisiereRuecknahmeButton();
            }
        });
}
项目:featurea    文件:IntervalsComponent.java   
private void setTable(JTable table) {
    this.table = table;
    tableModel = new DefaultTableModel() {
        @Override
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            if (columnIndex == 2) {
                return intervalValueExternalAction == null;
            } else {
                return true;
            }
        }
    };
    intervalValues = convertStringValueToIntervals(value);
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public synchronized void valueChanged(ListSelectionEvent e) {
            onUpdateValue();
        }
    });
}
项目:incubator-netbeans    文件:ParamsPanel.java   
/** Creates new form ParamsPanel */
public ParamsPanel() {
    bundle = org.openide.util.NbBundle.getBundle(ParamsPanel.class);
    initComponents ();
    initAccessibility();
    paramsList.setModel(getListModel());
    paramsList.getSelectionModel().addListSelectionListener(
        new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                if (paramsList.getSelectedIndex() != -1)
                    updateEditor(paramsList.getSelectedIndex());
                removeParamButton.setEnabled(paramsList.getSelectedIndex() != -1);
            }
        }
    );
    removeParamButton.setEnabled(paramsList.getSelectedIndex() != -1);
    HelpCtx.setHelpIDString(this, I18nUtil.HELP_ID_ADDPARAMS);
}
项目:AgentWorkbench    文件:AddComponentDialog.java   
/**
   * This method initializes componentTypesList
   * @return javax.swing.JList
   */
  private JList<ComponentTypeListElement> getJListComponentTypes() {
if (jListComponentTypes == null) {
    jListComponentTypes = new JList<ComponentTypeListElement>(this.getListModelComponentTypes());
    jListComponentTypes.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    jListComponentTypes.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent lse) {
            if (!lse.getValueIsAdjusting()) {
                // --- Set the current list element ---------
                setComponentTypeListElement();
            }
        }
    });
}
return jListComponentTypes;
  }
项目:rapidminer    文件:DatabaseSelectionView.java   
DatabaseSelectionView(Window owner) {
    this.manageConnectionsdialog = new ManageDatabaseConnectionsDialog(owner);
    this.setLayout(new BorderLayout());
    JList connectionList = this.manageConnectionsdialog.getConnectionListCopy();
    ExtendedJScrollPane connectionsPanel = new ExtendedJScrollPane(connectionList);
    connectionsPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 250, 10, 250), BorderFactory.createLineBorder(Color.LIGHT_GRAY)));
    this.add(connectionsPanel, "Center");
    this.testLabel = new FixedWidthLabel(370, "", (Icon)null);
    this.testLabel.setIconTextGap(10);
    connectionList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            DatabaseSelectionView.this.resetTestStatus();
            DatabaseSelectionView.this.testButton.setEnabled(DatabaseSelectionView.this.getSelectedConnection() != null);
            DatabaseSelectionView.this.editButton.setEnabled(DatabaseSelectionView.this.getSelectedConnection() != null);
            DatabaseSelectionView.this.fireStateChanged();
        }
    });
    this.createButtonPanel();
}
项目:lazycat    文件:WebAppPanel.java   
public void addListener() {
    WebAppListener listener = new WebAppListener();
    bAdd.addActionListener(listener);
    bEdit.addActionListener(listener);
    bDelete.addActionListener(listener);
    bStart.addActionListener(listener);
    bStop.addActionListener(listener);
    bRestart.addActionListener(listener);
    t.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            WebAppPanel.instance.syncStatus();

        }
    });

}
项目:rapidminer    文件:ExtendedErrorDialog.java   
public StackTraceList(Throwable t) {
    super(new DefaultListModel());
    setFont(getFont().deriveFont(Font.PLAIN));
    setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    appendAllStackTraces(t);
    addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (getSelectedIndex() >= 0) {
                if (!(getSelectedValue() instanceof FormattedStackTraceElement)) {
                    editButton.setEnabled(false);
                } else {
                    editButton.setEnabled(true);
                }
            } else {
                editButton.setEnabled(true);
            }
        }
    });
}
项目:Equella    文件:FilterList.java   
@Override
public void valueChanged(ListSelectionEvent e)
{
    if( e.getSource() == list )
    {
        ListSelectionListener[] lsl = listeners.getListeners(ListSelectionListener.class);
        if( lsl.length > 0 )
        {
            ListSelectionEvent e2 = new ListSelectionEvent(this, e.getFirstIndex(), e.getLastIndex(),
                e.getValueIsAdjusting());

            for( ListSelectionListener l : lsl )
            {
                l.valueChanged(e2);
            }
        }
    }
}
项目:lazycat    文件:TomcatPanel.java   
public void addListener() {
    TomcatListener listener = new TomcatListener();
    bAdd.addActionListener(listener);
    bEdit.addActionListener(listener);
    bDelete.addActionListener(listener);
    bStart.addActionListener(listener);
    bStop.addActionListener(listener);

    t.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            TomcatPanel.instance.syncStatus();

        }
    });

    t.addMouseListener(new TomcatMouseListener());
}
项目:QN-ACTR-Release    文件:AllStationsParametersPanel.java   
private void initComponents() {
    setLayout(new BorderLayout(5, 5));
    this.setBorder(new EmptyBorder(20, 20, 20, 20));
    //classesList = new JList(new StationsListModel());
    stationsList = new JList();
    stationsList.setListData(stationData.getStationKeys());
    stationsList.setCellRenderer(new StationElementRenderer());
    stationsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    panelDescription = new JLabel(STATIONS_PAR_DESCRIPTION);
    JScrollPane jsp = new JScrollPane(stationsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jsp.setPreferredSize(new Dimension(140, 200));
    add(panelDescription, BorderLayout.NORTH);
    add(jsp, BorderLayout.WEST);
    stationsList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            updateParsPane();
        }
    });
}
项目:parabuild-ci    文件:ConfigureDetectorsDialog.java   
/**
 * installs a list selection listener to populate the bottom details page based on selection changes in top grid.
 * A conversion from the table sorter index to the base model index is done to get the correct details
 */
private void postInitComponents() {
    // Listen to detector table selections so we can (hopefully)
    // display the description of the detector

    ListSelectionModel rowSM = detectorTable.getSelectionModel();
    rowSM.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) return;

            ListSelectionModel lsm = (ListSelectionModel) e.getSource();
            if (!lsm.isSelectionEmpty()) {
                int selectedRow = lsm.getMinSelectionIndex();
                DefaultSortedTableModel sorter = (DefaultSortedTableModel) detectorTable.getModel();
                viewDetectorDetails(factoryList.get(sorter.getBaseModelIndex(selectedRow)));
            }
        }
    });
}
项目:incubator-netbeans    文件:JFXApplicationMultiPropertyPanel.java   
void registerListeners() {
    tableModel.addTableModelListener(this);
    tableMultiProperties.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent lse) {
            if (!lse.getValueIsAdjusting()) {
                updateRemoveButton();
            }
        }
    });
    cellEditor.registerCellEditorListener();
}
项目:openjdk-jdk10    文件:JListOperator.java   
/**
 * Maps
 * {@code JList.removeListSelectionListener(ListSelectionListener)}
 * through queue
 */
public void removeListSelectionListener(final ListSelectionListener listSelectionListener) {
    runMapping(new MapVoidAction("removeListSelectionListener") {
        @Override
        public void map() {
            ((JList) getSource()).removeListSelectionListener(listSelectionListener);
        }
    });
}
项目:incubator-netbeans    文件:NbPlatformCustomizer.java   
private NbPlatformCustomizer() {
    initComponents();
    initTabs();
    platformsList.addListSelectionListener(new ListSelectionListener() {
        @Override public void valueChanged(ListSelectionEvent e) {
            refreshPlatform();
        }
    });
    refreshPlatform();
}
项目:incubator-netbeans    文件:CategoryPanelStepFilters.java   
private void initFilterClassesList() {
    filterClassesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            filterRemoveButton.setEnabled(filterClassesTable.getSelectedRow() >= 0);
        }
    });
    filterRemoveButton.setEnabled(filterClassesTable.getSelectedRow() >= 0);
    filterClassesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    filterClassesTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
}
项目:incubator-netbeans    文件:VariableFormatterEditPanel.java   
private void initChildrenVariablesTable() {
    removeVarButton.setEnabled(false);
    moveUpVarButton.setEnabled(false);
    moveDownVarButton.setEnabled(false);
    childrenVariablesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            int row = childrenVariablesTable.getSelectedRow();
            removeVarButton.setEnabled(row >= 0);
            moveUpVarButton.setEnabled(row > 0);
            moveDownVarButton.setEnabled(row >= 0 && row < childrenVariablesTable.getRowCount() - 1);
        }
    });
}
项目:incubator-netbeans    文件:StatusLineComponent.java   
public @Override void setModel(TaskModel mod) {
    model = mod;
    model.addListDataListener(new Listener());
    model.addListSelectionListener(new ListSelectionListener() {
        public @Override void valueChanged(ListSelectionEvent e) {
            pane.updateBoldFont(model.getSelectedHandle());
        }
    });
}
项目:PackagePlugin    文件:MainFrame.java   
/**
 * 通过此方法添加的监听将通过代理 调用前显示遮罩
 * <p>
 */
public void initListSelectionListener() {
    InvocationHandler handler2 = new AnnotationInvocationHandler(this, this.getListSelectionListenerImpl());
    ListSelectionListenerImpl cc = this.getListSelectionListenerImpl();
    ListSelectionListener listener = (ListSelectionListener) Proxy.newProxyInstance(cc.getClass().getClassLoader(), cc.getClass().getInterfaces(), handler2);
    dbList.addListSelectionListener(listener);
}
项目:incubator-netbeans    文件:FolderList.java   
/** Creates new form FolderList */
public FolderList (String label, char mnemonic, String accessibleDesc, String fcMessage,
                   char addButtonMnemonic, String addButtonAccessibleDesc,
                   char removeButtonMnemonic,String removeButtonAccessibleDesc) {
    this.fcMessage = fcMessage;
    initComponents();
    this.jLabel1.setText(label);
    this.jLabel1.setDisplayedMnemonic(mnemonic);
    this.roots.getAccessibleContext().setAccessibleName(accessibleDesc);
    this.roots.setCellRenderer(new Renderer());
    this.roots.setModel (new DefaultListModel());
    this.roots.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                removeButton.setEnabled(roots.getSelectedIndices().length != 0);
            }
        }
    });
    this.roots.setDragEnabled(true);
    this.roots.setDropMode(DropMode.INSERT);
    this.roots.setTransferHandler(new DNDHandle());
    this.addButton.getAccessibleContext().setAccessibleDescription(addButtonAccessibleDesc);
    this.addButton.setMnemonic (addButtonMnemonic);        
    this.removeButton.getAccessibleContext().setAccessibleDescription(removeButtonAccessibleDesc);
    this.removeButton.setMnemonic (removeButtonMnemonic);
    this.removeButton.setEnabled(false);
}
项目:openjdk-jdk10    文件: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");
}
项目:incubator-netbeans    文件:BranchPicker.java   
boolean openDialog () {
    final JButton okButton = new JButton();
    Mnemonics.setLocalizedText(okButton, NbBundle.getMessage(BranchPicker.class, "LBL_BranchPicker.okButton.text")); //NOI18N
    DialogDescriptor dd = new DialogDescriptor(panel, NbBundle.getMessage(BranchPicker.class, "LBL_BranchPicker.title"), //NOI18N
            true, new Object[] { okButton, DialogDescriptor.CANCEL_OPTION }, okButton, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx(BranchPicker.class), null);
    okButton.setEnabled(false);
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    ListSelectionListener list = new ListSelectionListener() {
        @Override
        public void valueChanged (ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                String selected = (String) panel.lstBranches.getSelectedValue();
                selectedPath = null;
                if (!FORBIDDEN_SELECTION.contains(selected)) {
                    selectedPath = selected;
                }
                okButton.setEnabled(selectedPath != null);
            }
        }
    };
    panel.lstBranches.addListSelectionListener(list);
    initializeItems();
    dialog.setVisible(true);
    SvnProgressSupport supp = loadingSupport;
    if (supp != null) {
        supp.cancel();
    }
    panel.lstBranches.removeListSelectionListener(list);
    return dd.getValue() == okButton;
}
项目:incubator-netbeans    文件:PopupSwitcher.java   
/**
 * For (unit) testing only
 * @param model
 * @param hits
 * @param forward 
 */
PopupSwitcher( Model model, final int hits, final boolean forward ) {
    super( new BorderLayout() );
    this.table = new Table(model);
    scrollPane = new JScrollPane( table );
    lblDescription = new JLabel(" "); //NOI18N //NOI18N
    lblDescription.setBorder( BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder( 1, 0, 0, 0, table.getGridColor()),
            BorderFactory.createEmptyBorder( 1, 1, 1, 1) ) );
    configureScrollPane();
    add( scrollPane, BorderLayout.CENTER );
    add( lblDescription, BorderLayout.SOUTH );
    Border b = UIManager.getBorder( "nb.popupswitcher.border" ); //NOI18N
    if( null == b )
        b = BorderFactory.createLineBorder(table.getGridColor());
    setBorder(b);
    setBackground( getDefaultBackground() );

    selectionListener = new ListSelectionListener() {
        @Override
        public void valueChanged( ListSelectionEvent e ) {
            updateDescription();
        }
    };
    table.getSelectionModel().addListSelectionListener( selectionListener );
    table.getColumnModel().getSelectionModel().addListSelectionListener( selectionListener );

    table.setInitialSelection( hits, forward );
}
项目:incubator-netbeans    文件:ClassNameList.java   
/**
 * Creates new form ClassNameList
 */
public ClassNameList() {
    initComponents();
    listClasses.setTableHeader(null);
    listClasses.getColumnModel().getColumn(0).setCellRenderer(new EnableAwareRenderer());
    listClasses.getColumnModel().getColumn(0).setCellEditor(new ValidatingCellEditor());
    listClasses.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            updateButtons();
        }
    });
    InnerPanelSupport.displayExtendedCells(listClasses);
}
项目: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();
        }
    });
}
项目:incubator-netbeans    文件:TaskModel.java   
@Override
public void valueChanged(final ListSelectionEvent e) {
    final ListSelectionListener[] lists = getSelectionListeners();
    eventExecutor.execute(new Runnable() {
        @Override
        public void run() {
            for (ListSelectionListener list : lists) {
                list.valueChanged(e);
            }
        }
    });
}
项目:incubator-netbeans    文件:HibernateRevengDatabaseTablesPanel.java   
public HibernateRevengDatabaseTablesPanel(Project project) {
    initComponents();
    this.project = project;

    ListSelectionListener selectionListener = new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            updateButtons();
        }
    };
    availableTablesList.getSelectionModel().addListSelectionListener(selectionListener);
    selectedTablesList.getSelectionModel().addListSelectionListener(selectionListener);
}
项目:incubator-netbeans    文件:UnitTab.java   
private void listenOnSelection () {
    table.getSelectionModel ().addListSelectionListener (new ListSelectionListener () {
        @Override
        public void valueChanged (final ListSelectionEvent e) {
            if (! SwingUtilities.isEventDispatchThread()) {
                SwingUtilities.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        valueChanged(e);
                    }
                });
                return ;
            }
            //Ignore extra messages.
            if (e.getValueIsAdjusting()) {
                return;
            }
            ListSelectionModel lsm =
                    (ListSelectionModel)e.getSource ();
            if (lsm.isSelectionEmpty ()) {
                //no rows are selected
                showDetailsAtRow (-1);
                popupActionsSupport.rowChanged (-1);
            } else {
                int selectedRow = table.convertRowIndexToModel(lsm.getMinSelectionIndex());                    
                popupActionsSupport.rowChanged (selectedRow);
                //selectedRow is selected
                Action action = null;
                if (removeLocallyDownloaded != null && removeLocallyDownloaded.isEnabled()) {
                    action = removeLocallyDownloaded;
                }
                showDetailsAtRow (selectedRow, action);
            }
        }
    });
}
项目:incubator-netbeans    文件:ToDoCustomizer.java   
private void initList() {
    mimeIdentifiers = Settings.getDefault().getMimeIdentifiers();
    extensionIdentifiers = Settings.getDefault().getExtensionIdentifiers();
    listIdentifiers.setCellRenderer(new IdentifierRenderer());
    updateListModel();
    listIdentifiers.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            int index = listIdentifiers.getSelectedIndex();
            btnRemoveMime.setEnabled(index != -1 && index != 0 && index != mimeIdentifiers.size() + 1);
            updateMimeDetails(index);
        }
    });
}
项目:SE2Project    文件:KundenauflisterWerkzeug.java   
/**
 * Registiert die Aktion, die ausgeführt wird, wenn ein Kunde ausgewählt
 * wird.
 */
private void registriereKundenAnzeigenAktion()
{
    _ui.getKundenTable()
        .getSelectionModel()
        .addListSelectionListener(new ListSelectionListener()
        {
            @Override
            public void valueChanged(ListSelectionEvent e)
            {
                informiereUeberAenderung();
            }
        });
}
项目:incubator-netbeans    文件:HighlightingPanel.java   
/** Creates new form Highlightingpanel1 */
public HighlightingPanel () {
    initComponents ();

    setName(loc("Editor_tab")); //NOI18N

    // 1) init components
    lCategories.getAccessibleContext ().setAccessibleName (loc ("AN_Categories"));
    lCategories.getAccessibleContext ().setAccessibleDescription (loc ("AD_Categories"));
    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"));
    lCategories.setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
    lCategories.setVisibleRowCount (3);
    lCategories.addListSelectionListener (new ListSelectionListener () {
        @Override
        public void valueChanged (ListSelectionEvent e) {
            if (!listen) return;
            refreshUI ();
        }
    });
    lCategories.setCellRenderer (new CategoryRenderer ());
    cbForeground.addItemListener(this);
    cbBackground.addItemListener (this);

    cbEffects.addItem (loc ("CTL_Effects_None"));
    cbEffects.addItem (loc ("CTL_Effects_Underlined"));
    cbEffects.addItem (loc ("CTL_Effects_Wave_Underlined"));
    cbEffects.addItem (loc ("CTL_Effects_Strike_Through"));
    cbEffects.getAccessibleContext ().setAccessibleName (loc ("AN_Effects"));
    cbEffects.getAccessibleContext ().setAccessibleDescription (loc ("AD_Effects"));
    cbEffects.addActionListener (this);
    cbEffectColor.addItemListener(this);

    lCategory.setLabelFor (lCategories);
    loc (lCategory, "CTL_Category");
    loc (lForeground, "CTL_Foreground_label");
    loc (lBackground, "CTL_Background_label");
}
项目:incubator-netbeans    文件:SourceWizardPanel.java   
/** 
 * List content drives remove button enableness.
 */
private void initList() {
    sourcesList.getSelectionModel().addListSelectionListener(
        new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent evt) {
                removeButton.setEnabled(!sourcesList.isSelectionEmpty());
            }
        }
    );

    removeButton.setEnabled(!sourcesList.isSelectionEmpty());
}
项目:java-swing-template    文件:Utilities.java   
public static void attachTableSelectionChangedListener(JTable jt, final Callback action) {
    jt.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            action.run(e);
        }
    });
}