List of usage examples for javax.swing JCheckBox JCheckBox
public JCheckBox(Action a)
From source file:jgnash.ui.report.compiled.MonthlyAccountBalanceChart.java
private JPanel createPanel() { LocalDate end = DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate()); LocalDate start = end.minusYears(1); startDateField.setDate(start);/*from www . j av a 2 s . co m*/ JButton refreshButton = new JButton(rb.getString("Button.Refresh")); refreshButton.setIcon(IconUtils.getIcon("/jgnash/resource/view-refresh.png")); subAccountCheckBox = new JCheckBox(rb.getString("Button.IncludeSubAccounts")); subAccountCheckBox.setSelected(true); hideLockedAccountCheckBox = new JCheckBox(rb.getString("Button.HideLockedAccount")); hidePlaceholderAccountCheckBox = new JCheckBox(rb.getString("Button.HidePlaceholderAccount")); Account a = combo.getSelectedAccount(); JFreeChart chart = createVerticalXYBarChart(a); final ChartPanel chartPanel = new ChartPanel(chart); FormLayout layout = new FormLayout("p, 4dlu, p:g", ""); DefaultFormBuilder builder = new DefaultFormBuilder(layout); FormLayout dLayout = new FormLayout("p, 4dlu, p, 8dlu, p, 4dlu, p, 8dlu, p", ""); DefaultFormBuilder dBuilder = new DefaultFormBuilder(dLayout); dBuilder.append(rb.getString("Label.StartDate"), startDateField); dBuilder.append(rb.getString("Label.EndDate"), endDateField); dBuilder.append(refreshButton); FormLayout cbLayout = new FormLayout("p, 4dlu, p, 4dlu, p, 4dlu", ""); DefaultFormBuilder cbBuilder = new DefaultFormBuilder(cbLayout); cbBuilder.append(subAccountCheckBox); cbBuilder.append(hideLockedAccountCheckBox); cbBuilder.append(hidePlaceholderAccountCheckBox); builder.append(rb.getString("Label.Account"), combo); builder.nextLine(); builder.append(" "); builder.append(cbBuilder.getPanel()); builder.nextLine(); builder.appendRelatedComponentsGapRow(); builder.nextLine(); builder.append(dBuilder.getPanel(), 3); builder.nextLine(); builder.appendUnrelatedComponentsGapRow(); builder.nextLine(); builder.appendRow(RowSpec.decode("fill:p:g")); builder.append(chartPanel, 3); final JPanel panel = builder.getPanel(); ActionListener listener = e -> { try { Account account = combo.getSelectedAccount(); if (account == null) { return; } updateSubAccountBox(); chartPanel.setChart(createVerticalXYBarChart(account)); panel.validate(); } catch (final Exception ex) { Logger.getLogger(MonthlyAccountBalanceChart.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); } }; combo.addActionListener(listener); hideLockedAccountCheckBox.addActionListener(e -> { combo.setHideLocked(hideLockedAccountCheckBox.isSelected()); try { Account account = combo.getSelectedAccount(); if (account == null) { return; } updateSubAccountBox(); chartPanel.setChart(createVerticalXYBarChart(account)); panel.validate(); } catch (final Exception ex) { Logger.getLogger(MonthlyAccountBalanceChart.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); } }); hidePlaceholderAccountCheckBox.addActionListener(e -> { combo.setHidePlaceholder(hidePlaceholderAccountCheckBox.isSelected()); try { Account account = combo.getSelectedAccount(); if (account == null) { return; } updateSubAccountBox(); chartPanel.setChart(createVerticalXYBarChart(account)); panel.validate(); } catch (final Exception ex) { Logger.getLogger(MonthlyAccountBalanceChart.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); } }); refreshButton.addActionListener(listener); updateSubAccountBox(); return panel; }
From source file:biomine.bmvis2.pipeline.KMedoidsHighlight.java
@Override public JComponent getSettingsComponent(final SettingsChangeCallback v, VisualGraph graph) { Box ret = new Box(BoxLayout.X_AXIS); ret.add(new JLabel("k:")); final JSpinner spin = new JSpinner(new SpinnerNumberModel(3, 1, 1000, 1)); spin.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { setK(((Number) spin.getValue()).intValue()); v.settingsChanged(false);//from www . ja v a2s.com } }); ret.add(spin); final JCheckBox showClustersBox = new JCheckBox("Color clusters"); ret.add(showClustersBox); showClustersBox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { showClusters = showClustersBox.isSelected(); v.settingsChanged(false); } }); return ret; }
From source file:gda.util.userOptions.UserOptionsDialog.java
@SuppressWarnings("rawtypes") private JPanel makePane() { JPanel pane = new JPanel(); pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); Iterator<Map.Entry<String, UserOption>> iter = options.entrySet().iterator(); while (iter.hasNext()) { Map.Entry<String, UserOption> entry = iter.next(); UserOption option = entry.getValue(); if (option.defaultValue instanceof Boolean && option.description instanceof String) { JCheckBox box = new JCheckBox((String) option.description); box.setSelected((Boolean) option.value); box.setAlignmentX(Component.LEFT_ALIGNMENT); box.setAlignmentY(Component.LEFT_ALIGNMENT); components.put(entry.getKey(), box); pane.add(box);/* w w w .j av a 2s .co m*/ } } return pane; }
From source file:net.pms.newgui.GeneralTab.java
public JComponent build() { // Apply the orientation for the locale Locale locale = new Locale(configuration.getLanguage()); ComponentOrientation orientation = ComponentOrientation.getOrientation(locale); String colSpec = FormLayoutUtil.getColSpec(COL_SPEC, orientation); FormLayout layout = new FormLayout(colSpec, ROW_SPEC); PanelBuilder builder = new PanelBuilder(layout); builder.setBorder(Borders.DLU4_BORDER); builder.setOpaque(true);/*from www .j a v a 2 s . c o m*/ CellConstraints cc = new CellConstraints(); smcheckBox = new JCheckBox(Messages.getString("NetworkTab.3")); smcheckBox.setContentAreaFilled(false); smcheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setMinimized((e.getStateChange() == ItemEvent.SELECTED)); } }); if (configuration.isMinimized()) { smcheckBox.setSelected(true); } JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), FormLayoutUtil.flip(cc.xyw(1, 1, 9), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); builder.addLabel(Messages.getString("NetworkTab.0"), FormLayoutUtil.flip(cc.xy(1, 7), colSpec, orientation)); final KeyedComboBoxModel kcbm = new KeyedComboBoxModel( new Object[] { "ar", "bg", "ca", "zhs", "zht", "cz", "da", "nl", "en", "fi", "fr", "de", "el", "iw", "is", "it", "ja", "ko", "no", "pl", "pt", "br", "ro", "ru", "sl", "es", "sv", "tr" }, new Object[] { "Arabic", "Bulgarian", "Catalan", "Chinese (Simplified)", "Chinese (Traditional)", "Czech", "Danish", "Dutch", "English", "Finnish", "French", "German", "Greek", "Hebrew", "Icelandic", "Italian", "Japanese", "Korean", "Norwegian", "Polish", "Portuguese", "Portuguese (Brazilian)", "Romanian", "Russian", "Slovenian", "Spanish", "Swedish", "Turkish" }); langs = new JComboBox(kcbm); langs.setEditable(false); String defaultLang = null; if (configuration.getLanguage() != null && configuration.getLanguage().length() > 0) { defaultLang = configuration.getLanguage(); } else { defaultLang = Locale.getDefault().getLanguage(); } if (defaultLang == null) { defaultLang = "en"; } kcbm.setSelectedKey(defaultLang); if (langs.getSelectedIndex() == -1) { langs.setSelectedIndex(0); } langs.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { configuration.setLanguage((String) kcbm.getSelectedKey()); } } }); builder.add(langs, FormLayoutUtil.flip(cc.xyw(3, 7, 7), colSpec, orientation)); builder.add(smcheckBox, FormLayoutUtil.flip(cc.xyw(1, 9, 9), colSpec, orientation)); JButton service = new JButton(Messages.getString("NetworkTab.4")); service.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (PMS.get().installWin32Service()) { JOptionPane.showMessageDialog( (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())), Messages.getString("NetworkTab.11") + Messages.getString("NetworkTab.12"), Messages.getString("Dialog.Information"), JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog( (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())), Messages.getString("NetworkTab.14"), Messages.getString("Dialog.Error"), JOptionPane.ERROR_MESSAGE); } } }); builder.add(service, FormLayoutUtil.flip(cc.xy(1, 11), colSpec, orientation)); if (System.getProperty(LooksFrame.START_SERVICE) != null || !Platform.isWindows()) { service.setEnabled(false); } JButton checkForUpdates = new JButton(Messages.getString("NetworkTab.8")); checkForUpdates.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { LooksFrame frame = (LooksFrame) PMS.get().getFrame(); frame.checkForUpdates(); } }); builder.add(checkForUpdates, FormLayoutUtil.flip(cc.xy(1, 13), colSpec, orientation)); autoUpdateCheckBox = new JCheckBox(Messages.getString("NetworkTab.9")); autoUpdateCheckBox.setContentAreaFilled(false); autoUpdateCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setAutoUpdate((e.getStateChange() == ItemEvent.SELECTED)); } }); if (configuration.isAutoUpdate()) { autoUpdateCheckBox.setSelected(true); } builder.add(autoUpdateCheckBox, FormLayoutUtil.flip(cc.xyw(7, 13, 3), colSpec, orientation)); if (!Build.isUpdatable()) { checkForUpdates.setEnabled(false); autoUpdateCheckBox.setEnabled(false); } host = new JTextField(configuration.getServerHostname()); host.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { configuration.setHostname(host.getText()); } }); port = new JTextField(configuration.getServerPort() != 5001 ? "" + configuration.getServerPort() : ""); port.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { try { String p = port.getText(); if (StringUtils.isEmpty(p)) { p = "5001"; } int ab = Integer.parseInt(p); configuration.setServerPort(ab); } catch (NumberFormatException nfe) { logger.debug("Could not parse port from \"" + port.getText() + "\""); } } }); cmp = builder.addSeparator(Messages.getString("NetworkTab.22"), FormLayoutUtil.flip(cc.xyw(1, 21, 9), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); final KeyedComboBoxModel networkInterfaces = createNetworkInterfacesModel(); networkinterfacesCBX = new JComboBox(networkInterfaces); networkInterfaces.setSelectedKey(configuration.getNetworkInterface()); networkinterfacesCBX.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { configuration.setNetworkInterface((String) networkInterfaces.getSelectedKey()); } } }); ip_filter = new JTextField(configuration.getIpFilter()); ip_filter.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { configuration.setIpFilter(ip_filter.getText()); } }); maxbitrate = new JTextField(configuration.getMaximumBitrate()); maxbitrate.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { PMS.getConfiguration().setMaximumBitrate(maxbitrate.getText()); } }); builder.addLabel(Messages.getString("NetworkTab.20"), FormLayoutUtil.flip(cc.xy(1, 23), colSpec, orientation)); builder.add(networkinterfacesCBX, FormLayoutUtil.flip(cc.xyw(3, 23, 7), colSpec, orientation)); builder.addLabel(Messages.getString("NetworkTab.23"), FormLayoutUtil.flip(cc.xy(1, 25), colSpec, orientation)); builder.add(host, FormLayoutUtil.flip(cc.xyw(3, 25, 7), colSpec, orientation)); builder.addLabel(Messages.getString("NetworkTab.24"), FormLayoutUtil.flip(cc.xy(1, 27), colSpec, orientation)); builder.add(port, FormLayoutUtil.flip(cc.xyw(3, 27, 7), colSpec, orientation)); builder.addLabel(Messages.getString("NetworkTab.30"), FormLayoutUtil.flip(cc.xy(1, 29), colSpec, orientation)); builder.add(ip_filter, FormLayoutUtil.flip(cc.xyw(3, 29, 7), colSpec, orientation)); builder.addLabel(Messages.getString("NetworkTab.35"), FormLayoutUtil.flip(cc.xy(1, 31), colSpec, orientation)); builder.add(maxbitrate, FormLayoutUtil.flip(cc.xyw(3, 31, 7), colSpec, orientation)); cmp = builder.addSeparator(Messages.getString("NetworkTab.31"), FormLayoutUtil.flip(cc.xyw(1, 33, 9), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); newHTTPEngine = new JCheckBox(Messages.getString("NetworkTab.32")); newHTTPEngine.setSelected(configuration.isHTTPEngineV2()); newHTTPEngine.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setHTTPEngineV2((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(newHTTPEngine, FormLayoutUtil.flip(cc.xyw(1, 35, 9), colSpec, orientation)); preventSleep = new JCheckBox(Messages.getString("NetworkTab.33")); preventSleep.setSelected(configuration.isPreventsSleep()); preventSleep.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setPreventsSleep((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(preventSleep, FormLayoutUtil.flip(cc.xyw(1, 37, 9), colSpec, orientation)); JCheckBox fdCheckBox = new JCheckBox(Messages.getString("NetworkTab.38")); fdCheckBox.setContentAreaFilled(false); fdCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setRendererForceDefault((e.getStateChange() == ItemEvent.SELECTED)); } }); if (configuration.isRendererForceDefault()) { fdCheckBox.setSelected(true); } builder.addLabel(Messages.getString("NetworkTab.36"), FormLayoutUtil.flip(cc.xy(1, 39), colSpec, orientation)); ArrayList<RendererConfiguration> allConfs = RendererConfiguration.getAllRendererConfigurations(); ArrayList<Object> keyValues = new ArrayList<Object>(); ArrayList<Object> nameValues = new ArrayList<Object>(); keyValues.add(""); nameValues.add(Messages.getString("NetworkTab.37")); if (allConfs != null) { for (RendererConfiguration renderer : allConfs) { if (renderer != null) { keyValues.add(renderer.getRendererName()); nameValues.add(renderer.getRendererName()); } } } final KeyedComboBoxModel renderersKcbm = new KeyedComboBoxModel( (Object[]) keyValues.toArray(new Object[keyValues.size()]), (Object[]) nameValues.toArray(new Object[nameValues.size()])); renderers = new JComboBox(renderersKcbm); renderers.setEditable(false); String defaultRenderer = configuration.getRendererDefault(); renderersKcbm.setSelectedKey(defaultRenderer); if (renderers.getSelectedIndex() == -1) { renderers.setSelectedIndex(0); } builder.add(renderers, FormLayoutUtil.flip(cc.xyw(3, 39, 7), colSpec, orientation)); builder.add(fdCheckBox, FormLayoutUtil.flip(cc.xyw(1, 41, 9), colSpec, orientation)); cmp = builder.addSeparator(Messages.getString("NetworkTab.34"), FormLayoutUtil.flip(cc.xyw(1, 43, 9), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); pPlugins = new JPanel(new GridLayout()); builder.add(pPlugins, FormLayoutUtil.flip(cc.xyw(1, 45, 9), colSpec, orientation)); JPanel panel = builder.getPanel(); // Apply the orientation to the panel and all components in it panel.applyComponentOrientation(orientation); JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); return scrollPane; }
From source file:EditorPaneExample18.java
public EditorPaneExample18() { super("JEditorPane Example 18"); pane = new JEditorPane(); pane.setEditable(true); // Editable getContentPane().add(new JScrollPane(pane), "Center"); // Add a menu bar menuBar = new JMenuBar(); setJMenuBar(menuBar);// ww w . j a v a 2 s .co m // Populate it createMenuBar(); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1; c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridy = 3; panel.add(new JLabel(LOAD_TIME), c); c.gridy = 4; c.gridwidth = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; onlineLoad = new JCheckBox("Online Load"); panel.add(onlineLoad, c); onlineLoad.setSelected(true); onlineLoad.setForeground(typeLabel.getForeground()); c.gridy = 5; c.gridwidth = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; editableBox = new JCheckBox("Editable JEditorPane"); panel.add(editableBox, c); editableBox.setSelected(true); editableBox.setForeground(typeLabel.getForeground()); c.gridy = 6; c.weightx = 0.0; JButton saveButton = new JButton("Save"); panel.add(saveButton, c); saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { EditorKit kit = pane.getEditorKit(); try { if (kit instanceof RTFEditorKit) { kit.write(System.out, pane.getDocument(), 0, pane.getDocument().getLength()); System.out.flush(); } else { if (writer == null) { writer = new OutputStreamWriter(System.out); pane.write(writer); writer.flush(); } kit.write(writer, pane.getDocument(), 0, pane.getDocument().getLength()); writer.flush(); } } catch (Exception e) { System.out.println("Write failed"); } } }); c.gridx = 1; c.gridy = 0; c.weightx = 1.0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; urlCombo = new JComboBox(); panel.add(urlCombo, c); urlCombo.setEditable(true); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); timeLabel = new JLabel(""); c.gridy = 3; panel.add(timeLabel, c); getContentPane().add(panel, "South"); // Register a custom EditorKit for HTML ClassLoader loader = getClass().getClassLoader(); if (loader != null) { // Java 2 JEditorPane.registerEditorKitForContentType("text/html", "AdvancedSwing.Chapter4.HiddenViewHTMLEditorKit", loader); } else { // JDK 1.1 JEditorPane.registerEditorKitForContentType("text/html", "AdvancedSwing.Chapter4.HiddenViewHTMLEditorKit"); } // Allocate the empty tree model DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty"); emptyModel = new DefaultTreeModel(emptyRootNode); // Create and place the heading tree tree = new JTree(emptyModel); tree.setPreferredSize(new Dimension(200, 200)); getContentPane().add(new JScrollPane(tree), "East"); // Change page based on combo selection urlCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (populatingCombo == true) { return; } Object selection = urlCombo.getSelectedItem(); loadNewPage(selection); } }); // Change editability based on the checkbox editableBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { pane.setEditable(editableBox.isSelected()); pane.revalidate(); pane.repaint(); } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadComplete(); displayLoadTime(); populateCombo(findLinks(pane.getDocument(), null)); TreeNode node = buildHeadingTree(pane.getDocument()); tree.setModel(new DefaultTreeModel(node)); createMenuBar(); enableMenuBar(true); getRootPane().revalidate(); enableInput(); loadingPage = false; } } }); // Listener for tree selection tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent evt) { TreePath path = evt.getNewLeadSelectionPath(); if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); Object userObject = node.getUserObject(); if (userObject instanceof Heading) { Heading heading = (Heading) userObject; try { Rectangle textRect = pane.modelToView(heading.getOffset()); textRect.y += 3 * textRect.height; pane.scrollRectToVisible(textRect); } catch (BadLocationException e) { } } } } }); // Listener for hypertext events pane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent evt) { // Ignore hyperlink events if the frame is busy if (loadingPage == true) { return; } if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { JEditorPane sp = (JEditorPane) evt.getSource(); if (evt instanceof HTMLFrameHyperlinkEvent) { HTMLDocument doc = (HTMLDocument) sp.getDocument(); doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt); } else { loadNewPage(evt.getURL()); } } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) { pane.setCursor(handCursor); } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) { pane.setCursor(defaultCursor); } } }); }
From source file:de.rub.syssec.saaf.gui.frame.CfgSelectorFrame.java
/** * A frame to generate and open Control Flow Graphs. CFGs are created using mxGraph * and are saved as PNGs.//ww w .ja va 2s.co m * * @param smaliClass the smali class to select methods from */ public CfgSelectorFrame(ClassInterface smaliClass) { super(smaliClass.getFullClassName(true), true, true, true, true); this.smaliClass = smaliClass; listModel = new MethodTableModel(smaliClass); list.setModel(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { int viewRow = list.getSelectedRow(); if (viewRow <= 0) { showButton.setEnabled(false); } else { showButton.setEnabled(true); } } }); JScrollPane listScrollPane = new JScrollPane(list); ActionListener al = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals(SHOW_OPERATION)) { generateAndShowCfg(true); } else if (e.getActionCommand().equals(GENERATE_OPERATION)) { generateAndShowCfg(false); } } }; generateButton = new JButton(GENERATE_OPERATION); generateButton.setActionCommand(GENERATE_OPERATION); generateButton.addActionListener(al); showButton = new JButton(SHOW_OPERATION); showButton.setEnabled(false); showButton.addActionListener(al); saveCfgCheckBox = new JCheckBox("Save a copy"); saveCfgCheckBox.setToolTipText("Save a copy in the configured CFG folder upon generation."); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.add(generateButton); buttonPane.add(saveCfgCheckBox); buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel filler = new JPanel(); filler.setPreferredSize(new Dimension(10, 10)); buttonPane.add(filler); buttonPane.add(showButton); add(listScrollPane, BorderLayout.CENTER); add(buttonPane, BorderLayout.PAGE_END); this.setPreferredSize(new Dimension(500, 250)); this.pack(); this.setVisible(true); }
From source file:mrmc.chart.ROCCurvePlot.java
/** * Sole constructor. Creates a line plot display ROC curves * //from w w w. j a v a 2s . c om * @param title Title of the chart * @param xaxis x-axis label * @param yaxis y-axis label * @param treeMap Mapping of readers to a set of points defining an ROC curve */ public ROCCurvePlot(final String title, String xaxis, String yaxis, TreeMap<String, TreeSet<XYPair>> treeMap) { super(title); createDataset(treeMap); final JFreeChart chart = ChartFactory.createScatterPlot(title, xaxis, yaxis, seriesCollection, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) chart.getPlot(); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); NumberAxis domain = (NumberAxis) xyplot.getDomainAxis(); domain.setRange(0.00, 1.00); domain.setTickUnit(new NumberTickUnit(0.1)); NumberAxis range = (NumberAxis) xyplot.getRangeAxis(); range.setRange(0.00, 1.00); range.setTickUnit(new NumberTickUnit(0.1)); renderer = new XYLineAndShapeRenderer(); chart.getXYPlot().setRenderer(renderer); ChartPanel chartPanel = new ChartPanel(chart); JPanel readerSelect = new JPanel(new WrapLayout()); readerSeriesBoxes = new ArrayList<JCheckBox>(); for (String r : treeMap.keySet()) { JCheckBox aBox = new JCheckBox("" + r); aBox.setSelected(false); aBox.addItemListener(new SeriesSelectListener()); hideSeries("" + r); readerSeriesBoxes.add(aBox); readerSelect.add(aBox); } renderer.setSeriesShapesVisible(seriesCollection.getSeriesIndex("Vertical Average"), false); renderer.setSeriesStroke(seriesCollection.getSeriesIndex("Vertical Average"), new java.awt.BasicStroke(3f)); renderer.setSeriesShapesVisible(seriesCollection.getSeriesIndex("Horizontal Average"), false); renderer.setSeriesStroke(seriesCollection.getSeriesIndex("Horizontal Average"), new java.awt.BasicStroke(3f)); renderer.setSeriesShapesVisible(seriesCollection.getSeriesIndex("Diagonal Average"), false); renderer.setSeriesStroke(seriesCollection.getSeriesIndex("Diagonal Average"), new java.awt.BasicStroke(3f)); renderer.setSeriesStroke(seriesCollection.getSeriesIndex("Pooled Average"), new java.awt.BasicStroke(3f)); vert = new JCheckBox("Vertical Average"); vert.setSelected(true); vert.addItemListener(new SeriesSelectListener()); readerSelect.add(vert); horiz = new JCheckBox("Horizontal Average"); horiz.setSelected(true); horiz.addItemListener(new SeriesSelectListener()); readerSelect.add(horiz); diag = new JCheckBox("Diagonal Average"); diag.setSelected(true); diag.addItemListener(new SeriesSelectListener()); readerSelect.add(diag); pooled = new JCheckBox("Pooled Average"); pooled.setSelected(true); pooled.addItemListener(new SeriesSelectListener()); readerSelect.add(pooled); JCheckBox allReaders = new JCheckBox("Show Readers"); allReaders.setSelected(false); allReaders.addItemListener(new ReadersSelectListener()); readerSelect.add(allReaders); JCheckBox allAverages = new JCheckBox("Show Averages"); allAverages.setSelected(true); allAverages.addItemListener(new AverageSelectListener()); readerSelect.add(allAverages); chartPanel.setPreferredSize(new java.awt.Dimension(700, 700)); this.add(chartPanel); this.add(readerSelect, BorderLayout.PAGE_END); }
From source file:au.org.ala.delta.ui.SearchDialog.java
/** * Create the dialog./*from w w w.j av a 2 s. c om*/ */ public SearchDialog(SearchController controller) { super(UIUtils.getParentFrame(controller.getOwningComponent())); hookInternalFrame(controller.getOwningComponent()); _controller = controller; UIUtils.centerDialog(this, controller.getOwningComponent().getParent()); setTitle(controller.getTitle()); setName(_controller.getTitle()); setBounds(100, 100, 366, 229); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); SingleFrameApplication application = (SingleFrameApplication) Application.getInstance(); ResourceMap messages = application.getContext().getResourceMap(); JLabel lblFind = new JLabel(messages.getString("searchDialog.lblFind")); lblFind.setMinimumSize(new Dimension(30, 0)); textField = new JTextField(); textField.setColumns(10); JPanel panel = new JPanel(); panel.setBorder(new TitledBorder(null, messages.getString("searchDialog.groupDirection"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); buttonGroup = new ButtonGroup(); rdbtnForwards = new JRadioButton(messages.getString("searchDialog.directionForwards")); rdbtnForwards.setSelected(true); buttonGroup.add(rdbtnForwards); rdbtnBackwards = new JRadioButton(messages.getString("searchDialog.directionBackwards")); buttonGroup.add(rdbtnBackwards); contentPanel.setLayout(new MigLayout("", "[growprio 0,grow,left][grow][grow]", "[20px][21px,grow][grow]")); contentPanel.add(lblFind, "cell 0 0,alignx left,aligny top"); contentPanel.add(textField, "cell 1 0 2 1,growx,aligny top"); final JPanel panel_1 = new JPanel(); panel_1.setBorder(new TitledBorder(null, messages.getString("searchDialog.optionsPanelTitle"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); contentPanel.add(panel_1, "cell 0 1 2 1,grow"); panel_1.setLayout(new BoxLayout(panel_1, BoxLayout.Y_AXIS)); chckbxMatchCase = new JCheckBox(messages.getString("searchDialog.lblMatchCase")); panel_1.add(chckbxMatchCase); chckbxWrapSearch = new JCheckBox(messages.getString("searchDialog.lblWrapSearch")); panel_1.add(chckbxWrapSearch); chckbxWrapSearch.setSelected(true); contentPanel.add(panel, "cell 2 1,grow"); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(rdbtnForwards); panel.add(rdbtnBackwards); { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton findButton = new JButton(messages.getString("searchDialog.btnFindNext")); findButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { findNext(); } }); buttonPane.add(findButton); getRootPane().setDefaultButton(findButton); } { JButton cancelButton = new JButton(messages.getString("searchDialog.btnCancel")); buttonPane.add(cancelButton); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }); } } }
From source file:jgnash.ui.report.compiled.IncomeExpensePieChart.java
private JPanel createPanel() { EnumSet<AccountType> set = EnumSet.of(AccountType.INCOME, AccountType.EXPENSE); JButton refreshButton = new JButton(rb.getString("Button.Refresh")); startField = new DatePanel(); endField = new DatePanel(); showEmptyCheck = new JCheckBox(rb.getString("Label.ShowEmptyAccounts")); showPercentCheck = new JCheckBox(rb.getString("Button.ShowPercentValues")); final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT); Objects.requireNonNull(engine); combo = AccountListComboBox.getParentTypeInstance(engine.getRootAccount(), set); final LocalDate dStart = DateUtils.getFirstDayOfTheMonth(LocalDate.now()).minusYears(1); long start = pref.getLong(START_DATE, DateUtils.asEpochMilli(dStart)); startField.setDate(DateUtils.asLocalDate(start)); currentAccount = combo.getSelectedAccount(); JFreeChart chart = createPieChart(currentAccount); chartPanel = new ChartPanel(chart, true, true, true, false, true); // (chart, properties, save, print, zoom, tooltips) FormLayout layout = new FormLayout("p, 4dlu, 70dlu, 8dlu, p, 4dlu, 70dlu, 8dlu, p, 4dlu:g, left:p", "f:d, 3dlu, f:d, 6dlu, f:p:g"); DefaultFormBuilder builder = new DefaultFormBuilder(layout); layout.setRowGroups(new int[][] { { 1, 3 } }); builder.append(combo, 9);//from ww w. ja v a 2s . co m builder.append(showEmptyCheck); builder.nextLine(); builder.nextLine(); builder.append(rb.getString("Label.StartDate"), startField); builder.append(rb.getString("Label.EndDate"), endField); builder.append(refreshButton); builder.append(showPercentCheck); builder.nextLine(); builder.nextLine(); builder.append(chartPanel, 11); JPanel panel = builder.getPanel(); combo.addActionListener(e -> { setCurrentAccount(combo.getSelectedAccount()); pref.putLong(START_DATE, DateUtils.asEpochMilli(startField.getLocalDate())); }); refreshButton.addActionListener(e -> { setCurrentAccount(currentAccount); pref.putLong(START_DATE, DateUtils.asEpochMilli(startField.getLocalDate())); }); showEmptyCheck.addActionListener(e -> setCurrentAccount(currentAccount)); showPercentCheck.addActionListener(e -> ((PiePlot) chartPanel.getChart().getPlot()) .setLabelGenerator(showPercentCheck.isSelected() ? percentLabels : defaultLabels)); ChartMouseListener mouseListener = new ChartMouseListener() { @Override public void chartMouseClicked(final ChartMouseEvent event) { MouseEvent me = event.getTrigger(); if (me.getID() == MouseEvent.MOUSE_CLICKED && me.getClickCount() == 1) { try { ChartEntity entity = event.getEntity(); // expand sections if interesting, back out if in nothing if (entity instanceof PieSectionEntity) { Account a = (Account) ((PieSectionEntity) entity).getSectionKey(); if (a.getChildCount() > 0) { setCurrentAccount(a); } } else if (entity == null) { Account parent = currentAccount; if (parent == null) { return; } parent = parent.getParent(); if (parent == null || parent instanceof RootAccount) { return; } setCurrentAccount(parent); } } catch (final Exception e) { Logger.getLogger(IncomeExpensePieChart.class.getName()).log(Level.SEVERE, e.getLocalizedMessage(), e); } } } @Override public void chartMouseMoved(ChartMouseEvent event) { setChartCursor(chartPanel, event.getEntity(), event.getTrigger().getPoint()); } }; chartPanel.addChartMouseListener(mouseListener); return panel; }
From source file:org.pmedv.jake.app.PlayerView.java
private JPanel createTopPanel() { JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); buttonPanel.setBackground(Colors.LIGHT_GRAY); ImageIcon playIcon = resources.getIcon("icon.play"); ImageIcon stopIcon = resources.getIcon("icon.stop"); ImageIcon nextIcon = resources.getIcon("icon.next"); ImageIcon prevIcon = resources.getIcon("icon.last"); prevButton = new CmdJButton(prevIcon, "Plays the previous song", null); nextButton = new CmdJButton(nextIcon, "Plays the next song", null); startButton = new CmdJButton(playIcon, "Starts playing", null); stopButton = new CmdJButton(stopIcon, "Stops playing", null); buttonPanel.add(startButton);/*from w w w .j av a 2s . c om*/ buttonPanel.add(stopButton); buttonPanel.add(prevButton); buttonPanel.add(nextButton); buttonPanel.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0), BorderFactory.createLineBorder(Color.LIGHT_GRAY))); timeField = new JTextField(5); timeField.setEditable(false); timeField.setBackground(Colors.SOFT_BLUE_ICE); titleField = new JMarqueeTextField(30); titleField.setEditable(false); titleField.setBackground(Colors.SOFT_BLUE_ICE); buttonPanel.add(timeField); buttonPanel.add(titleField); randomBox = new JCheckBox("R"); buttonPanel.add(randomBox); return buttonPanel; }