List of usage examples for javax.swing DefaultListModel DefaultListModel
DefaultListModel
From source file:stockit.Manager.java
/** * Creates new form Trader/*from ww w . j a v a 2 s .c o m*/ */ public Manager() { initComponents(); try { DefaultListModel demoList = new DefaultListModel(); DBConnection dbcon = new DBConnection(); dbcon.establishConnection(); Statement stmt = dbcon.con.createStatement(); ResultSet rs = stmt.executeQuery("SELECT tc.username" + " FROM trader as t, manager_account as mc," + " trader_account as tc" + " WHERE t.Manager_SSN = mc.Manager_SSN AND tc.Trader_SSN = t.Trader_SSN" + " AND mc.username = \"" + username + "\""); while (rs.next()) { demoList.addElement(rs.getString("username")); } dbcon.con.close(); listOfTraders = new JList(demoList); jScrollPane3.setViewportView(listOfTraders); //setUpTable(); } catch (Exception ex) { Logger.getLogger(clientLogin.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:kenh.xscript.elements.Debug.java
private void initial(Container c) { c.setLayout(new BorderLayout()); // Add variable list DefaultListModel<String> model = new DefaultListModel(); if (this.getEnvironment() != null) { java.util.Set<String> keys = this.getEnvironment().getVariables().keySet(); for (String key : keys) { model.addElement(key);/*from w w w .ja va 2 s. com*/ } } else { for (int i = 1; i < 10; i++) { model.addElement("Variable " + i); } model.addElement("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); } JList list = new JList(model); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane listPane = new JScrollPane(); listPane.setViewportView(list); listPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); c.add(listPane, BorderLayout.EAST); list.setPreferredSize(new Dimension(150, list.getPreferredSize().height)); // JTextField quote = new JTextField(); quote.requestFocus(); //JButton button = new JButton(">>"); JPanel quotePanel = new JPanel(); quotePanel.setLayout(new BorderLayout()); quotePanel.add(quote, BorderLayout.CENTER); //quotePanel.add(button, BorderLayout.EAST); JTextArea result = new JTextArea(); result.setEditable(false); JScrollPane resultPane = new JScrollPane(); resultPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); resultPane.setViewportView(result); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(quotePanel, BorderLayout.NORTH); panel.add(resultPane, BorderLayout.CENTER); c.add(panel, BorderLayout.CENTER); list.addListSelectionListener(this); //button.addActionListener(this); quote.addKeyListener(this); this.result = result; }
From source file:hr.fer.zemris.vhdllab.platform.ui.wizard.support.FileSelectionComponent.java
private void createComponent(Predicate projectFilter) { projectsCombobox = new JComboBox(projectList(projectFilter)); new ComboBoxAutoCompletion(projectsCombobox); model = new DefaultListModel(); list = new JList(model); list.setPreferredSize(new Dimension(150, 150)); projectsCombobox.addItemListener(new ItemListener() { @Override/* www. j a v a 2 s. com*/ public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateList(e.getItem()); } } }); setLayout(new BorderLayout()); add(projectsCombobox, BorderLayout.NORTH); add(new JScrollPane(list), BorderLayout.CENTER); }
From source file:ANNFileDetect.EditNet.java
public void populateList() { String[] nnames = new String[] { "" }; nnames = sqlite.GetNetworkNames();//from ww w . j a v a 2 s.c o m DefaultListModel mdl = new DefaultListModel(); for (int i = 0; i < nnames.length; i++) { mdl.add(i, nnames[i]); } NetList.setModel(mdl); NetList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { if (evt.getValueIsAdjusting()) { return; } else { String[] images = {}; try { images = sqlite.GetImagesForNetwork(NetList.getSelectedValue().toString()); } catch (Exception e) { System.out.println("exception: " + e.toString()); } DefaultListModel mdl2 = new DefaultListModel(); if (images.length > 0) { for (int i = 0; i < images.length; i++) { mdl2.add(i, images[i]); } } else { mdl2.clear(); thresholdList.setModel(mdl2); } fileList.setModel(mdl2); } } }); fileList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { if (evt.getValueIsAdjusting()) { return; } else { String[] thresh = sqlite.GetThresholds(NetList.getSelectedValue().toString(), fileList.getSelectedValue().toString()); DefaultListModel mdl3 = new DefaultListModel(); if (thresh.length > 0) { for (int i = 0; i < thresh.length; i++) { String[] vals = thresh[i].split(","); mdl3.add(i, "Range: " + vals[0] + "-" + vals[1] + " Score: " + vals[3] + " Weight: " + vals[2]); } } else { mdl3.clear(); } thresholdList.setModel(mdl3); } } }); }
From source file:com.orange.atk.graphAnalyser.RealtimeGraph.java
/** Creates new form Paneljavalauncher */ public RealtimeGraph(CreateGraph JaTKCharts) { this.JaTKCharts = JaTKCharts; chartPanel = JaTKCharts.getChartpanel(); listModelGraph = new DefaultListModel(); comboModelLeft = new DefaultComboBoxModel(); comboModelRight = new DefaultComboBoxModel(); mapPerfGraph = JaTKCharts.getMapPerfGraph(); mapAction = JaTKCharts.getMapAction(); chartPanel.setDomainZoomable(true);//w w w. j av a 2 s . c o m chartPanel.setRangeZoomable(true); chartPanel.setAutoscrolls(true); JATKpath = Platform.getInstance().getJATKPath(); initComponents(); jListPerfGraph.setCellRenderer(new MyGraphCellRenderer()); jComboBoxLeft.setRenderer(new MyGraphCellRenderer()); jComboBoxRight.setRenderer(new MyGraphCellRenderer()); jListGraph.setCellRenderer(new MyCellRenderer()); addPerformanceslist(); jListPerfGraph.getSelectionModel().addListSelectionListener(new listenPerfGraphHandler()); jListPerfGraph.setSelectionInterval(0, jListPerfGraph.getModel().getSize() - 1); this.setTitle("Real Time Graphics"); }
From source file:de.tor.tribes.ui.windows.ReportRulesDialog.java
public final void rebuildRuleList() { DefaultListModel model = new DefaultListModel(); for (ReportRule entry : ReportManager.getSingleton().getRules()) { model.addElement(entry);// w w w .j a v a 2 s .c om } jRuleList.setModel(model); }
From source file:com.sciaps.view.SpectrumAnalysisReportPanel.java
private void doInitialization() { initComponents();/*from w w w . j a v a2 s . co m*/ searchRange_ = 0.12; peakFoundPercentage_ = 35; lgPeakFoundPercentage_ = 50; peakWeightPercentage_ = 10; listModel_ = new DefaultListModel(); lstIdentifiedPeaks_.setModel(listModel_); peakMeritTableModel_ = new PeakMeritTableModel(); tblPeakMeritSummary_.setModel(peakMeritTableModel_); tblPeakMeritSummary_.setAutoCreateRowSorter(true); rejectedPeakMeritTableModel_ = new PeakMeritTableModel(); tblRejectedPeakMerit_.setModel(rejectedPeakMeritTableModel_); tblRejectedPeakMerit_.setAutoCreateRowSorter(true); setupTableColumnWidth(); spectrumAnalyze_ = new SpectrumAnalyze(); }
From source file:com.starbucks.apps.StarbucksBarista.java
private void setApplicationState(int state) { this.state = state; switch (state) { case STATE_READY: customerField.setText(""); amountField.setText(""); cardField.setText(""); orderIdField.setText(""); statusArea.setText(""); requestView.setText(""); responseView.setText(""); findButton.setEnabled(true);// w w w . j a v a 2 s . c o m prepareButton.setEnabled(false); viewButton.setEnabled(false); verifyButton.setEnabled(false); deliverButton.setEnabled(false); resetButton.setEnabled(false); ordersList.setModel(new DefaultListModel()); ordersList.setEnabled(true); break; case STATE_ITEM_PREPARED: findButton.setEnabled(false); prepareButton.setEnabled(false); viewButton.setEnabled(false); verifyButton.setEnabled(true); deliverButton.setEnabled(false); ordersList.setEnabled(false); resetButton.setEnabled(false); break; case STATE_PAYMENT_RECEIVED: findButton.setEnabled(false); prepareButton.setEnabled(false); viewButton.setEnabled(false); verifyButton.setEnabled(false); deliverButton.setEnabled(true); ordersList.setEnabled(false); resetButton.setEnabled(false); break; } }
From source file:ListDemo.java
public ListDemo() { super(new BorderLayout()); listModel = new DefaultListModel(); listModel.addElement("Debbie Scott"); listModel.addElement("Scott Hommel"); listModel.addElement("Sharon Zakhour"); // Create the list and put it in a scroll pane. list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0);// ww w . java 2 s .com 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); fireButton = new JButton(fireString); fireButton.setActionCommand(fireString); fireButton.addActionListener(new FireListener()); employeeName = new JTextField(10); employeeName.addActionListener(hireListener); employeeName.getDocument().addDocumentListener(hireListener); String 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(fireButton); 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); }
From source file:DragListDemo.java
public DragListDemo() { arrayListHandler = new ArrayListTransferHandler(); JList list1, list2;/* ww w . j a v a 2 s . com*/ DefaultListModel list1Model = new DefaultListModel(); list1Model.addElement("0 (list 1)"); list1Model.addElement("1 (list 1)"); list1Model.addElement("2 (list 1)"); list1Model.addElement("3 (list 1)"); list1Model.addElement("4 (list 1)"); list1Model.addElement("5 (list 1)"); list1Model.addElement("6 (list 1)"); list1 = new JList(list1Model); list1.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); list1.setTransferHandler(arrayListHandler); list1.setDragEnabled(true); JScrollPane list1View = new JScrollPane(list1); list1View.setPreferredSize(new Dimension(200, 100)); JPanel panel1 = new JPanel(); panel1.setLayout(new BorderLayout()); panel1.add(list1View, BorderLayout.CENTER); panel1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); DefaultListModel list2Model = new DefaultListModel(); list2Model.addElement("0 (list 2)"); list2Model.addElement("1 (list 2)"); list2Model.addElement("2 (list 2)"); list2Model.addElement("3 (list 2)"); list2Model.addElement("4 (list 2)"); list2Model.addElement("5 (list 2)"); list2Model.addElement("6 (list 2)"); list2 = new JList(list2Model); list2.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); list2.setTransferHandler(arrayListHandler); list2.setDragEnabled(true); JScrollPane list2View = new JScrollPane(list2); list2View.setPreferredSize(new Dimension(200, 100)); JPanel panel2 = new JPanel(); panel2.setLayout(new BorderLayout()); panel2.add(list2View, BorderLayout.CENTER); panel2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setLayout(new BorderLayout()); add(panel1, BorderLayout.LINE_START); add(panel2, BorderLayout.LINE_END); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }