Search in sources :

Example 46 with JCheckBox

use of javax.swing.JCheckBox in project pcgen by PCGen.

the class DisplayOptionsPanel method addDisplayOption.

private int addDisplayOption(final int line, final GridBagConstraints constraints, final GridBagLayout gridbag, final JPanel panel, final String labelText, final JComponent c) {
    if (c instanceof JCheckBox) {
        final JCheckBox checkbox = (JCheckBox) c;
        checkbox.setText(labelText);
        Utility.buildConstraints(constraints, 0, line, GridBagConstraints.REMAINDER, 1, 0, 0);
    } else {
        final JLabel label = new JLabel(labelText);
        Utility.buildConstraints(constraints, 0, line, 1, 1, 0, 0);
        panel.add(label, constraints);
        Utility.buildConstraints(constraints, 1, line, GridBagConstraints.REMAINDER, 1, 0, 0);
    }
    panel.add(c, constraints);
    return line + 1;
}
Also used : JCheckBox(javax.swing.JCheckBox) JLabel(javax.swing.JLabel)

Example 47 with JCheckBox

use of javax.swing.JCheckBox in project pcgen by PCGen.

the class ExportDialog method maybeOpenFile.

private void maybeOpenFile(File file) {
    UIPropertyContext context = UIPropertyContext.getInstance();
    String value = context.getProperty(UIPropertyContext.ALWAYS_OPEN_EXPORT_FILE);
    Boolean openFile = StringUtils.isEmpty(value) ? null : Boolean.valueOf(value);
    if (openFile == null) {
        JCheckBox checkbox = new JCheckBox();
        checkbox.setText("Always perform this action");
        JPanel message = PCGenFrame.buildMessageLabelPanel("Do you want to open " + file.getName() + "?", checkbox);
        int ret = JOptionPane.showConfirmDialog(this, message, "Select an Option", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (ret == JOptionPane.CLOSED_OPTION) {
            return;
        }
        openFile = BooleanUtils.toBoolean(ret, JOptionPane.YES_OPTION, JOptionPane.NO_OPTION);
        if (checkbox.isSelected()) {
            context.setBoolean(UIPropertyContext.ALWAYS_OPEN_EXPORT_FILE, openFile);
        }
    }
    if (!openFile) {
        return;
    }
    if (!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Desktop.Action.OPEN)) {
        pcgenFrame.showErrorMessage("Cannot Open " + file.getName(), "Operating System does not support this operation");
        return;
    }
    try {
        Desktop.getDesktop().open(file);
    } catch (IOException ex) {
        String message = "Failed to open " + file.getName();
        pcgenFrame.showErrorMessage(Constants.APPLICATION_NAME, message);
        Logging.errorPrint(message, ex);
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) IOException(java.io.IOException) UIPropertyContext(pcgen.gui2.UIPropertyContext)

Example 48 with JCheckBox

use of javax.swing.JCheckBox in project pcgen by PCGen.

the class TipOfTheDay method initUI.

//
// initialize the dialog
//
private void initUI() {
    final JPanel panel = new JPanel(new BorderLayout(2, 2));
    panel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    JLabel iconLabel;
    final Icon icon = Icons.TipOfTheDay24.getImageIcon();
    iconLabel = icon != null ? new JLabel(icon) : new JLabel("TipOfTheDay24.gif");
    iconLabel.setOpaque(true);
    panel.add(iconLabel, BorderLayout.WEST);
    final JLabel lblDidYouKnow = new JLabel("    " + LanguageBundle.getString("in_tod_didyouknow"));
    FontManipulation.xxlarge(lblDidYouKnow);
    lblDidYouKnow.setOpaque(true);
    tipText = new JLabelPane();
    tipText.setBorder(null);
    tipText.setFocusable(false);
    tipText.addHyperlinkListener(new Hyperactive());
    final JScrollPane pane = new JScrollPane(tipText);
    pane.setBorder(null);
    final JPanel content = new JPanel(new BorderLayout(0, 2));
    content.add(lblDidYouKnow, BorderLayout.NORTH);
    content.add(pane, BorderLayout.CENTER);
    content.setPreferredSize(new Dimension(585, 230));
    panel.add(content, BorderLayout.CENTER);
    chkShowTips = new JCheckBox(LanguageBundle.getString("in_tod_showTips"), propertyContext.initBoolean("showTipOfTheDay", true));
    final JButton btnClose = new JButton(LanguageBundle.getString("in_close"));
    btnClose.setMnemonic(LanguageBundle.getMnemonic("in_mn_close"));
    btnClose.addActionListener(this);
    // TODO give focus to close button
    final JButton btnPrevTip = new JButton(LanguageBundle.getString("in_tod_prevTip"));
    btnPrevTip.setMnemonic(LanguageBundle.getMnemonic("in_mn_tod_prevTip"));
    btnPrevTip.addActionListener(this);
    btnPrevTip.setActionCommand(PREV);
    final JButton btnNextTip = new JButton(LanguageBundle.getString("in_tod_nextTip"));
    btnNextTip.setMnemonic(LanguageBundle.getMnemonic("in_mn_tod_nextTip"));
    btnNextTip.addActionListener(this);
    btnNextTip.setActionCommand(NEXT);
    final JPanel actions = new JPanel(new GridBagLayout());
    final GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 0, 0);
    actions.add(chkShowTips, c);
    final JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    buttons.add(btnPrevTip);
    buttons.add(btnNextTip);
    buttons.add(btnClose);
    c.gridx = 1;
    c.anchor = GridBagConstraints.EAST;
    actions.add(buttons, c);
    panel.add(actions, BorderLayout.SOUTH);
    setContentPane(panel);
    getRootPane().setDefaultButton(btnClose);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            quit();
        }
    });
    addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                quit();
            }
        }
    });
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JLabelPane(pcgen.gui2.util.JLabelPane) Insets(java.awt.Insets) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) KeyAdapter(java.awt.event.KeyAdapter) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) JCheckBox(javax.swing.JCheckBox) KeyEvent(java.awt.event.KeyEvent) BorderLayout(java.awt.BorderLayout) Hyperactive(pcgen.gui2.tools.Hyperactive) WindowEvent(java.awt.event.WindowEvent) Icon(javax.swing.Icon)

