Java Code Examples for javax.swing.event.ListSelectionListener

The following are top voted examples for showing how to use javax.swing.event.ListSelectionListener. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: incubator-netbeans   File: ExitDialog.java   View source code 7 votes vote down vote up
/** 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"));
}
 
Example 2
Project: Reer   File: AbstractFilterEditorPanel.java   View source code 6 votes vote down vote up
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);
}
 
Example 3
Project: incubator-netbeans   File: PersistenceClientEntitySelectionVisual.java   View source code 6 votes vote down vote up
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 );
    }
}
 
Example 4
Project: incubator-netbeans   File: SuiteCustomizerSources.java   View source code 6 votes vote down vote up
/**
 * 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();
            } 
        }
    });
}
 
Example 5
Project: incubator-netbeans   File: GlobalOptionsPanel.java   View source code 6 votes vote down vote up
/** 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("");
            }
        }
    });
}
 
Example 6
Project: incubator-netbeans   File: DiffColorsPanel.java   View source code 6 votes vote down vote up
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);
}
 
Example 7
Project: incubator-netbeans   File: QueryParameter.java   View source code 6 votes vote down vote up
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();
}
 
Example 8
Project: incubator-netbeans   File: ToDoCustomizer.java   View source code 6 votes vote down vote up
/** 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();
}
 
Example 9
Project: SE2Project   File: RueckgabeWerkzeug.java   View source code 6 votes vote down vote up
/**
 * 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();
            }
        });
}
 
Example 10
Project: featurea   File: IntervalsComponent.java   View source code 6 votes vote down vote up
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();
        }
    });
}
 
Example 11
Project: incubator-netbeans   File: ParamsPanel.java   View source code 6 votes vote down vote up
/** 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);
}
 
Example 12
Project: AgentWorkbench   File: AddComponentDialog.java   View source code 6 votes vote down vote up
/**
   * 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;
  }
 
Example 13
Project: rapidminer   File: DatabaseSelectionView.java   View source code 6 votes vote down vote up
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();
}
 
Example 14
Project: lazycat   File: WebAppPanel.java   View source code 6 votes vote down vote up
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();

		}
	});

}
 
Example 15
Project: rapidminer   File: ExtendedErrorDialog.java   View source code 6 votes vote down vote up
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);
			}
		}
	});
}
 
Example 16
Project: Equella   File: FilterList.java   View source code 6 votes vote down vote up
@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);
			}
		}
	}
}
 
Example 17
Project: lazycat   File: TomcatPanel.java   View source code 6 votes vote down vote up
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());
}
 
Example 18
Project: QN-ACTR-Release   File: AllStationsParametersPanel.java   View source code 6 votes vote down vote up
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();
		}
	});
}
 
Example 19
Project: parabuild-ci   File: ConfigureDetectorsDialog.java   View source code 6 votes vote down vote up
/**
 * 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)));
			}
		}
	});
}
 
Example 20
Project: incubator-netbeans   File: JFXApplicationMultiPropertyPanel.java   View source code 5 votes vote down vote up
void registerListeners() {
    tableModel.addTableModelListener(this);
    tableMultiProperties.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent lse) {
            if (!lse.getValueIsAdjusting()) {
                updateRemoveButton();
            }
        }
    });
    cellEditor.registerCellEditorListener();
}
 
Example 21
Project: openjdk-jdk10   File: JListOperator.java   View source code 5 votes vote down vote up
/**
 * 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);
        }
    });
}
 
Example 22
Project: incubator-netbeans   File: NbPlatformCustomizer.java   View source code 5 votes vote down vote up
private NbPlatformCustomizer() {
    initComponents();
    initTabs();
    platformsList.addListSelectionListener(new ListSelectionListener() {
        @Override public void valueChanged(ListSelectionEvent e) {
            refreshPlatform();
        }
    });
    refreshPlatform();
}
 
Example 23
Project: incubator-netbeans   File: CategoryPanelStepFilters.java   View source code 5 votes vote down vote up
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);
}
 
Example 24
Project: incubator-netbeans   File: VariableFormatterEditPanel.java   View source code 5 votes vote down vote up
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);
        }
    });
}
 
Example 25
Project: incubator-netbeans   File: StatusLineComponent.java   View source code 5 votes vote down vote up
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());
        }
    });
}
 
Example 26
Project: PackagePlugin   File: MainFrame.java   View source code 5 votes vote down vote up
/**
 * 通过此方法添加的监听将通过代理 调用前显示遮罩
 * <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);
}
 
Example 27
Project: incubator-netbeans   File: FolderList.java   View source code 5 votes vote down vote up
/** 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);
}
 
Example 28
Project: openjdk-jdk10   File: bug7027139.java   View source code 5 votes vote down vote up
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");
}
 
Example 29
Project: incubator-netbeans   File: BranchPicker.java   View source code 5 votes vote down vote up
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;
}
 
Example 30
Project: incubator-netbeans   File: PopupSwitcher.java   View source code 5 votes vote down vote up
/**
 * 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 );
}
 
Example 31
Project: incubator-netbeans   File: ClassNameList.java   View source code 5 votes vote down vote up
/**
 * 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);
}
 
Example 32
Project: NBANDROID-V2   File: DeviceUiChooser.java   View source code 5 votes vote down vote up
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();
        }
    });
}
 
Example 33
Project: incubator-netbeans   File: TaskModel.java   View source code 5 votes vote down vote up
@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);
            }
        }
    });
}
 
Example 34
Project: incubator-netbeans   File: HibernateRevengDatabaseTablesPanel.java   View source code 5 votes vote down vote up
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);
}
 
Example 35
Project: incubator-netbeans   File: UnitTab.java   View source code 5 votes vote down vote up
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);
            }
        }
    });
}
 
Example 36
Project: incubator-netbeans   File: ToDoCustomizer.java   View source code 5 votes vote down vote up
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);
        }
    });
}
 
Example 37
Project: SE2Project   File: KundenauflisterWerkzeug.java   View source code 5 votes vote down vote up
/**
 * 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();
            }
        });
}
 
Example 38
Project: incubator-netbeans   File: HighlightingPanel.java   View source code 5 votes vote down vote up
/** 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");
}
 
Example 39
Project: incubator-netbeans   File: SourceWizardPanel.java   View source code 5 votes vote down vote up
/** 
 * 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());
}
 
Example 40
Project: java-swing-template   File: Utilities.java   View source code 5 votes vote down vote up
public static void attachTableSelectionChangedListener(JTable jt, final Callback action) {
    jt.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

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