Example usage for javax.swing JCheckBox JCheckBox

List of usage examples for javax.swing JCheckBox JCheckBox

Introduction

In this page you can find the example usage for javax.swing JCheckBox JCheckBox.

Prototype

public JCheckBox(String text, Icon icon) 

Source Link

Document

Creates an initially unselected check box with the specified text and icon.

Usage

From source file:org.cds06.speleograph.graph.GraphEditor.java

/**
 * Creates a modal dialog by specifying the attached {@link GraphPanel}.
 * <p>Please look at {@link javax.swing.JDialog#JDialog()} to see defaults params applied to this Dialog.</p>
 *//*from   w w w . ja  va 2s . c  o  m*/
public GraphEditor(GraphPanel panel) {
    super((Frame) SwingUtilities.windowForComponent(panel), true);
    Validate.notNull(panel);
    this.graphPanel = panel;

    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    mainPanel.registerKeyboardAction(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
        }
    }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

    setContentPane(mainPanel);
    mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    this.setTitle(I18nSupport.translate("menus.graph.graphEditor"));

    {
        // This section use FormLayout which is an external layout for Java, consult the doc before edit the
        // following lines !
        final FormLayout layout = new FormLayout(
                "right:max(40dlu;p), 4dlu, p:grow, 4dlu, p, 4dlu, p:grow, 4dlu, p", //NON-NLS
                "p,4dlu,p,4dlu,p,4dlu,p,4dlu,p" //NON-NLS
        );

        PanelBuilder builder = new PanelBuilder(layout);

        final JLabel colorLabel = new JLabel();
        final JTextField titleForGraph = new JTextField(
                graphPanel.getChart().getTitle() != null ? graphPanel.getChart().getTitle().getText() : "");
        final JLabel colorXYPlotLabel = new JLabel();
        final JLabel colorGridLabel = new JLabel();
        final JCheckBox showLegendCheckBox = new JCheckBox("Afficher la lgende",
                graphPanel.getChart().getLegend().isVisible());

        {
            builder.addLabel("Titre :", "1,1");
            builder.add(titleForGraph, "3,1,7,1");
        }

        {
            builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.backgroundColor"), "1,3");
            colorLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
            colorLabel.setText(" ");
            colorLabel.setBackground((Color) graphPanel.getChart().getBackgroundPaint());
            colorLabel.setOpaque(true);
            colorLabel.setEnabled(false);
            final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit"));
            edit.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    Color c = JColorChooser.showDialog(GraphEditor.this,
                            I18nSupport.translate("menus.graph.graphEditor.selectColor"),
                            colorLabel.getBackground());
                    if (c != null) {
                        colorLabel.setBackground(c);
                    }
                }
            });
            builder.add(colorLabel, "3,3,5,1");
            builder.add(edit, "9,3");
        }

        final XYPlot xyPlot = graphPanel.getChart().getXYPlot();
        {
            builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.graphColor"), "1,5");
            colorXYPlotLabel.setText(" ");
            colorXYPlotLabel.setOpaque(true);
            colorXYPlotLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
            colorXYPlotLabel.setBackground((Color) xyPlot.getBackgroundPaint());
            colorXYPlotLabel.setEnabled(false);
            final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit"));
            edit.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    Color c = JColorChooser.showDialog(GraphEditor.this,
                            I18nSupport.translate("menus.graph.graphEditor.selectColor"),
                            colorXYPlotLabel.getBackground());
                    if (c != null) {
                        colorXYPlotLabel.setBackground(c);
                    }
                }
            });
            builder.add(colorXYPlotLabel, "3,5,5,1");
            builder.add(edit, "9,5");
        }

        {
            builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.gridColor"), "1,7");
            colorGridLabel.setOpaque(true);
            colorGridLabel.setText(" ");
            colorGridLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
            colorGridLabel.setBackground((Color) xyPlot.getRangeGridlinePaint());
            colorGridLabel.setEnabled(false);
            final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit"));
            edit.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    Color c = JColorChooser.showDialog(GraphEditor.this,
                            I18nSupport.translate("menus.graph.graphEditor.selectColor"),
                            colorGridLabel.getBackground());
                    if (c != null) {
                        colorGridLabel.setBackground(c);
                    }
                }
            });
            builder.add(colorGridLabel, "3,7,5,1");
            builder.add(edit, "9,7");
        }

        {
            builder.add(showLegendCheckBox, "1,9,9,1");
        }

        mainPanel.add(builder.build(), BorderLayout.CENTER);

        ButtonBarBuilder buttonBarBuilder = new ButtonBarBuilder();

        buttonBarBuilder.addGlue();

        buttonBarBuilder.addButton(new AbstractAction() {
            {
                putValue(NAME, I18nSupport.translate("cancel"));
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                GraphEditor.this.setVisible(false);
            }
        });

        buttonBarBuilder.addButton(new AbstractAction() {

            {
                putValue(NAME, I18nSupport.translate("ok"));
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                if (titleForGraph.getText().isEmpty())
                    graphPanel.getChart().setTitle((String) null);
                else
                    graphPanel.getChart().setTitle(titleForGraph.getText());
                {
                    Color c = colorGridLabel.getBackground();
                    xyPlot.setRangeGridlinePaint(c);
                    xyPlot.setRangeMinorGridlinePaint(c);
                    xyPlot.setDomainGridlinePaint(c);
                    xyPlot.setDomainMinorGridlinePaint(c);
                }
                graphPanel.getChart().setBackgroundPaint(colorLabel.getBackground());
                xyPlot.setBackgroundPaint(colorXYPlotLabel.getBackground());
                graphPanel.getChart().getLegend().setVisible(showLegendCheckBox.isSelected());
                GraphEditor.this.setVisible(false);
            }
        });

        mainPanel.add(buttonBarBuilder.build(), BorderLayout.SOUTH);
    }

    pack();
    Dimension d = this.getPreferredSize();
    this.setSize(new Dimension(d.width + 20, d.height));
    setResizable(false);
}

