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(Action a) 

Source Link

Document

Creates a check box where properties are taken from the Action supplied.

Usage

From source file:gdt.jgui.tool.JTextEncrypter.java

/**
 * The default constructor./*  ww w  .  ja va2  s.  co m*/
 */
public JTextEncrypter() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    JPanel panel = new JPanel();
    panel.setBorder(
            new TitledBorder(null, "Master password", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panel);
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
    JCheckBox chckbxNewCheckBox = new JCheckBox("Show");
    chckbxNewCheckBox.setHorizontalTextPosition(SwingConstants.LEFT);
    chckbxNewCheckBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() != ItemEvent.SELECTED) {
                passwordField.setEchoChar('*');
            } else {
                passwordField.setEchoChar((char) 0);
            }
        }
    });
    panel.add(chckbxNewCheckBox);
    panel.setFocusTraversalPolicy(
            new FocusTraversalOnArray(new Component[] { chckbxNewCheckBox, passwordField }));
    passwordField = new JPasswordField();
    passwordField.setMaximumSize(new Dimension(Integer.MAX_VALUE, passwordField.getPreferredSize().height));
    panel.add(passwordField);

    JPanel panel_1 = new JPanel();
    panel_1.setBorder(new TitledBorder(null, "Text", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panel_1);
    panel_1.setLayout(new BorderLayout(0, 0));

    textArea = new JTextArea();
    textArea.setColumns(1);
    panel_1.add(textArea);

}

From source file:CheckBoxDemo.java

public CheckBoxDemo() {
    super(new BorderLayout());

    // Create the check boxes.
    chinButton = new JCheckBox("Chin");
    chinButton.setMnemonic(KeyEvent.VK_C);
    chinButton.setSelected(true);// w w w. j a  v a2 s . co m

    glassesButton = new JCheckBox("Glasses");
    glassesButton.setMnemonic(KeyEvent.VK_G);
    glassesButton.setSelected(true);

    hairButton = new JCheckBox("Hair");
    hairButton.setMnemonic(KeyEvent.VK_H);
    hairButton.setSelected(true);

    teethButton = new JCheckBox("Teeth");
    teethButton.setMnemonic(KeyEvent.VK_T);
    teethButton.setSelected(true);

    // Register a listener for the check boxes.
    chinButton.addItemListener(this);
    glassesButton.addItemListener(this);
    hairButton.addItemListener(this);
    teethButton.addItemListener(this);

    // Indicates what's on the geek.
    choices = new StringBuffer("cght");

    // Set up the picture label
    pictureLabel = new JLabel();
    pictureLabel.setFont(pictureLabel.getFont().deriveFont(Font.ITALIC));
    updatePicture();

    // Put the check boxes in a column in a panel
    JPanel checkPanel = new JPanel(new GridLayout(0, 1));
    checkPanel.add(chinButton);
    checkPanel.add(glassesButton);
    checkPanel.add(hairButton);
    checkPanel.add(teethButton);

    add(checkPanel, BorderLayout.LINE_START);
    add(pictureLabel, BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:com.mirth.connect.client.ui.ExportChannelLibrariesDialog.java

private void initComponents(Channel channel) {
    label1 = new JLabel("   The following code template libraries are linked to this channel:");
    label1.setIcon(UIManager.getIcon("OptionPane.questionIcon"));

    librariesTextPane = new JTextPane();
    librariesTextPane.setContentType("text/html");
    HTMLEditorKit editorKit = new HTMLEditorKit();
    StyleSheet styleSheet = editorKit.getStyleSheet();
    styleSheet.addRule(".export-channel-libraries-dialog {font-family:\"Tahoma\";font-size:11;text-align:top}");
    librariesTextPane.setEditorKit(editorKit);
    librariesTextPane.setEditable(false);
    librariesTextPane.setBackground(getBackground());
    librariesTextPane.setBorder(null);/*from w ww  .j  a  v  a 2 s .co  m*/

    StringBuilder librariesText = new StringBuilder("<html><ul class=\"export-channel-libraries-dialog\">");
    for (CodeTemplateLibrary library : PlatformUI.MIRTH_FRAME.codeTemplatePanel.getCachedCodeTemplateLibraries()
            .values()) {
        if (library.getEnabledChannelIds().contains(channel.getId()) || (library.isIncludeNewChannels()
                && !library.getDisabledChannelIds().contains(channel.getId()))) {
            librariesText.append("<li>").append(StringEscapeUtils.escapeHtml4(library.getName()))
                    .append("</li>");
        }
    }
    librariesText.append("</ul></html>");
    librariesTextPane.setText(librariesText.toString());
    librariesTextPane.setCaretPosition(0);

    librariesScrollPane = new JScrollPane(librariesTextPane);

    label2 = new JLabel("Do you wish to include these libraries in the channel export?");

    alwaysChooseCheckBox = new JCheckBox(
            "Always choose this option by default in the future (may be changed in the Administrator settings)");

    yesButton = new JButton("Yes");
    yesButton.setMnemonic('Y');
    yesButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            result = JOptionPane.YES_OPTION;
            if (alwaysChooseCheckBox.isSelected()) {
                Preferences.userNodeForPackage(Mirth.class).putBoolean("exportChannelCodeTemplateLibraries",
                        true);
            }
            dispose();
        }
    });

    noButton = new JButton("No");
    noButton.setMnemonic('N');
    noButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            result = JOptionPane.NO_OPTION;
            if (alwaysChooseCheckBox.isSelected()) {
                Preferences.userNodeForPackage(Mirth.class).putBoolean("exportChannelCodeTemplateLibraries",
                        false);
            }
            dispose();
        }
    });

    cancelButton = new JButton("Cancel");
    cancelButton.setMnemonic('C');
    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            result = JOptionPane.CANCEL_OPTION;
            dispose();
        }
    });
}

