List of usage examples for javax.swing DefaultListModel DefaultListModel
DefaultListModel
From source file:Demo.HistGraph.java
public HistGraph(List<String> paraType_list) { this.paraType_list = paraType_list; // widgets: charts(JFreeChart), parameter selector (JList) chartPane = new ChartPanel(null); charts = new JFreeChart[paraType_list.size()]; DefaultListModel modelOfList = new DefaultListModel(); paraSelector = new JList(modelOfList); for (int i = 0; i < paraType_list.size(); i++) { modelOfList.addElement(paraType_list.get(i)); charts[i] = null;//from ww w . j a v a 2 s. c o m } paraSelector.setSelectedIndex(0); charts[0] = CreateChart(paraType_list.get(0)); chartPane.setChart(charts[0]); JScrollPane selectorPanel = new JScrollPane(); selectorPanel.setViewportView(paraSelector); paraSelector.addMouseListener(this); // layout GridBagLayout layout = new GridBagLayout(); setLayout(layout); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 1; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 20, 5, 5); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 20; add(new JLabel("Distribution:"), gbc); gbc.insets = new Insets(5, 5, 5, 20); gbc.gridx = 1; gbc.gridy = 0; gbc.weightx = 1; add(new JLabel("Parameters:"), gbc); gbc.weighty = 14; gbc.insets = new Insets(5, 20, 5, 5); gbc.gridx = 0; gbc.gridy = 1; gbc.weightx = 20; add(chartPane, gbc); gbc.insets = new Insets(5, 5, 15, 20); gbc.gridx = 1; gbc.gridy = 1; gbc.weightx = 1; add(selectorPanel, gbc); }
From source file:DropDemo.java
private JPanel createList() { DefaultListModel listModel = new DefaultListModel(); for (int i = 0; i < 10; i++) { listModel.addElement("List Item " + i); }//from w w w.j a v a 2 s. co m list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); JScrollPane scrollPane = new JScrollPane(list); scrollPane.setPreferredSize(new Dimension(400, 100)); list.setDragEnabled(true); list.setTransferHandler(new ListTransferHandler()); dropCombo = new JComboBox(new String[] { "USE_SELECTION", "ON", "INSERT", "ON_OR_INSERT" }); dropCombo.addActionListener(this); JPanel dropPanel = new JPanel(); dropPanel.add(new JLabel("List Drop Mode:")); dropPanel.add(dropCombo); JPanel panel = new JPanel(new BorderLayout()); panel.add(scrollPane, BorderLayout.CENTER); panel.add(dropPanel, BorderLayout.SOUTH); panel.setBorder(BorderFactory.createTitledBorder("List")); return panel; }
From source file:components.ListDemo.java
public ListDemo() { super(new BorderLayout()); listModel = new DefaultListModel(); listModel.addElement("Jane Doe"); listModel.addElement("John Smith"); listModel.addElement("Kathy Green"); //Create the list and put it in a scroll pane. list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0);//w w w . ja v a 2 s . c o m 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:Demo.ScatterGraph.java
public ScatterGraph(int sampleNb, List<String> paraType_list) { this.sampleNb = sampleNb; this.paraType_list = paraType_list; // widgets: charts(JFreeChart), parameter selectors (JList) DefaultListModel xModel = new DefaultListModel(); xSelector = new JList(xModel); JScrollPane xSelPane = new JScrollPane(); xSelPane.setViewportView(xSelector); DefaultListModel yModel = new DefaultListModel(); ySelector = new JList(yModel); JScrollPane ySelPane = new JScrollPane(); ySelPane.setViewportView(ySelector); charts = new JFreeChart[paraType_list.size()][paraType_list.size()]; for (int i = 0; i < paraType_list.size(); i++) { String para = paraType_list.get(i); xModel.addElement(para);//from www . j a v a2 s. c o m yModel.addElement(para); for (int j = 0; j < paraType_list.size(); j++) { charts[i][j] = null; } } charts[0][0] = CreateChart(0, 0); chartPane = new ChartPanel(charts[0][0]); xSelector.setSelectedIndex(0); ySelector.setSelectedIndex(0); xSelector.addMouseListener(this); ySelector.addMouseListener(this); // layout GridBagLayout layout = new GridBagLayout(); setLayout(layout); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(5, 20, 5, 5); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 20; gbc.weighty = 12; gbc.gridheight = 4; add(chartPane, gbc); gbc.insets = new Insets(5, 5, 5, 20); gbc.gridx = 1; gbc.weightx = 1; gbc.gridheight = 1; gbc.gridy = 0; gbc.weighty = 1; add(new JLabel("X :"), gbc); gbc.gridy = 2; add(new JLabel("Y :"), gbc); gbc.gridy = 1; gbc.weighty = 5; add(xSelPane, gbc); gbc.gridy = 3; add(ySelPane, gbc); }
From source file:feedsplugin.FeedsSettingsTab.java
public JPanel createSettingsPanel() { final EnhancedPanelBuilder panelBuilder = new EnhancedPanelBuilder( FormFactory.RELATED_GAP_COLSPEC.encode() + ", fill:default:grow"); final CellConstraints cc = new CellConstraints(); mListModel = new DefaultListModel(); for (String feed : mSettings.getFeeds()) { mListModel.addElement(feed);// w w w . ja v a2s .c om } mFeeds = new JList(mListModel); mFeeds.setSelectedIndex(0); mFeeds.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); mFeeds.addListSelectionListener(new ListSelectionListener() { public void valueChanged(final ListSelectionEvent e) { listSelectionChanged(); } }); panelBuilder.addGrowingRow(); panelBuilder.add(new JScrollPane(mFeeds), cc.xyw(2, panelBuilder.getRow(), panelBuilder.getColumnCount() - 1)); mAdd = new JButton(mLocalizer.msg("add", "Add feed")); mAdd.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { String genre = JOptionPane.showInputDialog(mLocalizer.msg("addMessage", "Add feed URL"), ""); if (genre != null) { genre = genre.trim(); if (genre.length() > 0) { mListModel.addElement(genre); } } } }); mRemove = new JButton(mLocalizer.msg("remove", "Remove feed")); mRemove.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { final int index = mFeeds.getSelectedIndex(); if (index >= 0) { mListModel.remove(index); } } }); panelBuilder.addRow(); ButtonBarBuilder2 buttonBar = new ButtonBarBuilder2(); buttonBar.addButton(new JButton[] { mAdd, mRemove }); panelBuilder.add(buttonBar.getPanel(), cc.xyw(2, panelBuilder.getRow(), panelBuilder.getColumnCount() - 1)); mFeeds.addListSelectionListener(new ListSelectionListener() { public void valueChanged(final ListSelectionEvent e) { mRemove.setEnabled(mFeeds.getSelectedIndex() >= 0); } }); panelBuilder.addParagraph(mLocalizer.msg("moreFeeds", "Get more feeds")); panelBuilder.addRow(); JEditorPane help = UiUtilities.createHtmlHelpTextArea(mLocalizer.msg("help", "You can find more news feeds on the <a href=\"{0}\">plugin help page</a>. If you know more interesting feeds, feel free to add them on that page.", StringUtils.replace(PluginInfo.getHelpUrl(FeedsPlugin.getInstance().getId()), "&", "&"))); panelBuilder.add(help, cc.xyw(2, panelBuilder.getRow(), panelBuilder.getColumnCount() - 1)); // force update of enabled states listSelectionChanged(); return panelBuilder.getPanel(); }
From source file:be.fedict.eid.tsl.tool.SignSelectCertificatePanel.java
public SignSelectCertificatePanel(SignSelectPkcs11FinishablePanel pkcs11Panel, TrustServiceList trustServiceList) { this.pkcs11Panel = pkcs11Panel; this.trustServiceList = trustServiceList; this.component = new JPanel(); BoxLayout boxLayout = new BoxLayout(this.component, BoxLayout.PAGE_AXIS); this.component.setLayout(boxLayout); this.component.add(new JLabel("Please select a certificate from the token: ")); DefaultListModel listModel = new DefaultListModel(); this.certificateList = new JList(listModel); this.component.add(new JScrollPane(this.certificateList)); }
From source file:calzaii.CalzaII.java
public CalzaII() { try {//from w w w. j a v a2s . c o m initComponents(); servidor = "url"; userftp = "user"; passftp = "pass"; zapatos = new HashMap<>(); //Introducir lista de zapatos en HashMap URL url = new URL("http://" + servidor + "/consultar.php"); URLConnection consulta = url.openConnection(); BufferedReader modelos = new BufferedReader(new InputStreamReader(consulta.getInputStream())); String[] zapato; String[] imagen; while ((zapato = modelos.readLine().split(";")) != null && !zapato[0].isEmpty()) { imagen = zapato[1].split("/"); zapatos.put(zapato[0], imagen[4] + "/" + imagen[5]); } listaZapatos = new DefaultListModel(); jList1.setModel(listaZapatos); listaOfertas = new DefaultListModel(); jList2.setModel(listaOfertas); } catch (MalformedURLException ex) { Logger.getLogger(CalzaII.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(CalzaII.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.conwet.silbops.examples.gui.MainFrame.java
public MainFrame() { this.logModel = new DefaultListModel<>(); initComponents();//from w w w . jav a2 s .c om tglSub.setSelected(true); this.clearLines = new Runnable() { @Override public void run() { logModel.clear(); } }; }
From source file:com.emr.schemas.DestinationTables.java
/** * Creates a new DestinationTables form. * @param sourceQuery {@link String} SQL Query for getting the source data. * @param selected_columns {@link List} List containing the selected source columns * @param sourceTables {@link List} List containing the source tables * @param relations {@link String} Relationship between the source tables * @param emrConn {@link Connection} KenyaEMR Database Connection object *//* www .j ava2s. co m*/ public DestinationTables(String sourceQuery, List selected_columns, List sourceTables, String relations, Connection emrConn, TableRelationsForm parent) { fileManager = null; dbManager = null; mpiConn = null; this.parent = parent; this.sourceQuery = sourceQuery; this.selected_columns = selected_columns; this.sourceTables = sourceTables; this.relations = relations; this.emrConn = emrConn; listModel = new DefaultListModel<String>(); initComponents(); this.setClosable(true); SourceTablesListener listSelectionListener = new SourceTablesListener(new JTextArea(), listOfTables); destinationTablesList.setCellRenderer(new CheckboxListCellRenderer()); destinationTablesList.addListSelectionListener(listSelectionListener); destinationTablesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); //Create KenyaEMR DB connection fileManager = new FileManager(); String[] settings = fileManager.getConnectionSettings("mpi_database.properties", "mpi"); if (settings == null) { //Connection settings not found //Open MPIConnectionForm JOptionPane.showMessageDialog(null, "Database Settings not found. Please set the connection settings for the database first.", "MPI Database settings", JOptionPane.ERROR_MESSAGE); } else { if (settings.length < 1) { //Open MPIConnectionForm JOptionPane.showMessageDialog(null, "Database Settings not found. Please set the connection settings for the database first.", "MPI Database settings", JOptionPane.ERROR_MESSAGE); } else { //Connection settings are ok //We establish a connection dbManager = new DatabaseManager(settings[0], settings[1], settings[3], settings[4], settings[5]); mpiConn = dbManager.getConnection(); if (mpiConn == null) { JOptionPane.showMessageDialog(null, "Test Connection Failed", "Connection Test", JOptionPane.ERROR_MESSAGE); } else { //get emr schema getDatabaseMetaData(); } } } }
From source file:hr.fer.zemris.vhdllab.applets.view.compilation.CompilationErrorsView.java
@Override protected JComponent createControl() { model = new DefaultListModel(); final JList listContent = new JList(model); listContent.setFixedCellHeight(15);//from w w w . j a va 2 s. c om listContent.addMouseListener(new MouseClickAdapter() { @Override protected void onDoubleClick(MouseEvent e) { String selectedValue = (String) listContent.getSelectedValue(); highlightError(selectedValue); } }); simulationManager.addListener(this); return new JScrollPane(listContent); }