From source file:misc.TablePrintDemo1.java

/**
 * Constructs an instance of the demo.// w w w. jav  a2  s. co  m
 */
public TablePrintDemo1() {
    super("Table Printing Demo 1");

    gradesLabel = new JLabel("Final Grades - CSC 101");
    gradesLabel.setFont(new Font("Dialog", Font.BOLD, 16));

    gradesTable = createTable(new GradesModel());
    gradesTable.setFillsViewportHeight(true);
    gradesTable.setRowHeight(24);

    /* Set a custom renderer on the "Passed" column */
    gradesTable.getColumn("Passed").setCellRenderer(createPassedColumnRenderer());

    scroll = new JScrollPane(gradesTable);

    String tooltipText;

    tooltipText = "Include a page header";
    headerBox = new JCheckBox("Header:", true);
    headerBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            headerField.setEnabled(headerBox.isSelected());
        }
    });
    headerBox.setToolTipText(tooltipText);
    tooltipText = "Page Header (Use {0} to include page number)";
    headerField = new JTextField("Final Grades - CSC 101");
    headerField.setToolTipText(tooltipText);

    tooltipText = "Include a page footer";
    footerBox = new JCheckBox("Footer:", true);
    footerBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            footerField.setEnabled(footerBox.isSelected());
        }
    });
    footerBox.setToolTipText(tooltipText);
    tooltipText = "Page Footer (Use {0} to Include Page Number)";
    footerField = new JTextField("Page {0}");
    footerField.setToolTipText(tooltipText);

    tooltipText = "Show the Print Dialog Before Printing";
    showPrintDialogBox = new JCheckBox("Show print dialog", true);
    showPrintDialogBox.setToolTipText(tooltipText);
    showPrintDialogBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (!showPrintDialogBox.isSelected()) {
                JOptionPane.showMessageDialog(TablePrintDemo1.this,
                        "If the Print Dialog is not shown," + " the default printer is used.",
                        "Printing Message", JOptionPane.INFORMATION_MESSAGE);
            }
        }
    });

    tooltipText = "Keep the GUI Responsive and Show a Status Dialog During Printing";
    interactiveBox = new JCheckBox("Interactive (Show status dialog)", true);
    interactiveBox.setToolTipText(tooltipText);
    interactiveBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (!interactiveBox.isSelected()) {
                JOptionPane.showMessageDialog(TablePrintDemo1.this,
                        "If non-interactive, the GUI is fully blocked" + " during printing.",
                        "Printing Message", JOptionPane.INFORMATION_MESSAGE);
            }
        }
    });

    tooltipText = "Shrink the Table to Fit the Entire Width on a Page";
    fitWidthBox = new JCheckBox("Fit width to printed page", true);
    fitWidthBox.setToolTipText(tooltipText);

    tooltipText = "Print the Table";
    printButton = new JButton("Print");
    printButton.setToolTipText(tooltipText);

    printButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            printGradesTable();
        }
    });

    contentPane = new JPanel();
    addComponentsToContentPane();
    setContentPane(contentPane);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(700, 600);
    setLocationRelativeTo(null);
}

From source file:fedroot.dacs.swingdemo.DacsClientFrame.java

/**
 * //w w w  .  j  av a  2s  .  c o m
 * @param dacsClientContext
 * @param feduri 
 * @throws java.lang.Exception 
 */
public DacsClientFrame(DacsClientContext dacsClientContext, Federation federation) throws Exception {
    logger.log(Level.INFO, "Federation {0}", federation.getFederationName());

    this.federation = federation;
    this.dacsClientContext = dacsClientContext;
    //        this.dacsClientContext.setDacs902EventHandler(federation, new Event902Handler(this));
    //        this.dacsClientContext.setDacs905EventHandler(federation, new Event905Handler(this));

    JPanel mainPanel = new JPanel(new BorderLayout());
    JPanel gotoUrlPanel = new JPanel(new FlowLayout());
    JPanel actionPanel = new JPanel(new FlowLayout());
    JPanel modifiersPanel = new JPanel(new FlowLayout());

    /** Enable/Disable DACS Check_only mode */
    checkOnlyCheckBox = new JCheckBox("Enable DACS Check Only", false);
    checkOnlyCheckBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            if (checkOnlyCheckBox.isSelected()) {
                enableEventHandlingCheckBox.setSelected(false);
                enableEventHandlingCheckBox.setEnabled(false);
            } else {
                enableEventHandlingCheckBox.setEnabled(true);
            }
        }
    });

    /** Enable/Disable Event Handling */
    enableEventHandlingCheckBox = new JCheckBox("Enable Event Handling", false);

    final JButton btnGOTO = new JButton("Goto URL");
    btnGOTO.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            try {
                followUrl(new URI(urlTextField.getText().trim()));
            } catch (URISyntaxException ex) {
                // TODO implement popup for error messages
            }
        }
    });

    final JButton btnGO = new JButton("GO");
    btnGO.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            try {
                followUrl(new URI(actionUrls[actionsComboBox.getSelectedIndex()]));
            } catch (URISyntaxException ex) {
                // TODO implement popup for error messages
            }
        }
    });

    final JButton btnUSERNAMES = new JButton("Usernames");
    btnUSERNAMES.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            createAndShowDacsUsernameFrame();
        }
    });

    final JButton btnLOGIN = new JButton("Login");
    btnLOGIN.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            createAndShowLoginFrame();
        }
    });

    final JButton btnNAT = new JButton("NATs");
    btnNAT.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            createAndShowDacsNatFrame();
        }
    });

    Container container = this.getContentPane();

    actionsComboBox = new JComboBox(actions);
    actionsComboBox.setToolTipText("Select an Action");
    actionsComboBox.setEditable(true);
    actionsComboBox.setSelectedIndex(0);

    JLabel actionLabel = new JLabel("Action:");

    urlTextField = new TextField(70);
    urlTextField.setEditable(true);

    gotoUrlPanel.add(urlTextField);
    gotoUrlPanel.add(btnGOTO);

    actionPanel.add(actionLabel);
    actionPanel.add(actionsComboBox);
    actionPanel.add(btnGO);
    actionPanel.add(btnLOGIN);
    actionPanel.add(btnUSERNAMES);
    actionPanel.add(btnNAT);

    mainPanel.add(gotoUrlPanel, BorderLayout.NORTH);
    mainPanel.add(actionPanel, BorderLayout.SOUTH);

    modifiersPanel.add(checkOnlyCheckBox);
    modifiersPanel.add(enableEventHandlingCheckBox);

    JSplitPane splitInputPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, mainPanel, modifiersPanel);

    splitInputPane.setOneTouchExpandable(false);

    responseTextArea = new JTextArea();
    responseTextArea.setEditable(false);
    responseTextArea.setCaretPosition(0);

    htmlPane = new JEditorPane();
    // htmlPane.setContentType("image/png");
    htmlPane.setEditable(false);

    JSplitPane splitResponsePane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(responseTextArea),
            new JScrollPane(htmlPane));
    splitResponsePane.setOneTouchExpandable(false);
    splitResponsePane.setResizeWeight(0.35);

    container.setLayout(new BorderLayout());
    container.add(splitInputPane, BorderLayout.NORTH);
    container.add(splitResponsePane, BorderLayout.CENTER);
}

