List of usage examples for javax.swing DefaultListModel DefaultListModel
DefaultListModel
From source file:misc.TextBatchPrintingDemo.java
/** * Create and display the main application frame. */// ww w .j av a 2 s.c o m void createAndShowGUI() { messageArea = new JLabel(defaultMessage); selectedPages = new JList(new DefaultListModel()); selectedPages.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); selectedPages.addListSelectionListener(this); setPage(homePage); JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(pageItem), new JScrollPane(selectedPages)); JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); /** Menu item and keyboard shortcuts for the "add page" command. */ fileMenu.add(createMenuItem(new AbstractAction("Add Page") { public void actionPerformed(ActionEvent e) { DefaultListModel pages = (DefaultListModel) selectedPages.getModel(); pages.addElement(pageItem); selectedPages.setSelectedIndex(pages.getSize() - 1); } }, KeyEvent.VK_A, KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.ALT_MASK))); /** Menu item and keyboard shortcuts for the "print selected" command.*/ fileMenu.add(createMenuItem(new AbstractAction("Print Selected") { public void actionPerformed(ActionEvent e) { printSelectedPages(); } }, KeyEvent.VK_P, KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.ALT_MASK))); /** Menu item and keyboard shortcuts for the "clear selected" command.*/ fileMenu.add(createMenuItem(new AbstractAction("Clear Selected") { public void actionPerformed(ActionEvent e) { DefaultListModel pages = (DefaultListModel) selectedPages.getModel(); pages.removeAllElements(); } }, KeyEvent.VK_C, KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.ALT_MASK))); fileMenu.addSeparator(); /** Menu item and keyboard shortcuts for the "home page" command. */ fileMenu.add(createMenuItem(new AbstractAction("Home Page") { public void actionPerformed(ActionEvent e) { setPage(homePage); } }, KeyEvent.VK_H, KeyStroke.getKeyStroke(KeyEvent.VK_H, ActionEvent.ALT_MASK))); /** Menu item and keyboard shortcuts for the "quit" command. */ fileMenu.add(createMenuItem(new AbstractAction("Quit") { public void actionPerformed(ActionEvent e) { for (Window w : Window.getWindows()) { w.dispose(); } } }, KeyEvent.VK_A, KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.ALT_MASK))); JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); JPanel contentPane = new JPanel(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); contentPane.add(pane); contentPane.add(messageArea); JFrame frame = new JFrame("Text Batch Printing Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setJMenuBar(menuBar); frame.setContentPane(contentPane); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); if (printService == null) { // Actual printing is not possible, issue a warning message. JOptionPane.showMessageDialog(frame, "No default print service", "Print Service Alert", JOptionPane.WARNING_MESSAGE); } }
From source file:search2go.UIFrame.java
public UIFrame() throws IOException, ParseException { topLevels = new TopLevelGTermSet[] { CCs, MFs, BPs }; this.addWindowListener(new WindowAdapter() { @Override/*from w w w .java 2 s . c o m*/ public void windowClosing(WindowEvent et) { try { if (os.isWindows()) { Runtime.getRuntime().exec("cmd /C TaskKill -IM blastx.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM blastn.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM blastp.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM python.exe -F"); } else { Runtime.getRuntime().exec("killAll -KILL blastx"); Runtime.getRuntime().exec("killAll -KILL blastn"); Runtime.getRuntime().exec("killAll -KILL blastp"); Runtime.getRuntime().exec("killAll -KILL python"); } } catch (IOException ex) { System.out.println("Error closing child processes"); } } }); initComponents(); txtBlastOutput.getDocument().addDocumentListener(new BufferEnforcer(txtBlastOutput)); txtFullOutput.getDocument().addDocumentListener(new BufferEnforcer(txtFullOutput)); txtMapOutput.getDocument().addDocumentListener(new BufferEnforcer(txtMapOutput)); ((DefaultCaret) txtBlastOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); ((DefaultCaret) txtMapOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); ((DefaultCaret) txtFullOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); webSaveMenu = new JPopupMenu(); JMenuItem saveWeb = new JMenuItem(); saveWeb.setText("Save"); saveWeb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { webSaveDialogue.showSaveDialog(pnlChartHolder); File saveFile = webSaveDialogue.getSelectedFile(); if (!saveFile.getPath().contains(".png")) saveFile = new File(saveFile.getPath() + ".png"); try { BufferedImage webChartImage = new BufferedImage(pnlChartHolder.getWidth(), pnlChartHolder.getHeight(), BufferedImage.TYPE_INT_RGB); pnlChartHolder.print(webChartImage.getGraphics()); ImageIO.write(webChartImage, "png", saveFile); } catch (Exception ex) { javax.swing.JOptionPane.showMessageDialog(pnlChartHolder, "Error saving chart. Please try again."); } } }); webSaveMenu.add(saveWeb); pnlChartHolder.add(webSaveMenu); pnlChartHolder.setLayout(new java.awt.BorderLayout()); try { currentProj = Workspace.open(new Path("Search2GO_Data")); chkDoCCs.setState(currentProj.willDoCC()); chkDoBPs.setState(currentProj.willDoBP()); chkDoMFs.setState(currentProj.willDoMF()); txtQuery.setText(currentProj.getQueryPath()); txtQueryFP.setText(currentProj.getQueryPath()); txtDatabase.setText(currentProj.getPathToDB()); txtDatabaseFP.setText(currentProj.getPathToDB()); txtThreads.setValue(currentProj.getThreadNo()); txtThreadsFP.setValue(currentProj.getThreadNo()); cbxNXP.setSelectedIndex(currentProj.getBlastTypeIndex()); cbxNXPFP.setSelectedIndex(currentProj.getBlastTypeIndex()); cbxDBID.setSelectedIndex(currentProj.getSelectedDBIndex()); cbxDBIDFP.setSelectedIndex(currentProj.getSelectedDBIndex()); txtBitScore.setValue(currentProj.getBitScoreThreshold()); txtBitScoreFP.setValue(currentProj.getBitScoreThreshold()); txtBlastE.setValue(currentProj.getEThreshold()); txtMapE.setValue(currentProj.getEThreshold()); txtEFP.setValue(currentProj.getEThreshold()); } catch (FileNotFoundException e) { currentProj = Workspace.create(new Path("Search2GO_Data")); chkDoCCs.setState(currentProj.willDoCC()); chkDoBPs.setState(currentProj.willDoBP()); chkDoMFs.setState(currentProj.willDoMF()); } this.setTitle("Search2GO " + currentProj.getPath().toString()); GTermTableModel = new DefaultTableModel(); GTermTableModel.setColumnCount(2); GTermTableModel.setColumnIdentifiers(new String[] { "GO ID", "Frequency" }); ListSelectionModel GTermSelector = tblGOFreq.getSelectionModel(); GTermSelector.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (tblGOFreq.getSelectedRow() > -1) { DefaultListModel emptyModel = new DefaultListModel(); lstQueries.setModel(emptyModel); txtTermInfo.setText(""); String selectedID = (String) tblGOFreq.getValueAt(tblGOFreq.getSelectedRow(), 0); JTextArea tempHolderInfo = new JTextArea(); JTextArea tempHolderQueries = new JTextArea(); if (tblGOFreq.getSelectedRow() != -1) { ResetGTermInfoGetter(tempHolderInfo, tempHolderQueries); gTermInfoGetter.getProcess(0).addParameter("id", selectedID.substring(0, selectedID.indexOf("["))); gTermInfoGetter.getProcess(1).addParameter("id", selectedID.substring(0, selectedID.indexOf("["))); GTerm currentGTerm = gTerms.getGTerm(selectedID.substring(0, selectedID.indexOf("["))); gTermInfoGetter.getProcess(1).addParameter("db", currentGTerm.getTopLevel().getCode()); gTermInfoGetter.setTail(new ProcessSequenceEnd() { @Override public void run() { tempHolderInfo.setText("id: " + selectedID + "\n" + tempHolderInfo.getText()); txtTermInfo.setText(tempHolderInfo.getText()); DefaultListModel queryList = new DefaultListModel(); for (String str : tempHolderQueries.getText().split(";")) { queryList.addElement(str.replaceAll("Query: ", "")); } lstQueries.setModel(queryList); prgIdentification.setIndeterminate(false); } }); try { gTermInfoGetter.start(); prgIdentification.setIndeterminate(true); } catch (IOException ex) { Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex); } } } } } }); lstQueries.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting() && !e.toString().contains("invalid") && lstQueries.getSelectedValue() != null) { JTextArea tempHolder = new JTextArea(); ProcessSequence fetchLocusSequence = new ProcessSequence(new ProcessSequenceEnd() { @Override public void run() { if (txtTermInfo.getText().contains("Score")) { txtTermInfo.setText( txtTermInfo.getText().substring(0, txtTermInfo.getText().indexOf("Score"))); } txtTermInfo.append(tempHolder.getText()); prgIdentification.setIndeterminate(false); } }); Path fetchLocusPath = new Path("Processes"); fetchLocusPath.append("fetchLocus.py"); Process fetchLocus = new Process(tempHolder); fetchLocus.setScriptCommand(fetchLocusPath.toEscString()); fetchLocus.addParameter("dir", currentProj.getPath().toEscString()); fetchLocus.addParameter("q", new ParameterString(lstQueries.getSelectedValue().replace("\n", "")).toString()); String selectedID = (String) tblGOFreq.getValueAt(tblGOFreq.getSelectedRow(), 0); GTerm currentGTerm = gTerms.getGTerm(selectedID.substring(0, selectedID.indexOf("["))); fetchLocus.addParameter("db", currentGTerm.getTopLevel().getCode()); fetchLocus.addParameter("id", currentGTerm.getID()); fetchLocusSequence.addProcess(fetchLocus); try { fetchLocusSequence.start(); prgIdentification.setIndeterminate(true); } catch (IOException ex) { Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex); } } } }); DocumentListener filterListener = new DocumentListener() { private void anyUpdate() { gTerms.getFilter().setFilterString(txtSearchTerms.getText()); if (!txtMinFreqFilter.getText().equals("")) gTerms.getFilter().setMinFreq(Integer.parseInt(txtMinFreqFilter.getText())); else gTerms.getFilter().setMinFreq(0); if (!txtMaxFreqFilter.getText().equals("")) gTerms.getFilter().setMaxFreq(Integer.parseInt(txtMaxFreqFilter.getText())); else gTerms.getFilter().setMaxFreq(-1); fillIdentTable(gTerms.stringFilter(), false); } @Override public void insertUpdate(DocumentEvent e) { anyUpdate(); } @Override public void removeUpdate(DocumentEvent e) { anyUpdate(); } @Override public void changedUpdate(DocumentEvent e) { anyUpdate(); } }; txtSearchTerms.getDocument().addDocumentListener(filterListener); txtMinFreqFilter.getDocument().addDocumentListener(filterListener); txtMaxFreqFilter.getDocument().addDocumentListener(filterListener); NumberFormat numberMask = NumberFormat.getIntegerInstance(); numberMask.setGroupingUsed(false); NumberFormatter numberMasker = new NumberFormatter(numberMask); NumberFormatter numberMaskerAndBlank = new NumberFormatter(numberMask) { @Override public Object stringToValue(String s) throws ParseException { if (s == null || s.length() == 0) return null; return super.stringToValue(s); } }; DefaultFormatterFactory numberMaskFactory = new DefaultFormatterFactory(numberMasker); DefaultFormatterFactory numberMaskAndBlankFactory = new DefaultFormatterFactory(numberMaskerAndBlank); txtThreads.setFormatterFactory(numberMaskFactory); txtThreadsFP.setFormatterFactory(numberMaskFactory); txtBitScore.setFormatterFactory(numberMaskAndBlankFactory); txtBitScoreFP.setFormatterFactory(numberMaskAndBlankFactory); txtMinFreqFilter.setFormatterFactory(numberMaskFactory); txtMaxFreqFilter.setFormatterFactory(numberMaskFactory); txtBlastE.setFormatterFactory(numberMaskAndBlankFactory); txtMapE.setFormatterFactory(numberMaskAndBlankFactory); txtEFP.setFormatterFactory(numberMaskAndBlankFactory); blastButton = new StopButton(btnBlast); mapButton = new StopButton(btnMapIDs); identButton = new StopButton(btnGTermIdent); fullButton = new StopButton(btnProcessFP); if (currentProj.getStage() >= 2) identify(false); }
From source file:gui.QTLResultsPanel.java
private void setsimple(Trait trait) { if (AppFrame.tpmmode == AppFrame.TPMMODE_QTL) { DefaultListModel<String> simplemodelModel = new DefaultListModel<String>(); simplemodelModel.addElement("Model Adj R^2 SIC"); for (String l : trait.getBestSimpleModels()) { simplemodelModel.addElement(l); }//from w w w . ja va2 s . c o m modelList = new JList<String>(simplemodelModel); modelList.addListSelectionListener(this); modelList.setFont(new Font("Monospaced", Font.PLAIN, 11)); modelList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); simpleDetails = new JScrollPane(modelList); // simple_details.setFont(new Font("Monospaced", Font.PLAIN, 11)); simpleDetails.setPreferredSize(new Dimension(200, 50)); simplesplit.setLeftComponent(simpleDetails); } else { setTrait_simple(trait, simpleright); } }
From source file:net.sf.xmm.moviemanager.gui.DialogIMDbMultiAdd.java
/** * Checks if the movie list should be retrived from IMDB or the local movie Database *//* ww w .j ava2 s . co m*/ void executeSearchMultipleMovies() { if (addInfoToExistingMovie) { executeEditExistingMovie(getSearchField().getText()); } else { final DefaultListModel listModel = new DefaultListModel(); int setSelectedIndex = 0; try { IMDb imdb = IMDbLib.newIMDb(MovieManager.getConfig().getHttpSettings()); ArrayList<ModelIMDbSearchHit> hits = imdb.getSimpleMatches(getSearchField().getText()); // Error if (hits == null) { HTTPResult res = imdb.getLastHTTPResult(); if (res.getStatusCode() == HttpStatus.SC_REQUEST_TIMEOUT) { listModel.addElement(new ModelIMDbSearchHit("Connection timed out...")); //$NON-NLS-1$ } } for (int i = 0; i < hits.size(); i++) { listModel.addElement(hits.get(i)); } } catch (Exception e) { executeErrorMessage(e); e.printStackTrace(); dispose(); } if (listModel.getSize() == 0) listModel.addElement( new ModelIMDbSearchHit(Localizer.get("DialogIMDB.list-element.messsage.no-hits-found"))); //$NON-NLS-1$ getMoviesList().setModel(listModel); getMoviesList().setSelectedIndex(setSelectedIndex); // This delays the execution of requestFocusInWindow. // The reason is to avoid that the actionlistener for the choose button // is invoked, which is would be if invokelater isn't used. (Experienced on Ubuntu). SwingUtilities.invokeLater(new Runnable() { public void run() { getMoviesList().requestFocusInWindow(); } }); } }
From source file:br.upe.ecomp.dosa.view.wizard.WizardAction.java
private void initMeasurements() { addMeasurements();/*from www. ja v a2 s. c o m*/ measurementSelectedList.setModel(new DefaultListModel()); measurementDescriptionTextArea.setText(""); updateMeasurementButtonsStatus(); measurementAvailableList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(final ListSelectionEvent evt) { measurementAvailableListSelectionListner(); } }); measurementSelectedList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(final ListSelectionEvent evt) { measurementSelectedListSelectionListner(); } }); }
From source file:edu.ku.brc.af.tasks.subpane.formeditor.ViewSetSelectorPanel.java
/** * /* ww w. j a v a 2 s . c o m*/ */ @SuppressWarnings("unchecked") //$NON-NLS-1$ public ViewSetSelectorPanel(final BasicFormPreviewPanel previewPanel) { this.previewPanel = previewPanel; Vector<String> levelsVec = new Vector<String>(); SpecifyUser user = AppContextMgr.getInstance().getClassObject(SpecifyUser.class); @SuppressWarnings("unused") Hashtable<Discipline, Boolean> usedColTypes = new Hashtable<Discipline, Boolean>(); levelsVec.add(user.getUserType()); // for (Agent agent : user.getAgents()) // { // // XXX Commented Out // /*Discipline ct = agent.getDiscipline(); // if (usedColTypes.get(ct) == null) // { // levelsVec.add(ct.getName()); // usedColTypes.put(ct, true); // }*/ // } levelsVec.add("BackStop"); //$NON-NLS-1$ addBtn = UIHelper.createIconBtn("PlusSign", "", new ActionListener() { //$NON-NLS-1$ //$NON-NLS-2$ public void actionPerformed(ActionEvent arg0) { addControl(); } }); delBtn = UIHelper.createIconBtn("MinusSign", "", new ActionListener() { //$NON-NLS-1$ //$NON-NLS-2$ public void actionPerformed(ActionEvent arg0) { delControl(TYPE.SelectedObj); } }); ActionListener addViewAL = new ActionListener() { public void actionPerformed(ActionEvent e) { addView(); } }; ActionListener delViewAL = new ActionListener() { public void actionPerformed(ActionEvent e) { delView(); } }; viewControlPanel = new EditDeleteAddPanel(null, delViewAL, addViewAL); ActionListener addAltViewAL = new ActionListener() { public void actionPerformed(ActionEvent e) { addAltView(); } }; ActionListener delAltViewAL = new ActionListener() { public void actionPerformed(ActionEvent e) { delAltView(); } }; altViewControlPanel = new EditDeleteAddPanel(null, delAltViewAL, addAltViewAL); ActionListener addDefViewAL = new ActionListener() { public void actionPerformed(ActionEvent e) { addViewDef(); } }; ActionListener delDefViewAL = new ActionListener() { public void actionPerformed(ActionEvent e) { delViewDef(); } }; viewDefControlPanel = new EditDeleteAddPanel(null, delDefViewAL, addDefViewAL); ActionListener saveAL = new ActionListener() { public void actionPerformed(ActionEvent e) { save(); } }; EditDeleteAddPanel saveControlPanel = new EditDeleteAddPanel(null, null, saveAL); saveControlPanel.getAddBtn().setIcon(IconManager.getIcon("Save", IconManager.IconSize.Std16)); //$NON-NLS-1$ saveControlPanel.getAddBtn().setEnabled(true); setLayout(new BorderLayout()); levelsList = new JList(levelsVec); panel = new EditorPropPanel(controlHash, subcontrolHash, null, true, this); //panel.setFormViewDef(null); PanelBuilder pb = new PanelBuilder(new FormLayout("p,4px,p, 6px,10px,6px, p,6px,p, 6px,10px,6px, p,f:p:g", //$NON-NLS-1$ "p,2px,f:p:g,2px,p,10px,p,4px")); //$NON-NLS-1$ CellConstraints cc = new CellConstraints(); String[] labels = new String[] { "User Level", "ViewSets", " ", "Views", "AltViews", " ", "View Defs" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ int x = 1; for (String label : labels) { pb.add(createLabel(label, SwingConstants.CENTER), cc.xy(x, 1)); x += 2; } Color vsFGColor = new Color(224, 224, 224); Color vsBGColor = new Color(124, 124, 124); Dimension ps = new Dimension(200, 150); x = 1; JScrollPane sp = createScrollPane(levelsList); pb.add(sp, cc.xy(x, 3)); x += 2; viewSetsList = new JList(new DefaultListModel()); sp = createScrollPane(viewSetsList); sp.setPreferredSize(ps); pb.add(sp, cc.xy(x, 3)); x += 2; pb.add(new VerticalSeparator(vsFGColor, vsBGColor), cc.xy(x, 3)); x += 2; viewsList = new JList(new DefaultListModel()); sp = new JScrollPane(viewsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp.setPreferredSize(ps); pb.add(sp, cc.xy(x, 3)); x += 2; altViewsList = new JList(new DefaultListModel()); sp = createScrollPane(altViewsList); sp.setPreferredSize(ps); pb.add(sp, cc.xy(x, 3)); x += 2; pb.add(new VerticalSeparator(vsFGColor, vsBGColor), cc.xy(x, 3)); x += 2; viewDefsList = new JList(new DefaultListModel()); sp = createScrollPane(viewDefsList); sp.setPreferredSize(ps); pb.add(sp, cc.xy(x, 3)); x += 2; pb.add(saveControlPanel, cc.xy(1, 5)); //pb.add(createLabel(" "), cc.xy(3, 5)); //pb.add(createLabel(" "), cc.xy(5, 5)); pb.add(viewControlPanel, cc.xy(7, 5)); pb.add(altViewControlPanel, cc.xy(9, 5)); //pb.add(createLabel(" "), cc.xy(11, 5)); pb.add(viewDefControlPanel, cc.xy(13, 5)); pb.addSeparator("View Def Editor", cc.xywh(1, 7, 13, 1)); //$NON-NLS-1$ add(pb.getPanel(), BorderLayout.NORTH); pb = new PanelBuilder(new FormLayout("max(250px;p),4px,f:p:g", "t:p")); //$NON-NLS-1$ //$NON-NLS-2$ PanelBuilder inner = new PanelBuilder(new FormLayout("max(250px;p)", "t:p,2px,t:p")); //$NON-NLS-1$ //$NON-NLS-2$ tree = new JTree(); ((DefaultTreeModel) tree.getModel()).setRoot(null); sp = createScrollPane(tree); inner.add(sp, cc.xy(1, 1)); PanelBuilder btnPb = new PanelBuilder(new FormLayout("f:p:g,p,2px,p", "p")); //$NON-NLS-1$ //$NON-NLS-2$ btnPb.add(delBtn, cc.xy(2, 1)); btnPb.add(addBtn, cc.xy(4, 1)); inner.add(btnPb.getPanel(), cc.xy(1, 3)); pb.add(inner.getPanel(), cc.xy(1, 1)); pb.add(panel, cc.xy(3, 1)); add(pb.getPanel(), BorderLayout.CENTER); tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { treeSelected(); } }); levelsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { levelSelected(); } } }); viewSetsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { viewSetSelected(); } } }); viewsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { viewSelected(); } } }); altViewsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { altViewSelected(); } } }); viewDefsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { viewDefSelected(); } } }); tree.addMouseListener(new MouseAdapter() { protected void doPopup(MouseEvent e) { if (e.isPopupTrigger()) { int xc = e.getX(); int yc = e.getY(); TreePath path = tree.getPathForLocation(xc, yc); if (path != null) { tree.setSelectionPath(path); } treeSelected(); DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) tree.getSelectionModel() .getSelectionPath().getLastPathComponent(); if (selectedCell != null || selectedRow != null) { new TreePopupMenu((Component) e.getSource(), e, selectedCell); } else if (selectedNode.getUserObject() instanceof FormViewDef) { new TreePopupMenu((Component) e.getSource(), e); } } } public void mouseReleased(MouseEvent e) { doPopup(e); } public void mousePressed(MouseEvent e) { doPopup(e); } }); XStream xstream = new XStream(); xstream.alias("control", Control.class); //$NON-NLS-1$ xstream.useAttributeFor(Control.class, "type"); //$NON-NLS-1$ xstream.useAttributeFor(Attr.class, "type"); //$NON-NLS-1$ xstream.useAttributeFor(Attr.class, "name"); //$NON-NLS-1$ xstream.useAttributeFor(Attr.class, "required"); //$NON-NLS-1$ xstream.useAttributeFor(Attr.class, "defaultValue"); //$NON-NLS-1$ xstream.aliasAttribute("default", "defaultValue"); //$NON-NLS-1$ //$NON-NLS-2$ xstream.alias("uicontrols", Vector.class); //$NON-NLS-1$ xstream.alias("attr", Attr.class); //$NON-NLS-1$ xstream.alias("param", Param.class); //$NON-NLS-1$ xstream.alias("subcontrol", SubControl.class); //$NON-NLS-1$ xstream.aliasAttribute("desc", "desc"); //$NON-NLS-1$ //$NON-NLS-2$ xstream.aliasAttribute(Attr.class, "values", "values"); //$NON-NLS-1$ //$NON-NLS-2$ xstream.useAttributeFor(SubControl.class, "type"); //$NON-NLS-1$ try { controls = (Vector<Control>) xstream.fromXML(FileUtils.readFileToString(new File("UIControls.xml"))); //$NON-NLS-1$ for (Control control : controls) { controlHash.put(control.getType(), control); if (control.getSubcontrols() != null) { for (SubControl sc : control.getSubcontrols()) { //System.out.println(" ["+sc.getType()+"] "); subcontrolHash.put(sc.getType(), sc); } } } } catch (IOException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ViewSetSelectorPanel.class, ex); ex.printStackTrace(); } }
From source file:com.github.alexfalappa.nbspringboot.projects.customizer.CfgPropsDialog.java
private void filterProps(String filter) { DefaultListModel<ConfigurationMetadataProperty> dlmCfgProps = new DefaultListModel<>(); for (ConfigurationMetadataProperty item : sortedProps) { if (filter == null || item.getId().contains(filter)) { if (Utils.isErrorDeprecated(item)) { if (bDeprErrorShow) { dlmCfgProps.addElement(item); }//from w ww . ja v a2 s . c o m } else { dlmCfgProps.addElement(item); } } } lCfgProps.setModel(dlmCfgProps); if (!dlmCfgProps.isEmpty()) { lCfgProps.setSelectedIndex(0); } }
From source file:ca.uhn.hl7v2.testpanel.ui.AddMessageDialog.java
private void initLocal() { DefaultListModel versionListModel = new DefaultListModel(); myVersionList.setModel(versionListModel); for (Version nextVersion : Version.values()) { versionListModel.addElement(nextVersion.getVersion()); }/*from ww w . j a v a2 s . c om*/ myVersionList.setSelectedIndex(versionListModel.getSize() - 1); myVersionList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent theE) { updateTypes(); } }); myMessageTypeListModel = new DefaultListModel(); myMessageTypeList.setModel(myMessageTypeListModel); updateTypes(); }
From source file:com.anrisoftware.prefdialog.fields.listbox.AbstractListBoxField.java
/** * Sets the specified elements for this combo box fields. * /*ww w . ja v a 2 s. c o m*/ * @param newElements * the elements array to set. * * @throws NullPointerException * if the specified elements are {@code null}. */ @SuppressWarnings({ "unchecked", "rawtypes" }) public void setElements(Object[] elements) { log.checkElements(this, elements); DefaultListModel model = new DefaultListModel(); for (Object e : elements) { model.addElement(e); } getComponent().setModel(model); log.elementsSet(this, elements); }
From source file:it.ventuland.ytd.ui.GUIClient.java
private void addComponentsToPane(final Container pane) { this.panel = new JPanel(); this.panel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; ActionManager lActionManager = new ActionManager(); dlm = new DefaultListModel<String>(); this.urllist = new JList<String>(dlm); // TODO maybe we add a button to remove added URLs from list? //this.userlist.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION ); this.urllist.setFocusable(false); textarea = new JTextArea(2, 2); textarea.setEditable(true);// w w w .ja v a2 s .c o m textarea.setFocusable(false); JScrollPane leftscrollpane = new JScrollPane(this.urllist); JScrollPane rightscrollpane = new JScrollPane(textarea); this.middlepane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftscrollpane, rightscrollpane); this.middlepane.setOneTouchExpandable(true); this.middlepane.setDividerLocation(150); Dimension minimumSize = new Dimension(25, 25); leftscrollpane.setMinimumSize(minimumSize); rightscrollpane.setMinimumSize(minimumSize); this.directorybutton = new JButton("", createImageIcon("images/open.png", "")); gbc.gridx = 0; gbc.gridy = 0; this.directorybutton.addActionListener(lActionManager); this.panel.add(this.directorybutton, gbc); this.saveconfigcheckbox = new JCheckBox("Save config"); this.saveconfigcheckbox.setSelected(false); this.panel.add(this.saveconfigcheckbox); this.saveconfigcheckbox.setEnabled(false); // TODO check if initial download directory exists // assume that at least the users homedir exists String shomedir = System.getProperty("user.home").concat(File.separator); gbc.gridx = 0; gbc.gridy = 2; gbc.gridwidth = 2; gbc.fill = GridBagConstraints.HORIZONTAL; this.directorytextfield = new JTextField(shomedir, 20 + (mIsDebug ? 48 : 0)); this.directorytextfield.setEnabled(false); this.directorytextfield.setFocusable(true); this.directorytextfield.addActionListener(lActionManager); this.panel.add(this.directorytextfield, gbc); JLabel dirhint = new JLabel("Download to folder:"); gbc.gridx = 0; gbc.gridy = 1; this.panel.add(dirhint, gbc); this.middlepane.setPreferredSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().width / 3, Toolkit.getDefaultToolkit().getScreenSize().height / 4 + (mIsDebug ? 200 : 0))); gbc.gridx = 0; gbc.gridy = 3; gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 2; gbc.weightx = 2; gbc.gridwidth = 2; this.panel.add(this.middlepane, gbc); // radio buttons for resolution to download mVideoResolutionBtnGrp = new ButtonGroup(); JPanel lRadioPanel = new JPanel(new GridLayout(1, 0)); List<Object> lVidQ = mAppContext.getList("youtube-downloader.video-quality"); JRadioButton lRadioButton = null; for (Object obj : lVidQ) { String lQuality = (String) obj; String lToolTip = mAppContext.getString("youtube-downloader.video-quality." + lQuality + ".tooltip"); boolean lSelected = mAppContext .getBoolean("youtube-downloader.video-quality." + lQuality + ".selected"); boolean lEnabled = mAppContext.getBoolean("youtube-downloader.video-quality." + lQuality + ".enabled"); lRadioButton = new JRadioButton(lQuality); lRadioButton.setName(lQuality); lRadioButton.setActionCommand(lQuality.toLowerCase()); lRadioButton.addActionListener(lActionManager); lRadioButton.setToolTipText(lToolTip); lRadioButton.setSelected(lSelected); lRadioButton.setEnabled(lEnabled); mVideoResolutionBtnGrp.add(lRadioButton); lRadioPanel.add(lRadioButton); } gbc.gridx = 1; gbc.gridy = 0; gbc.gridheight = 0; gbc.gridwidth = 0; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.NORTHEAST; this.panel.add(lRadioPanel, gbc); // radio buttons for video format to download mVideoQualityBtnGrp = new ButtonGroup(); lRadioPanel = new JPanel(new GridLayout(1, 0)); save3dcheckbox = new JCheckBox("3D"); save3dcheckbox.setToolTipText("stereoscopic video"); save3dcheckbox.setSelected(false); save3dcheckbox.setEnabled(true); lRadioPanel.add(save3dcheckbox); List<Object> lVidR = mAppContext.getList("youtube-downloader.video-resolution"); lRadioButton = null; for (Object obj : lVidR) { String lResolution = (String) obj; String lToolTip = mAppContext .getString("youtube-downloader.video-resolution." + lResolution + ".tooltip"); boolean lSelected = mAppContext .getBoolean("youtube-downloader.video-resolution." + lResolution + ".selected"); boolean lEnabled = mAppContext .getBoolean("youtube-downloader.video-resolution." + lResolution + ".enabled"); lRadioButton = new JRadioButton(lResolution); lRadioButton.setName(lResolution); lRadioButton.setActionCommand(lResolution.toLowerCase()); lRadioButton.addActionListener(lActionManager); lRadioButton.setToolTipText(lToolTip); lRadioButton.setSelected(lSelected); lRadioButton.setEnabled(lEnabled); mVideoQualityBtnGrp.add(lRadioButton); lRadioPanel.add(lRadioButton); } gbc.gridx = 1; gbc.gridy = 1; gbc.gridheight = 0; gbc.gridwidth = 0; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.NORTHEAST; this.panel.add(lRadioPanel, gbc); JLabel hint = new JLabel("Type, paste or drag'n drop a YouTube video address:"); gbc.fill = 0; gbc.gridwidth = 0; gbc.gridheight = 1; gbc.weightx = 0; gbc.weighty = 0; gbc.gridx = 0; gbc.gridy = 4; gbc.anchor = GridBagConstraints.WEST; this.panel.add(hint, gbc); textinputfield = new JTextField(20); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = 0; gbc.gridy = 5; gbc.gridwidth = 2; textinputfield.setEnabled(true); textinputfield.setFocusable(true); textinputfield.addActionListener(lActionManager); textinputfield.getDocument().addDocumentListener(new UrlInsertListener()); this.panel.add(textinputfield, gbc); this.quitbutton = new JButton("", createImageIcon("images/exit.png", "")); gbc.gridx = 2; gbc.gridy = 5; gbc.gridwidth = 0; this.quitbutton.addActionListener(lActionManager); this.quitbutton.setActionCommand("quit"); this.quitbutton.setToolTipText("Exit."); this.panel.add(this.quitbutton, gbc); pane.add(this.panel); addWindowListener(new GUIWindowAdapter()); this.setDropTarget(new DropTarget(this, new DragDropListener())); textarea.setTransferHandler(null); // otherwise the dropped text would be inserted }