From source file:com.netblizzard.jfreechart.MouseZoomDemo.java

/**
 * A demonstration of mouse zooming.//from  w ww .ja  v a 2  s .c  o m
 *
 * @param title  the frame title.
 */
public MouseZoomDemo(String title) {

    super(title);
    SampleXYDataset data = new SampleXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("Mouse Zoom Demo", "X", "Y", data,
            PlotOrientation.VERTICAL, true, true, false);

    this.chartPanel = new ChartPanel(chart);
    this.chartPanel.setHorizontalAxisTrace(false);
    //        this.chartPanel.setVerticalTraceLine(false);
    this.chartPanel.setHorizontalAxisTrace(false);
    this.chartPanel.setVerticalAxisTrace(false);
    this.chartPanel.setFillZoomRectangle(true);
    this.chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    JPanel main = new JPanel(new BorderLayout());
    JPanel checkpanel = new JPanel();
    this.xzoom = new JCheckBox("Horizontal Mouse Zooming");
    this.xzoom.setSelected(false);
    this.yzoom = new JCheckBox("Vertical Mouse Zooming");
    this.yzoom.setSelected(false);
    CheckListener clisten = new CheckListener();
    this.xzoom.addItemListener(clisten);
    this.yzoom.addItemListener(clisten);
    checkpanel.add(this.xzoom);
    checkpanel.add(this.yzoom);
    main.add(checkpanel, BorderLayout.SOUTH);
    main.add(this.chartPanel);
    setContentPane(main);

}

From source file:TapTapTap.java

private JPanel createPanel() {
    JPanel p = new JPanel();

    ButtonGroup entreeGroup = new ButtonGroup();
    JRadioButton radioButton;//from   ww w .jav a 2 s. c  o  m
    p.add(radioButton = new JRadioButton("Beef", true));
    entreeGroup.add(radioButton);
    p.add(radioButton = new JRadioButton("Chicken"));
    entreeGroup.add(radioButton);
    p.add(radioButton = new JRadioButton("Vegetable"));
    entreeGroup.add(radioButton);

    p.add(new JCheckBox("Ketchup"));
    p.add(new JCheckBox("Mustard"));
    p.add(new JCheckBox("Pickles"));

    p.add(new JLabel("Special requests:"));
    p.add(new JTextField(20));

    mOrderButton = new JButton("Place Order");
    p.add(mOrderButton);

    return p;
}

From source file:de.codesourcery.jasm16.ide.ui.utils.UIUtils.java