From source file:com.emental.mindraider.ui.dialogs.AddTripletJDialog.java

/**
 * Constructor.//from   w w  w . ja v  a  2 s.c  om
 */
public AddTripletJDialog() {
    super("Add Triplet");

    JPanel framePanel = new JPanel();
    framePanel.setLayout(new GridLayout(4, 1));

    JPanel p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.RIGHT));
    p.add(new JLabel(" Predicate: "));

    predicateNs = new JTextField(30);
    predicateNs.setText(MindRaiderConstants.MR_RDF_PREDICATE_NS);
    predicateNs.selectAll();
    p.add(predicateNs);
    p.add(new JLabel("#"));
    predicateLocalName = new JTextField(15);
    p.add(predicateLocalName);
    framePanel.add(p);

    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.RIGHT));
    p.add(new JLabel(" Object: "));

    objectNs = new JTextField(30);
    objectNs.setText(MindRaiderConstants.MR_RDF_PREDICATE_NS);
    objectNs.selectAll();
    p.add(objectNs);
    p.add(new JLabel("#"));
    objectLocalName = new JTextField(15);
    objectLocalName.grabFocus();
    objectLocalName.selectAll();
    objectLocalName.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent keyEvent) {
            if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) {
                createTriplet();
            }
        }

        public void keyReleased(KeyEvent keyEvent) {
        }

        public void keyTyped(KeyEvent keyEvent) {
        }
    });

    p.add(objectLocalName);
    framePanel.add(p);

    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.RIGHT));
    literalCheckBox = new JCheckBox("literal", false);
    p.add(literalCheckBox);
    framePanel.add(p);

    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.CENTER));
    JButton addButton = new JButton("Add");
    p.add(addButton);
    addButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            createTriplet();
        }
    });

    JButton cancelButton = new JButton("Cancel");
    p.add(cancelButton);
    cancelButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            AddTripletJDialog.this.dispose();
        }
    });
    framePanel.add(p);

    getContentPane().add(framePanel, BorderLayout.CENTER);

    // show
    pack();
    Gfx.centerAndShowWindow(this);

    addWindowListener(new WindowAdapter() {

        public void windowActivated(WindowEvent e) {
            getObjectLocalName().requestFocusInWindow();
        }
    });
}

From source file:fedroot.dacs.swingdemo.DemoFrame.java

/**
 * /*from  w w  w  .  ja  v  a 2 s  . co m*/
 * @param dacsClientContext
 * @param feduri 
 * @throws java.lang.Exception 
 */
