// -------------------------------------------------------------------------------------- // // ---------------------------------- Constructor Helpers ------------------------------- // // -------------------------------------------------------------------------------------- // private void buildActiveKits(JPanel container) { // initialize variable final int WIDTH = 150; // set containment panel properties container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS)); setComponentSize(container, 150, PAGE_HEIGHT); JLabel header = new JLabel("Active Kits"); header.setHorizontalAlignment(header.CENTER); header.setFont(new Font("Serif", Font.BOLD, 18)); setComponentSize(header, WIDTH, 25); // create list model and list listModel = new DefaultListModel(); kitList = new JList(listModel); kitList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); kitList.addListSelectionListener(this); kitList.setFixedCellHeight(25); JScrollPane listScrollPane = new JScrollPane(kitList); // add elements to containment panel container.add(header); container.add(listScrollPane); }
private void addListeners() { myListener = new SdkModel.Listener() { @Override public void sdkAdded(Sdk sdk) {} @Override public void beforeSdkRemove(Sdk sdk) {} @Override public void sdkChanged(Sdk sdk, String previousName) { refreshSdkList(); } @Override public void sdkHomeSelected(Sdk sdk, String newSdkHome) {} }; myProjectSdksModel.addListener(myListener); mySdkList.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { updateOkButton(); } }); }
private JList<String> boxList() { if (boxList == null) { boxList = ui.createList(boxes().toArray(new String[0])); boxList.addListSelectionListener(this); } return boxList; }
private void createUI() { setHelpText("Importing an ontology from a repository", HELP_TEXT); list = new JList(); list.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { setPageComplete(validateData()); updateNextPage(); } }); refreshList(); LabeledComponent lc = new LabeledComponent("Select an ontology to import", new JScrollPane(list)); JPanel holder = new JPanel(new BorderLayout(3, 3)); holder.add(lc, BorderLayout.NORTH); addRepositoryAction = new AbstractAction("Add repository...") { public void actionPerformed(ActionEvent e) { addRepository(); } }; JPanel buttonHolder = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonHolder.add(new JButton(addRepositoryAction), BorderLayout.SOUTH); holder.add(buttonHolder, BorderLayout.SOUTH); getContentComponent().add(holder, BorderLayout.NORTH); setPageComplete(validateData()); }
private JList<String> machineList() { if (machineList == null) { machineList = ui.createList(boxes().toArray(new String[0])); machineList.addListSelectionListener(this); } return machineList; }
private JList<String> tubList() { if (tubList == null) { tubList = ui.createList(new String[] {}); tubList.addListSelectionListener(this); } return tubList; }
// Add JButton and JList components to the panel. public ScribblePane3() { // Implicit super() call here invokes the superclass constructor // Add a "Clear" button to the panel. // Handle button events with an action listener JButton clear = new JButton("Clear"); clear.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { clear(); } }); this.add(clear); // Add a JList to allow color choices. // Handle list selection events with a ListSelectionListener. final JList colorList = new JList(colorNames); colorList.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { setColor(colors[colorList.getSelectedIndex()]); } }); this.add(colorList); }
/** * Instantiates a new help search panel. * * @param root the root * @param dialog the dialog */ public HelpSearchPanel(HelpIndexRoot root, HelpDialog dialog) { this.root = root; this.dialog = dialog; setLayout(new BorderLayout()); JPanel queryPanel = new JPanel(); queryPanel.setLayout(new BorderLayout()); queryPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); queryField = new JTextField(); queryField.setActionCommand(MenuUtils.SEARCH_BUTTON); queryField.addActionListener(this); queryPanel.add(queryField, BorderLayout.CENTER); searchButton = new JButton(MenuUtils.SEARCH_BUTTON); searchButton.setActionCommand(MenuUtils.SEARCH_BUTTON); searchButton.addActionListener(this); queryPanel.add(searchButton, BorderLayout.EAST); add(queryPanel, BorderLayout.NORTH); listModel = new DefaultListModel(); listModel.addElement("[No search results]"); resultList = new JList(listModel); resultList.addListSelectionListener(this); resultList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); resultsScrollPane = new JScrollPane(resultList); add(resultsScrollPane, BorderLayout.CENTER); }
private void initPlugins() { plugins.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); plugins.addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (plugins.getSelectedIndex() != -1) { PluginLoader loader = getCurrentLoader(); description.setText(loader.getDescription()); description.revalidate(); config.setEnabled(loader.getConfigDialog(SelectionFrame.this) != null); StringBuilder sb = new StringBuilder(); if (stat.isEmpty()) { sb = sb.append(loader.getName()); } else { sb = sb.append(stat).append(" > ").append(loader.getName()); } for (int i = 0; i < InterfaceConfig.SELECTION_FRAME_PROPERTIES.getInt("tabs-count"); i++) { sb = sb.insert(0, " "); } status.setText(sb.toString()); } } }); setLoaders(TaskState.getLoaders()); }
/** Initializes the config list. */ private void initList() { configList.setModel(new DefaultListModel()); configList.setCellRenderer(new ConfigListCellRenderer()); configList.addListSelectionListener(this); configList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane configScrollList = new JScrollPane(); configScrollList.getVerticalScrollBar().setUnitIncrement(30); configScrollList.getViewport().add(configList); add(configScrollList, BorderLayout.WEST); String osgiFilter = "(" + ConfigurationForm.FORM_TYPE + "=" + ConfigurationForm.ADVANCED_TYPE + ")"; ServiceReference[] confFormsRefs = null; try { confFormsRefs = AdvancedConfigActivator.bundleContext.getServiceReferences( ConfigurationForm.class.getName(), osgiFilter); } catch (InvalidSyntaxException ex) { } if (confFormsRefs != null) { for (int i = 0; i < confFormsRefs.length; i++) { ConfigurationForm form = (ConfigurationForm) AdvancedConfigActivator.bundleContext.getService(confFormsRefs[i]); if (form.isAdvanced()) this.addConfigForm(form); } } }
public SplitPaneDemo() { // Create the list of images and put it in a scroll pane. list = new JList(imageNames); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0); list.addListSelectionListener(this); JScrollPane listScrollPane = new JScrollPane(list); picture = new JLabel(); picture.setFont(picture.getFont().deriveFont(Font.ITALIC)); picture.setHorizontalAlignment(JLabel.CENTER); JScrollPane pictureScrollPane = new JScrollPane(picture); // Create a split pane with the two scroll panes in it. splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, listScrollPane, pictureScrollPane); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(150); // Provide minimum sizes for the two components in the split pane. Dimension minimumSize = new Dimension(100, 50); listScrollPane.setMinimumSize(minimumSize); pictureScrollPane.setMinimumSize(minimumSize); // Provide a preferred size for the split pane. splitPane.setPreferredSize(new Dimension(400, 200)); updateLabel(imageNames[list.getSelectedIndex()]); }
public JComponent CreateOpTab( String operatorName, Map<String, Object> parameterMap, AppContext appContext) { initializeOperatorUI(operatorName, parameterMap); final JComponent panel = createPanel(); bandList.addListSelectionListener( new ListSelectionListener() { public void valueChanged(final ListSelectionEvent e) { setNumberOfEigenvalues(); } }); showEigenvalues.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { showEigenvaluesFlag = (e.getStateChange() == ItemEvent.SELECTED); } }); subtractMeanImage.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { subtractMeanImageFlag = (e.getStateChange() == ItemEvent.SELECTED); } }); initParameters(); return panel; }
private void createListener() { mLinksList.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent pE) { if (mLinksList.isSelectionEmpty()) { mViewDocButton.setEnabled(false); } else { mViewDocButton.setEnabled(true); } } }); }
/** Constructor */ public ServiceFilterPanel(String text, Vector list) { empty_border = new EmptyBorder(5, 5, 0, 5); indent_border = new EmptyBorder(5, 25, 5, 5); service_box = new JCheckBox(text); service_box.addActionListener(this); service_data = new Vector(); if (list != null) { service_box.setSelected(true); service_data = (Vector) list.clone(); } service_list = new JList(service_data); service_list.setBorder(new EtchedBorder()); service_list.setVisibleRowCount(5); service_list.addListSelectionListener(this); service_list.setEnabled(service_box.isSelected()); service_scroll = new JScrollPane(service_list); service_scroll.setBorder(new EtchedBorder()); remove_service_button = new JButton("Remove"); remove_service_button.addActionListener(this); remove_service_button.setEnabled(false); remove_service_panel = new JPanel(); remove_service_panel.setLayout(new FlowLayout()); remove_service_panel.add(remove_service_button); service_area = new JPanel(); service_area.setLayout(new BorderLayout()); service_area.add(service_scroll, BorderLayout.CENTER); service_area.add(remove_service_panel, BorderLayout.EAST); service_area.setBorder(indent_border); add_service_field = new JTextField(); add_service_field.addActionListener(this); add_service_field.getDocument().addDocumentListener(this); add_service_field.setEnabled(service_box.isSelected()); add_service_button = new JButton("Add"); add_service_button.addActionListener(this); add_service_button.setEnabled(false); add_service_panel = new JPanel(); add_service_panel.setLayout(new BorderLayout()); JPanel dummy = new JPanel(); dummy.setBorder(empty_border); add_service_panel.add(dummy, BorderLayout.WEST); add_service_panel.add(add_service_button, BorderLayout.EAST); add_service_area = new JPanel(); add_service_area.setLayout(new BorderLayout()); add_service_area.add(add_service_field, BorderLayout.CENTER); add_service_area.add(add_service_panel, BorderLayout.EAST); add_service_area.setBorder(indent_border); setLayout(new BorderLayout()); add(service_box, BorderLayout.NORTH); add(service_area, BorderLayout.CENTER); add(add_service_area, BorderLayout.SOUTH); setBorder(empty_border); }
/** * Create the left panel, containing the movie name list and the performance date list. * * @return The left panel. */ public JComponent createLeftPanel() { nameListModel = new DefaultListModel(); nameList = new JList(nameListModel); nameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); nameList.setPrototypeCellValue("123456789012"); nameList.addListSelectionListener(new NameSelectionListener()); JScrollPane p1 = new JScrollPane(nameList); dateListModel = new DefaultListModel(); dateList = new JList(dateListModel); dateList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); dateList.setPrototypeCellValue("123456789012"); dateList.addListSelectionListener(new DateSelectionListener()); JScrollPane p2 = new JScrollPane(dateList); JPanel p = new JPanel(); p.setLayout(new GridLayout(1, 2)); p.add(p1); p.add(p2); return p; }
protected JScrollPane createDirectoryList() { directoryList = new JList(); align(directoryList); directoryList.setCellRenderer(new DirectoryCellRenderer()); directoryList.setModel(new MotifDirectoryListModel()); directoryList.addMouseListener(createDoubleClickListener(getFileChooser(), directoryList)); directoryList.addListSelectionListener(createListSelectionListener(getFileChooser())); JScrollPane scrollpane = new JScrollPane(directoryList); scrollpane.setMaximumSize(MAX_SIZE); scrollpane.setPreferredSize(prefListSize); align(scrollpane); return scrollpane; }
public ClientsPanel() { super(new BorderLayout()); lstClients = new JList(); lstClients.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lstClients.setCellRenderer( new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { EditorClient c = (EditorClient) value; JLabel label = new JLabel(c.getName()); if (c.isPresent()) label.setForeground(MyColors.getMainColor(c.getColorCode())); else label.setForeground(Color.GRAY); if (isSelected) label.setBackground(lstClients.getSelectionBackground()); return label; } }); lstClients.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (EditorServer_Debug) System.out.println(" mouseClicked "); int ndx = lstClients.locationToIndex(new Point(e.getX(), e.getY())); if (ndx > -1 && ndx < lstClients.getModel().getSize()) lstClients.setSelectedIndex(ndx); else { if (EditorServer_Debug) System.out.println(" invalid mouse click on the JList"); } } }); lstClients.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { EditorClient c = (EditorClient) lstClients.getSelectedValue(); currClient = c; updateActionTableFor(currClient); } }); tblActions = new JTable(getClearTableModel()); add(new JScrollPane(lstClients), BorderLayout.WEST); add(new JScrollPane(tblActions), BorderLayout.CENTER); }
private Component createListPanel() { model = new DefaultListModel(); list = new JList(model); list.setCellRenderer(new FilterRenderer()); list.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { enableAppropriately(); } } }); return new JScrollPane(list); }
private JList courseList() { JList result = new JList((ListModel) _plan.getSemester(_year, _semester)); result.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); result.setCellRenderer(_planViewCellRenderer); result.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (_courseList.getSelectedIndex() > -1) { _planViewPanel.courseSelected( (Course) _courseList.getModel().getElementAt(_courseList.getSelectedIndex()), _year, _semester); // _planViewPanel.setSelectedSemester(_year, _semester); } } }); return result; }
public EtatPanelDist( Hashtable uneHashtable, BoiteChangementEtatSommetDist parent, String defaultValue) { ardoise = new EtatArdoiseDist(uneHashtable, parent); Vector listeItems = new Vector(); JList liste = new JList(); JScrollPane listeAvecAscenseur; listeItems.addElement("A"); listeItems.addElement("B"); listeItems.addElement("C"); listeItems.addElement("D"); listeItems.addElement("E"); listeItems.addElement("F"); listeItems.addElement("G"); listeItems.addElement("H"); listeItems.addElement("I"); listeItems.addElement("J"); listeItems.addElement("K"); listeItems.addElement("L"); listeItems.addElement("M"); listeItems.addElement("N"); listeItems.addElement("O"); listeItems.addElement("P"); listeItems.addElement("Q"); listeItems.addElement("R"); listeItems.addElement("S"); listeItems.addElement("T"); listeItems.addElement("U"); listeItems.addElement("V"); listeItems.addElement("W"); listeItems.addElement("X"); listeItems.addElement("Y"); listeItems.addElement("Z"); liste = new JList(listeItems); liste.setSelectedValue(defaultValue, true); ardoise.changerEtat((String) liste.getSelectedValue()); liste.addListSelectionListener(this); setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5)); add(ardoise); listeAvecAscenseur = new JScrollPane(liste); listeAvecAscenseur.setPreferredSize(new Dimension(200, 80)); add(listeAvecAscenseur); setVisible(true); }
public ListDemo() { super(new BorderLayout()); listModel = new DefaultListModel(); // Create the list and put it in a scroll pane. list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0); list.addListSelectionListener(this); list.setVisibleRowCount(5); JScrollPane listScrollPane = new JScrollPane(list); JButton hireButton = new JButton(hireString); HireListener hireListener = new HireListener(hireButton); hireButton.setActionCommand(hireString); hireButton.addActionListener(hireListener); hireButton.setEnabled(false); loadButton = new JButton(loadString); loadButton.setActionCommand(loadString); loadButton.addActionListener(new loadListener()); employeeName = new JTextField(10); employeeName.addActionListener(hireListener); employeeName.getDocument().addDocumentListener(hireListener); String name; if (listModel.size() > 0) { name = listModel.getElementAt(list.getSelectedIndex()).toString(); } // Create a panel that uses BoxLayout. JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.add(loadButton); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(new JSeparator(SwingConstants.VERTICAL)); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(employeeName); buttonPane.add(hireButton); buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(listScrollPane, BorderLayout.CENTER); add(buttonPane, BorderLayout.PAGE_END); }
public JListDemo() { super("List Source Demo"); contentpane = getContentPane(); contentpane.setLayout(new FlowLayout()); list = new JList(listColorNames); list.setSelectedIndex(0); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); contentpane.add(new JScrollPane(list)); list.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { contentpane.setBackground(listColorValues[list.getSelectedIndex()]); } }); setSize(200, 200); setVisible(true); }
@Override public void init() { JPanel pane = new JPanel(); PointOnCircle point = new PointOnCircle(); JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 50, 15); Hashtable labelTable = new Hashtable(); labelTable.put(new Integer(0), new JLabel("Stop")); labelTable.put(new Integer(15), new JLabel("Slow")); labelTable.put(new Integer(50), new JLabel("Fast")); slider.setLabelTable(labelTable); slider.setPaintLabels(true); slider.addChangeListener( e -> { int speed; JSlider source = (JSlider) e.getSource(); speed = source.getValue(); point.setSpeed(speed); }); DefaultListModel<String> model = new DefaultListModel<>(); model.addElement("Right"); model.addElement("Left"); JList list = new JList(model); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0); list.addListSelectionListener( e -> { if (list.getSelectedIndex() == 0) { point.setRight(true); } else { point.setRight(false); } }); pane.add(slider); pane.add(list); add(point, BorderLayout.CENTER); add(pane, BorderLayout.NORTH); }
protected JScrollPane createFilesList() { fileList = new JList(); if (getFileChooser().isMultiSelectionEnabled()) { fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } else { fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } fileList.setModel(new MotifFileListModel()); fileList.setCellRenderer(new FileCellRenderer()); fileList.addListSelectionListener(createListSelectionListener(getFileChooser())); fileList.addMouseListener(createDoubleClickListener(getFileChooser(), fileList)); align(fileList); JScrollPane scrollpane = new JScrollPane(fileList); scrollpane.setPreferredSize(prefListSize); scrollpane.setMaximumSize(MAX_SIZE); align(scrollpane); return scrollpane; }
public LongListFrame() { wordList = new JList<String>(new WordListModel(3)); wordList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); wordList.setPrototypeCellValue("www"); JScrollPane scrollPane = new JScrollPane(wordList); JPanel p = new JPanel(); p.add(scrollPane); wordList.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { setSubject(wordList.getSelectedValue()); } }); Container contentPane = getContentPane(); contentPane.add(p, BorderLayout.NORTH); label = new JLabel(prefix + suffix); contentPane.add(label, BorderLayout.CENTER); setSubject("fox"); pack(); }
/** Create the UI */ private void init() { mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); lst = new JList(); DefaultListModel model = new DefaultListModel(); for (int i = 0; i < names.length; i++) { model.addElement(names[i]); } lst.setModel(model); lst.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lst.addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent lse) { onThumbnailChange(lse); } }); lst.setSelectedIndex(0); mainPanel.add(new JScrollPane(lst), BorderLayout.WEST); mainPanel.add(imageLabel, BorderLayout.EAST); }
/** Builds the UI. */ private void initUI() { // Initialize the JList DefaultListModel model = new DefaultListModel(); for (int i = 0; i < names.length; i++) { model.addElement(names[i]); } lst = new JList(model); // Add a selection listener lst.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lst.addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent lse) { onThumbnailChange(lse); } }); lst.setSelectedIndex(0); // calls onThumbnailChange(lse) // Add components. mainPanel = new JPanel(new BorderLayout()); mainPanel.add(new JScrollPane(lst), BorderLayout.WEST); mainPanel.add(imageLabel, BorderLayout.CENTER); }
public JList7() { JFrame f = new JFrame("JList"); Container contentPane = f.getContentPane(); contentPane.setLayout(new BorderLayout()); label = new JLabel(); list = new JList(s); list.setVisibleRowCount(5); list.setBorder(BorderFactory.createTitledBorder("您最喜欢到哪个国家玩呢?")); list.addListSelectionListener(this); contentPane.add(label, BorderLayout.NORTH); contentPane.add(new JScrollPane(list), BorderLayout.CENTER); f.pack(); f.show(); f.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); }
private JList getSelectedRobotsList() { if (selectedRobotsList == null) { selectedRobotsList = new JList(); selectedRobotsList.setModel(new SelectedRobotsModel()); selectedRobotsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); MouseListener mouseListener = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { removeButtonActionPerformed(); } if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { contextMenuActionPerformed(); } } }; selectedRobotsList.addMouseListener(mouseListener); selectedRobotsList.addListSelectionListener(eventHandler); } return selectedRobotsList; }
public StackTraceTool(Environment env) { super(new BorderLayout()); this.env = env; this.runtime = env.getExecutionManager(); this.context = env.getContextManager(); stackModel = new DefaultListModel(); // empty list = new JList(stackModel); list.setCellRenderer(new StackFrameRenderer()); JScrollPane listView = new JScrollPane(list); add(listView); // Create listener. StackTraceToolListener listener = new StackTraceToolListener(); context.addContextListener(listener); list.addListSelectionListener(listener); // ### remove listeners on exit! }