DefaultListModel model = new DefaultListModel(); model.addElement("one"); model.addElement("two"); JList list = new JList(model);
private JComponent createQuickOpenSolvedPanel() { quickOpenSolvedJList = new JList<>(new DefaultListModel<>()); List<File> solvedFileList = solutionBusiness.getSolvedFileList(); return createQuickOpenPanel(quickOpenSolvedJList, "Solved dataset shortcuts", solvedFileList); }
pane.add(rightPanel, BorderLayout.LINE_END); pathStates = new JList<State>(); JScrollPane stScrollPane = new JScrollPane(pathStates); stScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); rightPanelTabs.addTab("path states", stScrollPane); metadataList = new JList<String>(); metadataModel = new DefaultListModel<String>(); metadataList.setModel(metadataModel); JScrollPane mdScrollPane = new JScrollPane(metadataList); mdScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); rightPanelTabs.addTab("metadata", mdScrollPane); annotationMatches = new JList<GraphBuilderAnnotation>(); annotationMatches.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { annotationMatchesModel = new DefaultListModel<GraphBuilderAnnotation>(); annotationMatches.setModel(annotationMatchesModel); JScrollPane amScrollPane = new JScrollPane(annotationMatches); amScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); rightPanelTabs.addTab("annotations", amScrollPane);
@Override JScrollPane initSwingComponent() { list = new JList(new DefaultListModel()); JScrollPane pane = new JScrollPane(list); return pane; }
DefaultListModel model = new DefaultListModel(); for(int i=0;i<nameData.length;i++){ if(nameData[i]==null) break; model.addElement(nameData[i]); // build defaultlistmodel } final JList list = new JList(); list.setModel(model);
mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); mainFrame.setSize(640, 300); mainFrame.setLocationRelativeTo(null); DefaultListModel searchResultListModel = new DefaultListModel(); DefaultListSelectionModel searchResultSelectionModel = new DefaultListSelectionModel(); searchResultSelectionModel searchInputPanel.add(searchButton, BorderLayout.EAST); JList searchResultList = new JList(); searchResultList.setModel(searchResultListModel); searchResultList.setSelectionModel(searchResultSelectionModel); selectionOptionsPanel.add(showPersonDetailsButton); contentPane.add(searchInputPanel, BorderLayout.NORTH); contentPane.add(searchResultPanel, BorderLayout.CENTER); contentPane.add(selectionOptionsPanel, BorderLayout.SOUTH);
/** Creates a panel containing a sample JCheckBoxList */ public static JPanel createSimpleDemoPanel() { JPanel pnl = new JPanel(new BorderLayout()); DefaultListModel model = new DefaultListModel(); for (int i = 0; i < 5; i++) { model.addElement("Button #" + i); } JButtonList list = new JButtonList(model); pnl.add(new JScrollPane(list), BorderLayout.CENTER); pnl.setBorder(BorderFactory.createTitledBorder("JCheckBoxList")); return pnl; }
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new TestPane()); list = new JList(); list.setDragEnabled(true); list.setTransferHandler(new ListTransferHandler()); DefaultListModel model = new DefaultListModel(); for (int index = 0; index < 10; index++) { model.addElement(new ListItem("Item " + index));
public class ComboboxModelTest extends JFrame{ public static void main(String[] args) { ComboboxModelTest comboboxModelTest = new ComboboxModelTest(); comboboxModelTest.pack(); comboboxModelTest.setVisible(true); } public ComboboxModelTest() { Container contentPane = getContentPane(); contentPane.setLayout(new FlowLayout()); DefaultListModel defaultListModel = new DefaultListModel(); defaultListModel.addElement("Element 1"); defaultListModel.addElement("Element 2"); ComboBoxModel firstComboboxModel = new ListAdapterComboboxModel(defaultListModel); ComboBoxModel secondComboboxModel = new ListAdapterComboboxModel(defaultListModel); JComboBox jComboBox1 = new JComboBox(firstComboboxModel); JComboBox jComboBox2 = new JComboBox(secondComboboxModel); contentPane.add(jComboBox1); contentPane.add(jComboBox2); } }
mainPanel.setLayout(new BorderLayout()); getContentPane().setLayout(new BorderLayout()); getContentPane().add(mainPanel, BorderLayout.CENTER); mainPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); DefaultListModel model = new DefaultListModel(); for (Class c : classes) { model.addElement(c); mainPanel.add(new JScrollPane(list), BorderLayout.CENTER);
public JComponent createVisualRepresentation () { JList list = new JList (new DefaultListModel ()); JScrollPane scrollPane = new JScrollPane (list); scrollPane.setPreferredSize(new java.awt.Dimension(400, 150)); return scrollPane; }
JList list = new JList(); // You need to create the JList first JScrollPane scrollPane = new JScrollPane(list); // Add the scrollpane to the UI ... // At some time in the future, load the results... DefaultListModel model = new DefaultListModel(); while (src.hasNext()) { String lol = src.nextLine(); model.addElement(lol); } list.setModel(model);
JPanel panel = new Jpanel(); JList list = new JList({"this", "is", "a test", "list"}); JScrollPane sPane = new JScrollPane(); public void actionPerformed(ActionEvent e) { if (resultsPane!=null){ panel.remove(sPane); } sPane = updatePane(list); panel.add(sPane); } public void updatePane(String[] newListItems) { DefaultListModel model = new DefaultListModel(); for(int i = 0; i < newListItems.length; i++) { model.addElement(newListItems[i]); } JList aList = new JList(model); JScrollPane aPane = new JScrollPane(aList); }
/** * Creates new form NewJFrame1 */ public SetSelector() throws Exception { if (OVTK2Desktop.getDesktopResources().getSelectedViewer() == null) { return; } OVTK2Desktop.getInstance().getDesktopResources().getParentPane().add(this); graph = OVTK2Desktop.getDesktopResources().getSelectedViewer().getONDEXJUNGGraph(); initComponents(); this.setVisible(true); this.setTitle("Show tagget sets for members"); DefaultListModel listModel = new DefaultListModel(); lSets.setModel(listModel); for (ONDEXConcept c : graph.getConceptsOfConceptClass(MdHelper.createCC(graph, "Superset"))) { JCheckBox check = new JCheckBox(c.getConceptName().getName()); supersets.put(check, c); listModel.addElement(check); } System.err.println("Set selectior initialized."); }
private void showPathsInPanel(List<GraphPath> paths) { // show paths in a list panel DefaultListModel<PathPrinter> data = new DefaultListModel<PathPrinter>(); for(GraphPath gp : paths ){ data.addElement( new PathPrinter(gp) ); } pathsList.setModel(data); }
private JComponent createQuickOpenUnsolvedPanel() { quickOpenUnsolvedJList = new JList<>(new DefaultListModel<>()); List<File> unsolvedFileList = solutionBusiness.getUnsolvedFileList(); return createQuickOpenPanel(quickOpenUnsolvedJList, "Unsolved dataset shortcuts", unsolvedFileList); }
logText = new JTextPane(); logText.setEditable(false); JScrollPane logTextScroll = new JScrollPane(logText); logTextScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); logPanel.setVisible(false); JScrollPane historyTableScrollPane = new JScrollPane(historyTable); historyButtonRemove = new JButton(rb.getString("remove")); historyButtonClear = new JButton(rb.getString("clear")); queuePanel.setVisible(false); queuePanel.setPreferredSize(new Dimension(300, 250)); queueListModel = new DefaultListModel(); JList queueList = new JList(queueListModel); queueList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); queueList.addMouseListener(new QueueMenuMouseListener()); JScrollPane queueListScroll = new JScrollPane(queueList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); for (String item : Utils.getConfigList("queue")) { queueListModel.addElement(item); gbc.gridy = 0; pane.add(ripPanel, gbc); gbc.gridy = 1; pane.add(statusPanel, gbc); gbc.gridy = 2; pane.add(progressPanel, gbc); gbc.gridy = 3; pane.add(optionsPanel, gbc); gbc.weighty = 1;
/** * Creates the list that displays the items in the collection we are * editing. */ private Component createList() { m_list = new JList(); m_model = new DefaultListModel(); m_list.setModel(m_model); JScrollPane scroll = new JScrollPane(m_list); return scroll; }
private JList list ; private DefaultListModel model; public ListModelTest(){//default constructor //.... list = new JList(); model = new DefaultListModel(); list.setModel(model); //.... } public void actionPerformed(ActionEvent ev){ model.addElement("element"); //.... }
@Override public void valueChanged(ListSelectionEvent ev) { PathPrinter pp = ((PathPrinter) pathsList.getSelectedValue()); if(pp==null){ return; } GraphPath path = pp.gp; DefaultListModel<State> pathModel = new DefaultListModel<State>(); for( State st : path.states ){ pathModel.addElement( st ); } pathStates.setModel( pathModel ); showGraph.highlightGraphPath(path); }