Java Code Examples for javax.swing.event.ListSelectionListener

The following examples show how to use javax.swing.event.ListSelectionListener. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: openAGV   Source File: TextListInputPanel.java    License: Apache License 2.0 7 votes vote down vote up
/** 
 * 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);
        }
      }
    }
  });
}
 
Example 2
Source Project: netbeans   Source File: ExitDialog.java    License: Apache License 2.0 6 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 3
Source Project: netbeans   Source File: ToDoCustomizer.java    License: Apache License 2.0 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 4
Source Project: Cafebabe   Source File: InstructionList.java    License: GNU General Public License v3.0 6 votes vote down vote up
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();
			}
		}
	});
}
 
Example 5
Source Project: arcusplatform   Source File: RulesViewBuilder.java    License: Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 6
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 7
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 8
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 9
Source Project: netbeans   Source File: GlobalOptionsPanel.java    License: Apache License 2.0 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 10
Source Project: netbeans   Source File: Outline.java    License: Apache License 2.0 6 votes vote down vote up
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;
            }
        }
    });
}
 
Example 11
Source Project: netbeans   Source File: SiteTemplateWizard.java    License: Apache License 2.0 6 votes vote down vote up
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();
        }
    });
}
 
Example 12
Source Project: netbeans   Source File: SuiteCustomizerSources.java    License: Apache License 2.0 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 13
Source Project: netbeans   Source File: DiffColorsPanel.java    License: Apache License 2.0 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 14
Source Project: netbeans   Source File: OptionsPanel.java    License: Apache License 2.0 6 votes vote down vote up
/** 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);

}
 
Example 15
Source Project: netbeans   Source File: SyncPanel.java    License: Apache License 2.0 6 votes vote down vote up
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();
        }
    });
}
 
Example 16
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());
        }
      }
    }
  });
}
 
Example 17
Source Project: netbeans   Source File: PropertyEditorPanel.java    License: Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 18
Source Project: openAGV   Source File: AttributesTable.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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));
      }
    }
  });
}
 
Example 19
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);
        }
    });

}
 
Example 20
Source Project: NBANDROID-V2   Source File: DeviceUiChooser.java    License: Apache License 2.0 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 21
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);
}
 
Example 22
Source Project: netbeans   Source File: CompletionScrollPane.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 23
Source Project: ghidra   Source File: ListPanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 24
Source Project: netbeans   Source File: JFXApplicationMultiPropertyPanel.java    License: Apache License 2.0 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 25
Source Project: arcusplatform   Source File: SearchingPage.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 26
Source Project: netbeans   Source File: AnnotationsPanel.java    License: Apache License 2.0 5 votes vote down vote up
/** 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);
   }
 
Example 27
Source Project: jdk8u60   Source File: bug7027139.java    License: GNU General Public License v2.0 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 28
Source Project: openjdk-jdk8u   Source File: bug7027139.java    License: GNU General Public License v2.0 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
Source Project: netbeans   Source File: TreeNodeFilterCustomEditor.java    License: Apache License 2.0 5 votes vote down vote up
/**
     */
    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);     
    }
 
Example 30
Source Project: dctb-utfpr-2018-1   Source File: Container.java    License: Apache License 2.0 5 votes vote down vote up
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);
}