Example 49 with JCheckBox

use of javax.swing.JCheckBox in project voltdb by VoltDB.

the class FontDialogSwing method creatFontDialog.

/**
     * Create and display FontDialogSwing Dialog.
     *
     */
public static void creatFontDialog(DatabaseManagerSwing owner) {
    if (isRunning) {
        frame.setVisible(true);
    } else {
        CommonSwing.setSwingLAF(frame, CommonSwing.Native);
        fOwner = owner;
        frame.setIconImage(CommonSwing.getIcon("Frame"));
        isRunning = true;
        frame.setSize(600, 100);
        CommonSwing.setFramePositon(frame);
        ckbitalic = new JCheckBox(new ImageIcon(CommonSwing.getIcon("ItalicFont")));
        ckbitalic.putClientProperty("is3DEnabled", Boolean.TRUE);
        ckbitalic.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                setStyle();
            }
        });
        ckbbold = new JCheckBox(new ImageIcon(CommonSwing.getIcon("BoldFont")));
        ckbbold.putClientProperty("is3DEnabled", Boolean.TRUE);
        ckbbold.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                setStyle();
            }
        });
        fgColorButton = new JButton("Foreground", new ImageIcon(CommonSwing.getIcon("ColorSelection")));
        fgColorButton.putClientProperty("is3DEnabled", Boolean.TRUE);
        fgColorButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                setColor(FOREGROUND);
            }
        });
        bgColorButton = new JButton("Background", new ImageIcon(CommonSwing.getIcon("ColorSelection")));
        bgColorButton.putClientProperty("is3DEnabled", Boolean.TRUE);
        bgColorButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                setColor(BACKGROUND);
            }
        });
        closeButton = new JButton("Close", new ImageIcon(CommonSwing.getIcon("Close")));
        closeButton.putClientProperty("is3DEnabled", Boolean.TRUE);
        closeButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                frame.setVisible(false);
            }
        });
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        String[] fontNames = ge.getAvailableFontFamilyNames();
        Dimension fontsComboBoxDimension = new Dimension(160, 25);
        fontsComboBox = new JComboBox(fontNames);
        fontsComboBox.putClientProperty("is3DEnabled", Boolean.TRUE);
        fontsComboBox.setMaximumSize(fontsComboBoxDimension);
        fontsComboBox.setPreferredSize(fontsComboBoxDimension);
        fontsComboBox.setMaximumSize(fontsComboBoxDimension);
        fontsComboBox.setEditable(false);
        fontsComboBox.setSelectedItem(defaultFont);
        fontsComboBox.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                setFont();
            }
        });
        // weconsultants@users 20050215 - Added for Compatbilty fix for  JDK 1.3
        fontSizesComboBox = new JComboBox(fontSizes);
        Dimension spinnerDimension = new Dimension(45, 25);
        fontSizesComboBox.putClientProperty("is3DEnabled", Boolean.TRUE);
        fontSizesComboBox.setMinimumSize(spinnerDimension);
        fontSizesComboBox.setPreferredSize(spinnerDimension);
        fontSizesComboBox.setMaximumSize(spinnerDimension);
        fontSizesComboBox.addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent evt) {
                if (evt.getStateChange() == ItemEvent.SELECTED) {
                    setFontSize((String) evt.getItem());
                }
            }
        });
        // weconsultants@users 20050215 - Commented out for Compatbilty fix for  JDK 1.3
        //            Dimension spinnerDimension = new Dimension(50, 25);
        //            spinnerFontSizes = new JSpinner();
        //            spinnerFontSizes.putClientProperty("is3DEnabled", Boolean.TRUE);
        //            spinnerFontSizes.setMinimumSize(spinnerDimension);
        //            spinnerFontSizes.setPreferredSize(spinnerDimension);
        //            spinnerFontSizes.setMaximumSize(spinnerDimension);
        //            spinnerModelSizes = new SpinnerNumberModel(12, 8, 72, 1);
        //            spinnerFontSizes.setModel(spinnerModelSizes);
        //            spinnerFontSizes.addChangeListener(new ChangeListener() {
        //                public void stateChanged(ChangeEvent e) {
        //                    setFontSize();
        //                }
        //            });
        Container contentPane = frame.getContentPane();
        contentPane.setLayout(new FlowLayout());
        contentPane.add(fontsComboBox);
        // weconsultants@users 20050215 - Commented out for Compatbilty fix for 1.3
        // contentPane.add(spinnerFontSizes);
        // weconsultants@users 20050215 - Added for Compatbilty fix for 1.3
        contentPane.add(fontSizesComboBox);
        contentPane.add(ckbbold);
        contentPane.add(ckbitalic);
        contentPane.add(fgColorButton);
        contentPane.add(bgColorButton);
        contentPane.add(closeButton);
        frame.pack();
        frame.setVisible(false);
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) ItemEvent(java.awt.event.ItemEvent) FlowLayout(java.awt.FlowLayout) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) GraphicsEnvironment(java.awt.GraphicsEnvironment) JCheckBox(javax.swing.JCheckBox) Container(java.awt.Container) ActionListener(java.awt.event.ActionListener) ItemListener(java.awt.event.ItemListener)