/**
 * // w  w  w  . j  a v a2  s. com
 * @param parent
 * @param title
 * @param message
 * @return <code>true</code> if project should also be physically deleted,
 * <code>false</code> is project should be deleted but all files should be left alone,
 * <code>null</code> if user cancelled the dialog/project should not be deleted
 */
public static Boolean showDeleteProjectDialog(IAssemblyProject project) {
    final JDialog dialog = new JDialog((Window) null, "Delete project " + project.getName());

    dialog.setModal(true);

    final JTextArea message = createMultiLineLabel(
            "Do you really want to delete project '" + project.getName() + " ?");
    final JCheckBox checkbox = new JCheckBox("Delete project files");

    final DialogResult[] outcome = { DialogResult.CANCEL };

    final JButton yesButton = new JButton("Yes");
    yesButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            outcome[0] = DialogResult.YES;
            dialog.dispose();
        }
    });

    final JButton noButton = new JButton("No");
    noButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            outcome[0] = DialogResult.NO;
            dialog.dispose();
        }
    });
    final JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            outcome[0] = DialogResult.CANCEL;
            dialog.dispose();
        }
    });

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout());
    buttonPanel.add(yesButton);
    buttonPanel.add(noButton);
    buttonPanel.add(cancelButton);

    final JPanel messagePanel = new JPanel();
    messagePanel.setLayout(new GridBagLayout());

    GridBagConstraints cnstrs = constraints(0, 0, true, false, GridBagConstraints.NONE);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;
    cnstrs.gridheight = 1;
    messagePanel.add(message, cnstrs);

    cnstrs = constraints(0, 1, true, true, GridBagConstraints.NONE);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridheight = 1;
    cnstrs.weighty = 0;
    messagePanel.add(checkbox, cnstrs);

    final JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());

    cnstrs = constraints(0, 0, true, false, GridBagConstraints.NONE);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridheight = 1;
    cnstrs.weighty = 0;
    cnstrs.insets = new Insets(5, 2, 5, 2); // top,left,bottom,right         
    panel.add(messagePanel, cnstrs);

    cnstrs = constraints(0, 1, true, true, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridheight = 1;
    cnstrs.weighty = 0;
    cnstrs.insets = new Insets(0, 2, 10, 2); // top,left,bottom,right      
    panel.add(buttonPanel, cnstrs);

    dialog.getContentPane().add(panel);
    dialog.pack();
    dialog.setVisible(true);

    if (outcome[0] != DialogResult.YES) {
        return null;
    }
    return checkbox.isSelected();
}

From source file:net.pms.newgui.NetworkTab.java