public DemoFrame(DacsClientContext dacsClientContext, Federation federation) throws Exception {
    logger.log(Level.INFO, "Federation {0}", federation.getFederationName());

    this.federation = federation;
    this.dacsClientContext = dacsClientContext;
    //        this.dacsClientContext.setDacs902EventHandler(federation, new Event902Handler(this));
    //        this.dacsClientContext.setDacs905EventHandler(federation, new Event905Handler(this));

    JPanel mainPanel = new JPanel(new BorderLayout());
    JPanel gotoUrlPanel = new JPanel(new FlowLayout());
    JPanel actionPanel = new JPanel(new FlowLayout());
    JPanel modifiersPanel = new JPanel(new FlowLayout());

    /** Enable/Disable DACS Check_only mode */
    checkOnlyCheckBox = new JCheckBox("Enable DACS Check Only", false);
    checkOnlyCheckBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            if (checkOnlyCheckBox.isSelected()) {
                enableEventHandlingCheckBox.setSelected(false);
                enableEventHandlingCheckBox.setEnabled(false);
            } else {
                enableEventHandlingCheckBox.setEnabled(true);
            }
        }
    });

    /** Enable/Disable Event Handling */
    enableEventHandlingCheckBox = new JCheckBox("Enable Event Handling", false);

    final JButton btnGOTO = new JButton("Goto URL");
    btnGOTO.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            try {
                followUrl(new URI(urlTextField.getText().trim()));
            } catch (URISyntaxException ex) {
                // TODO implement popup for error messages
            }
        }
    });

    final JButton btnGO = new JButton("GO");
    btnGO.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            try {
                followUrl(new URI(actionUrls[actionsComboBox.getSelectedIndex()]));
            } catch (URISyntaxException ex) {
                // TODO implement popup for error messages
            }
        }
    });

    final JButton btnUSERNAMES = new JButton("Usernames");
    btnUSERNAMES.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            createAndShowDacsUsernameFrame();
        }
    });

    final JButton btnLOGIN = new JButton("Login");
    btnLOGIN.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            createAndShowLoginFrame();
        }
    });

    final JButton btnNAT = new JButton("NATs");
    btnNAT.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            createAndShowDacsNatFrame();
        }
    });

    Container container = this.getContentPane();

    actionsComboBox = new JComboBox(actions);
    actionsComboBox.setToolTipText("Select an Action");
    actionsComboBox.setEditable(true);
    actionsComboBox.setSelectedIndex(0);

    JLabel actionLabel = new JLabel("Action:");

    urlTextField = new TextField(70);
    urlTextField.setEditable(true);

    gotoUrlPanel.add(urlTextField);
    gotoUrlPanel.add(btnGOTO);

    actionPanel.add(actionLabel);
    actionPanel.add(actionsComboBox);
    actionPanel.add(btnGO);
    actionPanel.add(btnLOGIN);
    actionPanel.add(btnUSERNAMES);
    actionPanel.add(btnNAT);

    mainPanel.add(gotoUrlPanel, BorderLayout.NORTH);
    mainPanel.add(actionPanel, BorderLayout.SOUTH);

    modifiersPanel.add(checkOnlyCheckBox);
    modifiersPanel.add(enableEventHandlingCheckBox);

    JSplitPane splitInputPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, mainPanel, modifiersPanel);

    splitInputPane.setOneTouchExpandable(false);

    responseTextArea = new JTextArea();
    responseTextArea.setEditable(false);
    responseTextArea.setCaretPosition(0);

    htmlPane = new JEditorPane();
    // htmlPane.setContentType("image/png");
    htmlPane.setEditable(false);

    JSplitPane splitResponsePane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(responseTextArea),
            new JScrollPane(htmlPane));
    splitResponsePane.setOneTouchExpandable(false);
    splitResponsePane.setResizeWeight(0.35);

    container.setLayout(new BorderLayout());
    container.add(splitInputPane, BorderLayout.NORTH);
    container.add(splitResponsePane, BorderLayout.CENTER);
}

From source file:org.esa.beam.smos.visat.GridPointBtDataChartToolView.java

@Override
protected JComponent createGridPointComponentOptionsComponent() {
    modeCheckers = new JCheckBox[] { new JCheckBox("X", true), new JCheckBox("Y", true),
            new JCheckBox("XY", true), };
    final JPanel optionsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 2));
    for (JCheckBox modeChecker : modeCheckers) {
        modeChecker.addActionListener(new ActionListener() {
            @Override// www  . j  a v a 2 s.  c  o m
            public void actionPerformed(ActionEvent e) {
                updateGridPointBtDataComponent();
            }
        });
        optionsPanel.add(modeChecker);
    }
    return optionsPanel;
}