Example 50 with JCheckBox

use of javax.swing.JCheckBox in project pcgen by PCGen.

the class PreferencesInitiativePanel method initComponents.

private void initComponents() {
    setLayout(new BorderLayout());
    mainPanel = new JPanel();
    rollPCInitiatives = new JCheckBox();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    performancePanel = new JPanel();
    performancePanel.setLayout(new BoxLayout(performancePanel, BoxLayout.Y_AXIS));
    rollPCInitiatives.setText(//$NON-NLS-1$
    LanguageBundle.getString("in_plugin_initiative_rollPcInit"));
    performancePanel.add(rollPCInitiatives);
    mainPanel.add(performancePanel);
    JScrollPane jScrollPane1 = new JScrollPane();
    jScrollPane1.setViewportView(mainPanel);
    add(jScrollPane1, BorderLayout.CENTER);
}
Also used : JCheckBox(javax.swing.JCheckBox) JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) BoxLayout(javax.swing.BoxLayout)

Aggregations

JCheckBox (javax.swing.JCheckBox)491 JPanel (javax.swing.JPanel)199 JLabel (javax.swing.JLabel)155 JButton (javax.swing.JButton)108 ActionEvent (java.awt.event.ActionEvent)98 ActionListener (java.awt.event.ActionListener)93 JTextField (javax.swing.JTextField)88 GridBagConstraints (java.awt.GridBagConstraints)82 GridBagLayout (java.awt.GridBagLayout)77 Insets (java.awt.Insets)66 BorderLayout (java.awt.BorderLayout)63 Dimension (java.awt.Dimension)59 BoxLayout (javax.swing.BoxLayout)56 JScrollPane (javax.swing.JScrollPane)38 ItemEvent (java.awt.event.ItemEvent)37 ItemListener (java.awt.event.ItemListener)34 FlowLayout (java.awt.FlowLayout)33 JComboBox (javax.swing.JComboBox)33 JRadioButton (javax.swing.JRadioButton)32 Box (javax.swing.Box)30