public JComponent build() {
    FormLayout layout = new FormLayout("left:pref, 2dlu, p, 2dlu , p, 2dlu, p, 2dlu, pref:grow",
            "p, 0dlu, p, 0dlu, p, 3dlu, p, 3dlu, p, 3dlu,p, 3dlu, p, 15dlu, p, 3dlu,p, 3dlu, p,  3dlu, p, 3dlu, p, 3dlu, p,3dlu, p, 3dlu, p, 15dlu, p,3dlu, p, 3dlu, p, 15dlu, p, 3dlu, p");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.DLU4_BORDER);
    builder.setOpaque(true);//  w  ww . j  a  va 2s  .c  om

    CellConstraints cc = new CellConstraints();

    smcheckBox = new JCheckBox(Messages.getString("NetworkTab.3"));
    smcheckBox.setContentAreaFilled(false);
    smcheckBox.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            PMS.getConfiguration().setMinimized((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    if (PMS.getConfiguration().isMinimized()) {
        smcheckBox.setSelected(true);
    }

    JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), cc.xyw(1, 1, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(Messages.getString("NetworkTab.0"), cc.xy(1, 7));
    final KeyedComboBoxModel kcbm = new KeyedComboBoxModel(
            new Object[] { "bg", "ca", "zhs", "zht", "cz", "da", "nl", "en", "fi", "fr", "de", "el", "is", "it",
                    "ja", "no", "pl", "pt", "br", "ro", "ru", "sl", "es", "sv" },
            new Object[] { "Bulgarian", "Catalan", "Chinese (Simplified)", "Chinese (Traditional)", "Czech",
                    "Danish", "Dutch", "English", "Finnish", "French", "German", "Greek", "Icelandic",
                    "Italian", "Japanese", "Norwegian", "Polish", "Portuguese", "Portuguese (Brazilian)",
                    "Romanian", "Russian", "Slovenian", "Spanish", "Swedish" });
    langs = new JComboBox(kcbm);
    langs.setEditable(false);
    //langs.setSelectedIndex(0);
    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, cc.xyw(3, 7, 7));

    builder.add(smcheckBox, cc.xyw(1, 9, 9));

    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"),
                        "Information", JOptionPane.INFORMATION_MESSAGE);

            } else {
                JOptionPane.showMessageDialog(
                        (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                        Messages.getString("NetworkTab.14"), "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    builder.add(service, cc.xy(1, 11));
    if (System.getProperty(LooksFrame.START_SERVICE) != null || !Platform.isWindows()) {
        service.setEnabled(false);
    }

    host = new JTextField(PMS.getConfiguration().getServerHostname());
    host.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setHostname(host.getText());
            PMS.get().getFrame().setReloadable(true);
        }
    });
    // host.setEnabled( StringUtils.isBlank(configuration.getNetworkInterface())) ;
    port = new JTextField(configuration.getServerPort() != 5001 ? "" + configuration.getServerPort() : "");
    port.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

        @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);
                PMS.get().getFrame().setReloadable(true);
            } catch (NumberFormatException nfe) {
            }

        }
    });

    cmp = builder.addSeparator(Messages.getString("NetworkTab.22"), cc.xyw(1, 21, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    ArrayList<String> names = new ArrayList<String>();
    names.add("");
    ArrayList<String> interfaces = new ArrayList<String>();
    interfaces.add("");
    Enumeration<NetworkInterface> enm;
    try {
        enm = NetworkInterface.getNetworkInterfaces();
        while (enm.hasMoreElements()) {
            NetworkInterface ni = enm.nextElement();
            // check for interface has at least one ip address.
            if (ni.getInetAddresses().hasMoreElements()) {
                names.add(ni.getName());
                String displayName = ni.getDisplayName();
                if (displayName == null) {
                    displayName = ni.getName();
                }
                interfaces.add(displayName.trim());
            }
        }
    } catch (SocketException e1) {
        logger.error(null, e1);
    }

    final KeyedComboBoxModel networkInterfaces = new KeyedComboBoxModel(names.toArray(), interfaces.toArray());
    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());
                //host.setEnabled( StringUtils.isBlank(configuration.getNetworkInterface())) ;
                PMS.get().getFrame().setReloadable(true);
            }
        }
    });

    ip_filter = new JTextField(PMS.getConfiguration().getIpFilter());
    ip_filter.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setIpFilter(ip_filter.getText());
            PMS.get().getFrame().setReloadable(true);
        }
    });

    builder.addLabel(Messages.getString("NetworkTab.20"), cc.xy(1, 23));
    builder.add(networkinterfacesCBX, cc.xyw(3, 23, 7));
    builder.addLabel(Messages.getString("NetworkTab.23"), cc.xy(1, 25));
    builder.add(host, cc.xyw(3, 25, 7));
    builder.addLabel(Messages.getString("NetworkTab.24"), cc.xy(1, 27));
    builder.add(port, cc.xyw(3, 27, 7));
    builder.addLabel(Messages.getString("NetworkTab.30"), cc.xy(1, 29));
    builder.add(ip_filter, cc.xyw(3, 29, 7));

    cmp = builder.addSeparator(Messages.getString("NetworkTab.31"), cc.xyw(1, 31, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    newHTTPEngine = new JCheckBox(Messages.getString("NetworkTab.32"));
    newHTTPEngine.setSelected(PMS.getConfiguration().isHTTPEngineV2());
    newHTTPEngine.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            PMS.getConfiguration().setHTTPEngineV2((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(newHTTPEngine, cc.xyw(1, 33, 9));

    preventSleep = new JCheckBox(Messages.getString("NetworkTab.33"));
    preventSleep.setSelected(PMS.getConfiguration().isPreventsSleep());
    preventSleep.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            PMS.getConfiguration().setPreventsSleep((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(preventSleep, cc.xyw(1, 35, 9));

    cmp = builder.addSeparator(Messages.getString("NetworkTab.34"), cc.xyw(1, 37, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    JPanel panel = builder.getPanel();
    JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    return scrollPane;
}

From source file:lu.lippmann.cdb.datasetview.tabs.WeightedMapOfDecisionTreesTabView.java

/**
 * Constructor.//w  ww . j  av  a2  s  .  com
 */
public WeightedMapOfDecisionTreesTabView(final EventPublisher eventPublisher,
        final CommandDispatcher commandDispatcher, final ApplicationContext applicationContext) {
    super();

    this.applicationContext = applicationContext;
    this.commandDispatcher = commandDispatcher;
    this.eventPublisher = eventPublisher;

    final double defaultValueConfidenceFactor = DecisionTreeHelper.HIGH_CONFIDENCE_FACTOR;
    this.dtFactory = new J48DecisionTreeFactory(defaultValueConfidenceFactor, false);
    this.panel = new JXPanel();
    this.panel.setLayout(new BorderLayout());

    this.slider = new JSlider();
    this.slider.setBorder(new TitledBorder("Confidence factor"));
    this.slider.setOpaque(false);
    this.slider.setMaximum((int) (defaultValueConfidenceFactor * 100));
    this.slider.setValue((int) (defaultValueConfidenceFactor * 100));
    this.slider.setMinimum(1);
    this.slider.setMinorTickSpacing(1);
    this.slider.setMajorTickSpacing(10);
    this.slider.setPaintTicks(true);
    this.slider.setPaintLabels(true);
    this.panel.add(this.slider, BorderLayout.SOUTH);

    this.attrSelectionCombo = new JComboBox();
    this.attrSelectionCombo.setBorder(new TitledBorder("Attribute used to split"));

    final JXPanel cmdPanel = new JXPanel();
    cmdPanel.setLayout(new BorderLayout());
    cmdPanel.add(this.attrSelectionCombo, BorderLayout.CENTER);
    this.withWeightCheckBox = new JCheckBox("Weighted");
    this.withWeightCheckBox.setBorder(new TitledBorder("With weight"));
    cmdPanel.add(this.withWeightCheckBox, BorderLayout.EAST);
    this.panel.add(cmdPanel, BorderLayout.NORTH);
}

From source file:org.jfree.chart.demo.MouseZoomDemo.java

/**
 * A demonstration of mouse zooming./* w ww  .  ja v  a2  s .c  o m*/
 *
 * @param title  the frame title.
 */
public MouseZoomDemo(final String title) {

    super(title);
    final SampleXYDataset data = new SampleXYDataset();
    final JFreeChart chart = ChartFactory.createXYLineChart("Mouse Zoom Demo", "X", "Y", data,
            PlotOrientation.VERTICAL, true, true, false);

    this.chartPanel = new ChartPanel(chart);
    //        this.chartPanel.setHorizontalZoom(false);
    //      this.chartPanel.setVerticalZoom(false);
    this.chartPanel.setHorizontalAxisTrace(false);
    this.chartPanel.setVerticalAxisTrace(false);
    this.chartPanel.setFillZoomRectangle(true);
    this.chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    final JPanel main = new JPanel(new BorderLayout());
    final JPanel checkpanel = new JPanel();
    this.xzoom = new JCheckBox("Horizontal Mouse Zooming");
    this.xzoom.setSelected(false);
    this.yzoom = new JCheckBox("Vertical Mouse Zooming");
    this.yzoom.setSelected(false);
    final CheckListener clisten = new CheckListener();
    this.xzoom.addItemListener(clisten);
    this.yzoom.addItemListener(clisten);
    checkpanel.add(this.xzoom);
    checkpanel.add(this.yzoom);
    main.add(checkpanel, BorderLayout.SOUTH);
    main.add(this.chartPanel);
    setContentPane(main);

}

From source file:components.TableSelectionDemo.java

private JCheckBox addCheckBox(String text) {
    JCheckBox checkBox = new JCheckBox(text);
    checkBox.addActionListener(this);
    add(checkBox);/*from w  ww  .  j ava 2  s.  c o  m*/
    return checkBox;
}