From source file:be.ac.ua.comp.scarletnebula.gui.keywizards.AbstractFinalKeyWizardPage.java

protected AbstractFinalKeyWizardPage(final CloudProvider provider, final String toptext,
        final String checkKeyname) {
    super(new BorderLayout());
    final BetterTextLabel toptextLabel = new BetterTextLabel(toptext);
    toptextLabel.setBorder(BorderFactory.createEmptyBorder(20, 20, 0, 20));

    makeDefault = new JCheckBox("Make this the default keypair.", true);

    if (KeyManager.getKeyNames(provider.getName()).isEmpty() || provider.getDefaultKeypair().isEmpty()) {
        makeDefault.setEnabled(false);//  w  w w  .  j ava2s . co  m
    }
    makeDefault.setBorder(BorderFactory.createEmptyBorder(0, 20, 10, 20));

    keyValidityMessage.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20));
    add(keyValidityMessage, BorderLayout.CENTER);
    add(makeDefault, BorderLayout.SOUTH);

    final JPanel textAndThrobber = new JPanel(new BorderLayout());

    textAndThrobber.add(toptextLabel, BorderLayout.NORTH);
    if (!checkKeyname.isEmpty()) {
        final ThrobberBarWithText throbber = new ThrobberBarWithText("Verifying key uniqueness...");
        final CollapsablePanel throbberPanel = new CollapsablePanel(throbber, false);
        throbberPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
        final SwingWorkerWithThrobber<Boolean, String> checkKeyWorker = new TestKeyExistsWorker(throbberPanel,
                checkKeyname, provider);
        checkKeyWorker.addPropertyChangeListener(new SetWarningMessagePropertyListener(checkKeyWorker));
        checkKeyWorker.execute();
        textAndThrobber.add(throbberPanel, BorderLayout.SOUTH);
    }

    add(textAndThrobber, BorderLayout.NORTH);
}

From source file:org.uncommons.watchmaker.swing.evolutionmonitor.IslandsView.java

/**
 * Creates the GUI controls for toggling graph display options.
 * @return A component that can be added to the main panel.
 *///  w ww  .ja  v  a 2  s .  co m
private JComponent createControls() {
    JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    final JCheckBox meanCheckBox = new JCheckBox("Show Mean and Standard Deviation", false);
    meanCheckBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent itemEvent) {
            chart.setNotify(false);
            CategoryPlot plot = (CategoryPlot) chart.getPlot();
            if (itemEvent.getStateChange() == ItemEvent.SELECTED) {
                plot.setDataset(1, meanDataSet);
                plot.setRenderer(1, meanRenderer);
            } else {
                plot.setDataset(1, null);
                plot.setRenderer(1, null);
            }
            chart.setNotify(true);
        }
    });
    controls.add(meanCheckBox);

    return controls;
}

From source file:org.uncommons.watchmaker.swing.evolutionmonitor.PopulationFitnessView.java

/**
 * Creates the GUI controls for toggling graph display options.
 * @return A component that can be added to the main panel.
 *//* w w w. ja  v a  2 s. c  o m*/
private JComponent createControls(boolean islands) {
    JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    allDataButton.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ev) {
            updateDomainAxisRange();
        }
    });
    String text = "Last " + SHOW_FIXED_GENERATIONS + (islands ? " Epochs" : " Generations");
    JRadioButton recentDataButton = new JRadioButton(text, true);
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(allDataButton);
    buttonGroup.add(recentDataButton);

    controls.add(allDataButton);
    controls.add(recentDataButton);

    final JCheckBox meanCheckBox = new JCheckBox("Show Mean", true);
    meanCheckBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent itemEvent) {
            if (itemEvent.getStateChange() == ItemEvent.SELECTED) {
                dataSet.addSeries(meanSeries);
            } else {
                dataSet.removeSeries(meanSeries);
            }
        }
    });
    controls.add(meanCheckBox);

    invertCheckBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent itemEvent) {
            rangeAxis.setInverted(invertCheckBox.isSelected());
        }
    });
    controls.add(invertCheckBox);

    return controls;
}

From source file:projects.upc.exec.HrDiagram.java

/**
 * Main constructor./*from  w  w w  .  j a v  a 2  s .  co  m*/
 */
public HrDiagram() {

    List<UpcStar> upcStars = UpcUtils.loadUpcCatalogue();
    List<UpcStar> hipStars = UpcUtils.getHipparcosSubset(upcStars);
    List<UpcStar> unmatchedStars = UpcUtils.getUnmatchedSubset(upcStars);

    upcStarCrossMatches = XmUtil.getUpcStarCrossMatchMap(upcStars);
    hipStarCrossMatches = XmUtil.getUpcStarCrossMatchMap(hipStars);
    unmatchedStarCrossMatches = XmUtil.getUpcStarCrossMatchMap(unmatchedStars);

    logger.info("Loaded " + upcStarCrossMatches.size() + " UpcStars with SSA cross matches");
    logger.info("Loaded " + hipStarCrossMatches.size() + " UpcStars with Hipparcos and SSA cross matches");
    logger.info("Loaded " + unmatchedStarCrossMatches.size()
            + " UpcStars with no parallax cross-match, and with SSA cross matches");

    starsToPlot = upcStarCrossMatches;

    useHip = false;
    method = METHOD.NAIVE;
    fMax = 1.0;

    final JCheckBox plotAllCheckBox = new JCheckBox("Plot all UPC stars: ", true);
    plotAllCheckBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (plotAllCheckBox.isSelected()) {
                starsToPlot = upcStarCrossMatches;
                updateChart();
            }
        }
    });

    final JCheckBox plotHipCheckBox = new JCheckBox("Plot Hipparcos stars only: ", false);
    plotHipCheckBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (plotHipCheckBox.isSelected()) {
                starsToPlot = hipStarCrossMatches;
                updateChart();
            }
        }
    });

    final JCheckBox plotUnmatchedCheckBox = new JCheckBox("Plot all stars with no external match: ", false);
    plotUnmatchedCheckBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (plotUnmatchedCheckBox.isSelected()) {
                starsToPlot = unmatchedStarCrossMatches;
                updateChart();
            }
        }
    });

    final ButtonGroup bg = new ButtonGroup();
    bg.add(plotHipCheckBox);
    bg.add(plotAllCheckBox);
    bg.add(plotUnmatchedCheckBox);

    JCheckBox useHipCheckBox = new JCheckBox("Use Hipparcos parallaxes when available", useHip);
    useHipCheckBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            useHip = !useHip;
            updateChart();
        }
    });

    final JComboBox<METHOD> methodComboBox = new JComboBox<METHOD>(METHOD.values());
    methodComboBox.setSelectedItem(method);
    methodComboBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            method = (METHOD) methodComboBox.getSelectedItem();
            updateChart();
        }
    });

    final JSlider fSlider = GuiUtil.buildSlider(0.0, 2.0, 5, "%3.3f");
    fSlider.setValue((int) Math.rint(100.0 * fMax));
    final JLabel fLabel = new JLabel(getFLabel());
    // Create a change listener fot these
    ChangeListener cl = new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();

            if (source == fSlider) {
                // Compute fractional parallax error from slider position
                double newF = (2.0 * source.getValue() / 100.0);
                fMax = newF;
                fLabel.setText(getFLabel());
            }
            updateChart();
        }
    };
    fSlider.addChangeListener(cl);
    // Add a bit of padding to space things out
    fSlider.setBorder(new EmptyBorder(5, 5, 5, 5));

    // Present controls below the HR diagram
    JPanel controls = new JPanel(new GridLayout(3, 3));
    controls.add(plotAllCheckBox);
    controls.add(plotHipCheckBox);
    controls.add(plotUnmatchedCheckBox);
    controls.add(new JLabel("Distance estimation method:"));
    controls.add(methodComboBox);
    controls.add(useHipCheckBox);
    controls.add(fLabel);
    controls.add(fSlider);

    // Initialise the ChartPanel
    updateChart();

    // Build the panel contents
    setLayout(new BorderLayout());
    add(chartPanel, BorderLayout.CENTER);
    add(controls, BorderLayout.SOUTH);
}