Example usage for javax.swing JRadioButton JRadioButton

List of usage examples for javax.swing JRadioButton JRadioButton

Introduction

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

Prototype

public JRadioButton(String text) 

Source Link

Document

Creates an unselected radio button with the specified text.

Usage

From source file:EdgeLabelDemo.java

/**
 * create an instance of a simple graph with controls to
 * demo the label positioning features/*ww  w  .  j  a va  2 s.com*/
 * 
 */
@SuppressWarnings("serial")
public EdgeLabelDemo() {

    // create a simple graph for the demo
    graph = new SparseMultigraph<Integer, Number>();
    Integer[] v = createVertices(3);
    createEdges(v);

    Layout<Integer, Number> layout = new CircleLayout<Integer, Number>(graph);
    vv = new VisualizationViewer<Integer, Number>(layout, new Dimension(600, 400));
    vv.setBackground(Color.white);

    vertexLabelRenderer = vv.getRenderContext().getVertexLabelRenderer();
    edgeLabelRenderer = vv.getRenderContext().getEdgeLabelRenderer();

    Transformer<Number, String> stringer = new Transformer<Number, String>() {
        public String transform(Number e) {
            return "Edge:" + graph.getEndpoints(e).toString();
        }
    };
    vv.getRenderContext().setEdgeLabelTransformer(stringer);
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan));
    vv.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.red, Color.yellow));
    // add my listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<Integer>());

    // create a frome to hold the graph
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    Container content = getContentPane();
    content.add(panel);

    final DefaultModalGraphMouse<Integer, Number> graphMouse = new DefaultModalGraphMouse<Integer, Number>();
    vv.setGraphMouse(graphMouse);

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    ButtonGroup radio = new ButtonGroup();
    JRadioButton lineButton = new JRadioButton("Line");
    lineButton.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<Integer, Number>());
                vv.repaint();
            }
        }
    });

    JRadioButton quadButton = new JRadioButton("QuadCurve");
    quadButton.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<Integer, Number>());
                vv.repaint();
            }
        }
    });

    JRadioButton cubicButton = new JRadioButton("CubicCurve");
    cubicButton.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<Integer, Number>());
                vv.repaint();
            }
        }
    });
    radio.add(lineButton);
    radio.add(quadButton);
    radio.add(cubicButton);

    graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    JCheckBox rotate = new JCheckBox("<html><center>EdgeType<p>Parallel</center></html>");
    rotate.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            AbstractButton b = (AbstractButton) e.getSource();
            edgeLabelRenderer.setRotateEdgeLabels(b.isSelected());
            vv.repaint();
        }
    });
    rotate.setSelected(true);
    MutableDirectionalEdgeValue mv = new MutableDirectionalEdgeValue(.5, .7);
    vv.getRenderContext().setEdgeLabelClosenessTransformer(mv);
    JSlider directedSlider = new JSlider(mv.getDirectedModel()) {
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            d.width /= 2;
            return d;
        }
    };
    JSlider undirectedSlider = new JSlider(mv.getUndirectedModel()) {
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            d.width /= 2;
            return d;
        }
    };

    JSlider edgeOffsetSlider = new JSlider(0, 50) {
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            d.width /= 2;
            return d;
        }
    };
    edgeOffsetSlider.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            JSlider s = (JSlider) e.getSource();
            AbstractEdgeShapeTransformer<Integer, Number> aesf = (AbstractEdgeShapeTransformer<Integer, Number>) vv
                    .getRenderContext().getEdgeShapeTransformer();
            aesf.setControlOffsetIncrement(s.getValue());
            vv.repaint();
        }

    });

    Box controls = Box.createHorizontalBox();

    JPanel zoomPanel = new JPanel(new GridLayout(0, 1));
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Scale"));
    zoomPanel.add(plus);
    zoomPanel.add(minus);

    JPanel edgePanel = new JPanel(new GridLayout(0, 1));
    edgePanel.setBorder(BorderFactory.createTitledBorder("EdgeType Type"));
    edgePanel.add(lineButton);
    edgePanel.add(quadButton);
    edgePanel.add(cubicButton);

    JPanel rotatePanel = new JPanel();
    rotatePanel.setBorder(BorderFactory.createTitledBorder("Alignment"));
    rotatePanel.add(rotate);

    JPanel labelPanel = new JPanel(new BorderLayout());
    JPanel sliderPanel = new JPanel(new GridLayout(3, 1));
    JPanel sliderLabelPanel = new JPanel(new GridLayout(3, 1));
    JPanel offsetPanel = new JPanel(new BorderLayout());
    offsetPanel.setBorder(BorderFactory.createTitledBorder("Offset"));
    sliderPanel.add(directedSlider);
    sliderPanel.add(undirectedSlider);
    sliderPanel.add(edgeOffsetSlider);
    sliderLabelPanel.add(new JLabel("Directed", JLabel.RIGHT));
    sliderLabelPanel.add(new JLabel("Undirected", JLabel.RIGHT));
    sliderLabelPanel.add(new JLabel("Edges", JLabel.RIGHT));
    offsetPanel.add(sliderLabelPanel, BorderLayout.WEST);
    offsetPanel.add(sliderPanel);
    labelPanel.add(offsetPanel);
    labelPanel.add(rotatePanel, BorderLayout.WEST);

    JPanel modePanel = new JPanel(new GridLayout(2, 1));
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(graphMouse.getModeComboBox());

    controls.add(zoomPanel);
    controls.add(edgePanel);
    controls.add(labelPanel);
    controls.add(modePanel);
    content.add(controls, BorderLayout.SOUTH);
    quadButton.setSelected(true);
}

From source file:net.lmxm.ute.gui.editors.tasks.SubversionExportTaskEditorPanel.java

/**
 * Gets the head revision radio button./*ww  w. j  a  v  a2  s. com*/
 * 
 * @return the head revision radio button
 */
private JRadioButton getHeadRevisionRadioButton() {
    if (headRevisionRadioButton == null) {
        headRevisionRadioButton = new JRadioButton(SubversionRevision.HEAD.toString());
        headRevisionRadioButton.addActionListener(revisionActionListener);
    }

    return headRevisionRadioButton;
}

From source file:DialogDemo.java

/** Creates the panel shown by the first tab. */
private JPanel createSimpleDialogBox() {
    final int numButtons = 4;
    JRadioButton[] radioButtons = new JRadioButton[numButtons];
    final ButtonGroup group = new ButtonGroup();

    JButton showItButton = null;/*from   ww w .  j  a  va  2 s.  c  o m*/

    final String defaultMessageCommand = "default";
    final String yesNoCommand = "yesno";
    final String yeahNahCommand = "yeahnah";
    final String yncCommand = "ync";

    radioButtons[0] = new JRadioButton("OK (in the L&F's words)");
    radioButtons[0].setActionCommand(defaultMessageCommand);

    radioButtons[1] = new JRadioButton("Yes/No (in the L&F's words)");
    radioButtons[1].setActionCommand(yesNoCommand);

    radioButtons[2] = new JRadioButton("Yes/No " + "(in the programmer's words)");
    radioButtons[2].setActionCommand(yeahNahCommand);

    radioButtons[3] = new JRadioButton("Yes/No/Cancel " + "(in the programmer's words)");
    radioButtons[3].setActionCommand(yncCommand);

    for (int i = 0; i < numButtons; i++) {
        group.add(radioButtons[i]);
    }
    radioButtons[0].setSelected(true);

    showItButton = new JButton("Show it!");
    showItButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String command = group.getSelection().getActionCommand();

            // ok dialog
            if (command == defaultMessageCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.");

                // yes/no dialog
            } else if (command == yesNoCommand) {
                int n = JOptionPane.showConfirmDialog(frame, "Would you like green eggs and ham?",
                        "An Inane Question", JOptionPane.YES_NO_OPTION);
                if (n == JOptionPane.YES_OPTION) {
                    setLabel("Ewww!");
                } else if (n == JOptionPane.NO_OPTION) {
                    setLabel("Me neither!");
                } else {
                    setLabel("Come on -- tell me!");
                }

                // yes/no (not in those words)
            } else if (command == yeahNahCommand) {
                Object[] options = { "Yes, please", "No way!" };
                int n = JOptionPane.showOptionDialog(frame, "Would you like green eggs and ham?",
                        "A Silly Question", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
                        options, options[0]);
                if (n == JOptionPane.YES_OPTION) {
                    setLabel("You're kidding!");
                } else if (n == JOptionPane.NO_OPTION) {
                    setLabel("I don't like them, either.");
                } else {
                    setLabel("Come on -- 'fess up!");
                }

                // yes/no/cancel (not in those words)
            } else if (command == yncCommand) {
                Object[] options = { "Yes, please", "No, thanks", "No eggs, no ham!" };
                int n = JOptionPane.showOptionDialog(frame,
                        "Would you like some green eggs to go " + "with that ham?", "A Silly Question",
                        JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options,
                        options[2]);
                if (n == JOptionPane.YES_OPTION) {
                    setLabel("Here you go: green eggs and ham!");
                } else if (n == JOptionPane.NO_OPTION) {
                    setLabel("OK, just the ham, then.");
                } else if (n == JOptionPane.CANCEL_OPTION) {
                    setLabel("Well, I'm certainly not going to eat them!");
                } else {
                    setLabel("Please tell me what you want!");
                }
            }
            return;
        }
    });

    return createPane(simpleDialogDesc + ":", radioButtons, showItButton);
}

From source file:net.lmxm.ute.gui.editors.tasks.SubversionExportTaskEditorPanel.java

/**
 * Gets the numbered revision radio button.
 * //from   w w  w .ja  v a 2s . c om
 * @return the numbered revision radio button
 */
private JRadioButton getNumberedRevisionRadioButton() {
    if (numberedRevisionRadioButton == null) {
        numberedRevisionRadioButton = new JRadioButton(SubversionRevision.NUMBERED.toString());
        numberedRevisionRadioButton.addActionListener(revisionActionListener);
    }

    return numberedRevisionRadioButton;
}

From source file:Main_Window.java

public Main_Window() {
    super("Google Places Application"); //First call Constructor of JFrame

    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //We do not want our application to terminate when a JFrame is closed
    this.addWindowListener(new java.awt.event.WindowAdapter() {
        @Override/*from w  w w  .j a  v  a2  s. c o  m*/
        public void windowClosing(java.awt.event.WindowEvent windowEvent) {
            int Answer = JOptionPane.showConfirmDialog(null, "Exit Application ? ", "Exit ? ",
                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (Answer == JOptionPane.YES_OPTION) {
                if (POI_List.isEmpty()) {
                    POI_List.clear();
                }
                if (Distances_List.isEmpty()) {
                    Distances_List.clear();
                }
                if (Temp_List.isEmpty()) {
                    Temp_List.clear();
                }
                if (Distances_List_2.isEmpty()) {
                    Distances_List_2.clear();
                }
                System.exit(1);
            } else {
                setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
            }
        }
    });
    //The listener object created from that class is then registered with a Window using the window's addWindowListener method.

    //
    this.setSize(1100, 700); // Size of Window
    this.setLocationRelativeTo(null); // Display Window in center of Screen
    this.setVisible(true);
    this.getContentPane().setBackground(Color.LIGHT_GRAY);
    //

    //Initialization of J Components
    POIS_Label = new JLabel("Points of Interest:");
    POIS_Label.setForeground(Color.black);
    POIS_Label.setFont(new Font("Courier New", Font.BOLD, 25));
    POIS_Label.setBounds(600, 30, 350, 150);

    Retrieve_POIs_Button = new JButton("Retrieve POIs");
    Retrieve_POIs_Button.setForeground(Color.black);
    Retrieve_POIs_Button.setFont(new Font("Courier New", Font.BOLD, 35));
    Retrieve_POIs_Button.setBounds(25, 450, 350, 150);

    Open_Status = new JRadioButton(" Open Now?");
    Open_Status.setForeground(Color.black);
    Open_Status.setBackground(Color.LIGHT_GRAY);
    Open_Status.setBounds(20, 380, 100, 30);

    Welcome_Label = new JLabel("Welcome to Google Places");
    Welcome_Label.setForeground(Color.BLUE);
    Welcome_Label.setFont(new Font("Courier New", Font.BOLD, 35));
    Welcome_Label.setBounds(240, 20, 600, 60);

    Latitude_Label = new JLabel("Latitude:");
    Latitude_Label.setForeground(Color.BLACK);
    Latitude_Label.setFont(new Font("Courier New", Font.PLAIN, 25));
    Latitude_Label.setBounds(15, 80, 200, 100);

    Longitude_Label = new JLabel("Longitude:");
    Longitude_Label.setForeground(Color.BLACK);
    Longitude_Label.setFont(new Font("Courier New", Font.PLAIN, 25));
    Longitude_Label.setBounds(15, 130, 250, 100);

    Radius_Label = new JLabel("Radius:");
    Radius_Label.setForeground(Color.BLACK);
    Radius_Label.setFont(new Font("Courier New", Font.PLAIN, 25));
    Radius_Label.setBounds(15, 180, 250, 100);

    Category_Label = new JLabel("Category:");
    Category_Label.setForeground(Color.BLACK);
    Category_Label.setFont(new Font("Courier New", Font.PLAIN, 25));
    Category_Label.setBounds(15, 250, 250, 100);

    Latitude_TextField = new JTextField(7);
    Latitude_TextField.setForeground(Color.BLACK);
    Latitude_TextField.setBounds(165, 116, 180, 30);

    Longitude_TextField = new JTextField(7);
    Longitude_TextField.setForeground(Color.BLACK);
    Longitude_TextField.setBounds(170, 168, 180, 30);

    Radius_TextField = new JTextField(7);
    Radius_TextField.setForeground(Color.BLACK);
    Radius_TextField.setBounds(125, 215, 180, 30);

    Categories = new JComboBox(Categories_Names);
    Categories.setForeground(Color.BLACK);
    Categories.setBackground(Color.white);
    Categories.setBounds(15, 320, 180, 30);

    POI_List = new ArrayList();

    pane = getContentPane(); //Manager
    pane.setLayout(null); // Deactivate Manager Layout

    //JPANEL
    P = new JPanel();
    P.setBackground(Color.GRAY);
    P.setBounds(600, 120, 450, 180);
    P.setBackground(Color.GRAY);

    pane.add(P);
    pane.add(POIS_Label);
    pane.add(Retrieve_POIs_Button);
    pane.add(Welcome_Label);
    pane.add(Longitude_Label);
    pane.add(Latitude_Label);
    pane.add(Radius_Label);
    pane.add(Category_Label);
    pane.add(Latitude_TextField);
    pane.add(Longitude_TextField);
    pane.add(Radius_TextField);
    pane.add(Categories);
    pane.add(Open_Status);

    Retrieve_POIs_Button.addActionListener(this);

    setContentPane(pane);

}

From source file:net.pandoragames.far.ui.swing.RenameFilesPanel.java

private void init(SwingConfig config, ComponentRepository componentRepository) {

    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    this.setBorder(
            BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING));

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));
    JLabel patternLabel = new JLabel(localizer.localize("label.find-pattern"));
    this.add(patternLabel);
    filenamePattern = new JTextField();
    filenamePattern.setPreferredSize(/* w w  w .j  av a 2  s .c  om*/
            new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, config.getStandardComponentHight()));
    filenamePattern
            .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight()));
    filenamePattern.setAlignmentX(Component.LEFT_ALIGNMENT);
    UndoHistory findUndoManager = new UndoHistory();
    findUndoManager.registerUndoHistory(filenamePattern);
    findUndoManager.registerSnapshotHistory(filenamePattern);
    componentRepository.getReplaceCommand().addResetable(findUndoManager);
    filenamePattern.getDocument().addDocumentListener(new DocumentChangeListener() {
        public void documentUpdated(DocumentEvent e, String text) {
            dataModel.setPatternString(text);
            updateFileTable();
        }
    });
    componentRepository.getResetDispatcher().addToBeCleared(filenamePattern);
    this.add(filenamePattern);
    JCheckBox caseBox = new JCheckBox(localizer.localize("label.ignore-case"));
    caseBox.setSelected(true);
    caseBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setIgnoreCase((ItemEvent.SELECTED == event.getStateChange()));
            updateFileTable();
        }
    });
    this.add(caseBox);
    JCheckBox regexBox = new JCheckBox(localizer.localize("label.regular-expression"));
    regexBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setRegexPattern((ItemEvent.SELECTED == event.getStateChange()));
            updateFileTable();
        }
    });
    this.add(regexBox);
    JPanel extensionPanel = new JPanel();
    extensionPanel.setBorder(BorderFactory.createTitledBorder(localizer.localize("label.modify-extension")));
    extensionPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    extensionPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    extensionPanel.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, 60));
    extensionPanel.setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, 100));
    ButtonGroup extensionGroup = new ButtonGroup();
    JRadioButton protectButton = new JRadioButton(localizer.localize("label.protect-extension"));
    protectButton.setSelected(true);
    protectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dataModel.setProtectExtension(true);
            updateFileTable();
        }
    });
    extensionGroup.add(protectButton);
    extensionPanel.add(protectButton);
    JRadioButton includeButton = new JRadioButton(localizer.localize("label.include-extension"));
    includeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dataModel.setExtensionOnly(false);
            dataModel.setProtectExtension(false);
            updateFileTable();
        }
    });
    extensionGroup.add(includeButton);
    extensionPanel.add(includeButton);
    JRadioButton onlyButton = new JRadioButton(localizer.localize("label.only-extension"));
    onlyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dataModel.setExtensionOnly(true);
            updateFileTable();
        }
    });
    extensionGroup.add(onlyButton);
    extensionPanel.add(onlyButton);
    this.add(extensionPanel);

    this.add(Box.createVerticalGlue());
    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));

    // replace
    JLabel replaceLabel = new JLabel(localizer.localize("label.replacement-pattern"));
    this.add(replaceLabel);
    replacePattern = new JTextField();
    replacePattern.setPreferredSize(
            new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, config.getStandardComponentHight()));
    replacePattern
            .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight()));
    replacePattern.setAlignmentX(Component.LEFT_ALIGNMENT);
    UndoHistory undoManager = new UndoHistory();
    undoManager.registerUndoHistory(replacePattern);
    undoManager.registerSnapshotHistory(replacePattern);
    componentRepository.getReplaceCommand().addResetable(undoManager);
    replacePattern.getDocument().addDocumentListener(new DocumentChangeListener() {
        public void documentUpdated(DocumentEvent e, String text) {
            dataModel.setReplacementString(text);
            updateFileTable();
        }
    });
    componentRepository.getResetDispatcher().addToBeCleared(replacePattern);
    this.add(replacePattern);

    // treat case
    JPanel modifyCasePanel = new JPanel();
    modifyCasePanel.setBorder(BorderFactory.createTitledBorder(localizer.localize("label.modify-case")));
    modifyCasePanel.setLayout(new BoxLayout(modifyCasePanel, BoxLayout.Y_AXIS));
    modifyCasePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    modifyCasePanel.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, 100));
    modifyCasePanel.setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, 200));
    ButtonGroup modifyCaseGroup = new ButtonGroup();
    ActionListener radioButtonListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String cmd = e.getActionCommand();
            dataModel.setTreatCase(RenameForm.CASEHANDLING.valueOf(cmd));
            updateFileTable();
        }
    };
    JRadioButton lowerButton = new JRadioButton(localizer.localize("label.to-lower-case"));
    lowerButton.setActionCommand(RenameForm.CASEHANDLING.LOWER.name());
    lowerButton.addActionListener(radioButtonListener);
    modifyCaseGroup.add(lowerButton);
    modifyCasePanel.add(lowerButton);
    JRadioButton upperButton = new JRadioButton(localizer.localize("label.to-upper-case"));
    upperButton.setActionCommand(RenameForm.CASEHANDLING.UPPER.name());
    upperButton.addActionListener(radioButtonListener);
    modifyCaseGroup.add(upperButton);
    modifyCasePanel.add(upperButton);
    JRadioButton keepButton = new JRadioButton(localizer.localize("label.preserve-case"));
    keepButton.setActionCommand(RenameForm.CASEHANDLING.PRESERVE.name());
    keepButton.setSelected(true);
    keepButton.addActionListener(radioButtonListener);
    modifyCaseGroup.add(keepButton);
    modifyCasePanel.add(keepButton);
    this.add(modifyCasePanel);

    // prevent case conflict
    JCheckBox caseConflictBox = new JCheckBox(localizer.localize("label.prevent-case-conflict"));
    caseConflictBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    caseConflictBox.setSelected(true);
    caseConflictBox.setEnabled(!SwingConfig.isWindows()); // disabled on windows
    caseConflictBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setPreventCaseConflict((ItemEvent.SELECTED == event.getStateChange()));
            updateFileTable();
        }
    });
    this.add(caseConflictBox);

    this.add(Box.createVerticalGlue());

}

From source file:com.projity.dialog.ResourceSubstitutionDialog.java

protected void initControls() {
    entireProject = new JRadioButton(Messages.getString("UpdateProjectDialogBox.EntireProject")); //$NON-NLS-1$
    entireProject.setSelected(true);//from  www  .j  a va  2  s  .c om
    selectedTask = new JRadioButton(Messages.getString("UpdateProjectDialogBox.SelectedTasks")); //$NON-NLS-1$
    if (!hasTasksSelected) {
        selectedTask.setEnabled(false);
    }
    projectOrTask = new ButtonGroup();
    projectOrTask.add(entireProject);
    projectOrTask.add(selectedTask);

    rescheduleDateChooser = CalendarFactory.createDateField();

    ignoreInProgress = new JCheckBox("Ignore in-progress assignments"); //$NON-NLS-1$
    ignoreInProgress.setSelected(false);
    List resources = (List) project.getResourcePool().getResourceList().clone();
    resources.add(0, null); // allow blank
    fromResource = new JComboBox(resources.toArray());
    toResource = new JComboBox(resources.toArray());
    ok.setEnabled(false);
    toResource.addActionListener(this);
    fromResource.addActionListener(this);
}

From source file:com.rapidminer.gui.new_plotter.gui.dialog.ManageZoomDialog.java

/**
 * Setup the GUI./*w  ww.j  a v a 2 s. c  o  m*/
 */
private void setupGUI() {
    JPanel mainPanel = new JPanel();
    this.setContentPane(mainPanel);

    // start layout
    mainPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 0;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 2, 5);
    JPanel radioPanel = new JPanel();
    radioPanel.setLayout(new BorderLayout());
    zoomRadiobutton = new JRadioButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.zoom.label"));
    zoomRadiobutton.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.zoom.tip"));
    zoomRadiobutton.setSelected(true);
    radioPanel.add(zoomRadiobutton, BorderLayout.LINE_START);

    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weightx = 1;
    selectionRadiobutton = new JRadioButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.selection.label"));
    selectionRadiobutton
            .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.selection.tip"));
    selectionRadiobutton.setHorizontalAlignment(SwingConstants.CENTER);
    radioPanel.add(selectionRadiobutton, BorderLayout.LINE_END);

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 3;
    this.add(radioPanel, gbc);

    ButtonGroup group = new ButtonGroup();
    group.add(zoomRadiobutton);
    group.add(selectionRadiobutton);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.CENTER;
    rangeAxisSelectionCombobox = new JComboBox();
    rangeAxisSelectionCombobox.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.range_axis_combobox.tip"));
    rangeAxisSelectionCombobox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateValueRange();
        }
    });
    this.add(rangeAxisSelectionCombobox, gbc);

    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 1;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 2, 5);
    JLabel domainRangeLowerBoundLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.domain_lower_bound.label"));
    this.add(domainRangeLowerBoundLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.insets = new Insets(2, 5, 2, 5);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    domainRangeLowerBoundField = new JTextField();
    domainRangeLowerBoundField.setText(String.valueOf(domainRangeLowerBound));
    domainRangeLowerBoundField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyDomainRangeLowerBoundInput(input);
        }
    });
    domainRangeLowerBoundField.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.domain_lower_bound.tip"));
    this.add(domainRangeLowerBoundField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.NONE;
    JLabel domainRangeUpperBoundLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.domain_upper_bound.label"));
    this.add(domainRangeUpperBoundLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    domainRangeUpperBoundField = new JTextField();
    domainRangeUpperBoundField.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.domain_upper_bound.tip"));
    domainRangeUpperBoundField.setText(String.valueOf(domainRangeUpperBound));
    domainRangeUpperBoundField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyDomainRangeUpperBoundInput(input);
        }
    });
    this.add(domainRangeUpperBoundField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.fill = GridBagConstraints.NONE;
    JLabel valueRangeLowerBoundLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.value_lower_bound.label"));
    this.add(valueRangeLowerBoundLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 4;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    valueRangeLowerBoundField = new JTextField();
    valueRangeLowerBoundField.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.value_lower_bound.tip"));
    valueRangeLowerBoundField.setText(String.valueOf(valueRangeLowerBound));
    valueRangeLowerBoundField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyValueRangeLowerBoundInput(input);
        }
    });
    this.add(valueRangeLowerBoundField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.fill = GridBagConstraints.NONE;
    JLabel valueRangeUpperBoundLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.value_upper_bound.label"));
    this.add(valueRangeUpperBoundLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    valueRangeUpperBoundField = new JTextField();
    valueRangeUpperBoundField.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.value_upper_bound.tip"));
    valueRangeUpperBoundField.setText(String.valueOf(valueRangeUpperBound));
    valueRangeUpperBoundField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyValueRangeUpperBoundInput(input);
        }
    });
    this.add(valueRangeUpperBoundField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 6;
    gbc.gridwidth = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    this.add(new JSeparator(), gbc);

    gbc.gridx = 0;
    gbc.gridy = 7;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    JLabel colorMinValueLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.color_min_value.label"));
    this.add(colorMinValueLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 7;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    colorMinValueField = new JTextField();
    colorMinValueField
            .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.color_min_value.tip"));
    colorMinValueField.setText(String.valueOf(colorMinValue));
    colorMinValueField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyColorInput(input);
        }
    });
    colorMinValueField.setEnabled(false);
    this.add(colorMinValueField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 8;
    gbc.fill = GridBagConstraints.NONE;
    JLabel colorMaxValueLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.color_max_value.label"));
    this.add(colorMaxValueLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 8;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    colorMaxValueField = new JTextField();
    colorMaxValueField
            .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.color_max_value.tip"));
    colorMaxValueField.setText(String.valueOf(colorMaxValue));
    colorMaxValueField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyColorInput(input);
        }
    });
    colorMaxValueField.setEnabled(false);
    this.add(colorMaxValueField, gbc);

    gbc.gridx = 1;
    gbc.gridy = 9;
    gbc.fill = GridBagConstraints.NONE;
    restoreColorButton = new JButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.restore_color.label"));
    restoreColorButton
            .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.restore_color.tip"));
    restoreColorButton.setIcon(SwingTools.createIcon(
            "16/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.restore_color.icon")));
    restoreColorButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            LinkAndBrushSelection linkAndBrushSelection = new LinkAndBrushSelection(SelectionType.RESTORE_COLOR,
                    new LinkedList<Pair<Integer, Range>>(), new LinkedList<Pair<Integer, Range>>(), null, null,
                    engine.getPlotInstance());
            engine.getChartPanel().informLinkAndBrushSelectionListeners(linkAndBrushSelection);
            updateColorValues();
        }
    });
    restoreColorButton.setEnabled(false);
    this.add(restoreColorButton, gbc);

    gbc.gridx = 0;
    gbc.gridy = 10;
    gbc.gridwidth = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(2, 5, 5, 5);
    this.add(new JSeparator(), gbc);

    gbc.gridx = 0;
    gbc.gridy = 11;
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 5, 5);
    okButton = new JButton(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.ok.label"));
    okButton.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.ok.tip"));
    okButton.setIcon(SwingTools
            .createIcon("24/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.ok.icon")));
    okButton.setMnemonic(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.ok.mne").toCharArray()[0]);
    okButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // make sure fields have correct values
            boolean fieldsPassedChecks = checkFields();
            if (!fieldsPassedChecks) {
                return;
            }

            Object selectedItem = rangeAxisSelectionCombobox.getSelectedItem();
            if (selectedItem != null && selectedItem instanceof RangeAxisConfig) {
                RangeAxisConfig config = (RangeAxisConfig) selectedItem;
                boolean zoomOnLinkAndBrushSelection = engine.getChartPanel().getZoomOnLinkAndBrushSelection();
                Range domainRange = new Range(Double.parseDouble(domainRangeLowerBoundField.getText()),
                        Double.parseDouble(domainRangeUpperBoundField.getText()));
                Range valueRange = new Range(Double.parseDouble(valueRangeLowerBoundField.getText()),
                        Double.parseDouble(valueRangeUpperBoundField.getText()));
                LinkedList<Pair<Integer, Range>> domainRangeList = new LinkedList<Pair<Integer, Range>>();
                // only add domain zoom if != 0
                if (domainRange.getUpperBound() != 0) {
                    domainRangeList.add(new Pair<Integer, Range>(0, domainRange));
                }
                LinkedList<Pair<Integer, Range>> valueRangeList = new LinkedList<Pair<Integer, Range>>();
                // only add range zoom if at least one RangeAxisConfig exists
                if (engine.getPlotInstance().getMasterPlotConfiguration().getRangeAxisConfigs().size() > 0) {
                    if (valueRange.getUpperBound() != 0) {
                        // only add value zoom if != 0
                        valueRangeList.add(
                                new Pair<Integer, Range>(engine.getPlotInstance().getMasterPlotConfiguration()
                                        .getIndexOfRangeAxisConfigById(config.getId()), valueRange));
                    }
                }

                // zoom or select or color
                LinkAndBrushSelection linkAndBrushSelection = null;
                if (zoomRadiobutton.isSelected()) {
                    linkAndBrushSelection = new LinkAndBrushSelection(SelectionType.ZOOM_IN, domainRangeList,
                            valueRangeList);
                    if (isColorChanged(Double.parseDouble(colorMinValueField.getText()),
                            Double.parseDouble(colorMaxValueField.getText()))) {
                        linkAndBrushSelection = new LinkAndBrushSelection(SelectionType.COLOR_ZOOM,
                                domainRangeList, valueRangeList,
                                Double.parseDouble(colorMinValueField.getText()),
                                Double.parseDouble(colorMaxValueField.getText()), engine.getPlotInstance());
                    }
                } else if (selectionRadiobutton.isSelected()) {
                    linkAndBrushSelection = new LinkAndBrushSelection(SelectionType.SELECTION, domainRangeList,
                            valueRangeList);
                    if (isColorChanged(Double.parseDouble(colorMinValueField.getText()),
                            Double.parseDouble(colorMaxValueField.getText()))) {
                        linkAndBrushSelection = new LinkAndBrushSelection(SelectionType.COLOR_SELECTION,
                                domainRangeList, valueRangeList,
                                Double.parseDouble(colorMinValueField.getText()),
                                Double.parseDouble(colorMaxValueField.getText()), engine.getPlotInstance());
                    }
                }
                engine.getChartPanel().informLinkAndBrushSelectionListeners(linkAndBrushSelection);
                engine.getChartPanel().setZoomOnLinkAndBrushSelection(zoomOnLinkAndBrushSelection);
            } else {
                return;
            }

            ManageZoomDialog.this.dispose();
        }
    });
    okButton.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                okButton.doClick();
            }
        }
    });
    this.add(okButton, gbc);

    gbc.gridx = 2;
    gbc.gridy = 11;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    cancelButton = new JButton(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.cancel.label"));
    cancelButton.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.cancel.tip"));
    cancelButton.setIcon(SwingTools
            .createIcon("24/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.cancel.icon")));
    cancelButton.setMnemonic(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.cancel.mne").toCharArray()[0]);
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // cancel requested, close dialog
            ManageZoomDialog.this.dispose();
        }
    });
    this.add(cancelButton, gbc);

    // misc settings
    this.setMinimumSize(new Dimension(375, 360));
    // center dialog
    this.setLocationRelativeTo(null);
    this.setTitle(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.title.label"));
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.setModal(true);

    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowActivated(WindowEvent e) {
            okButton.requestFocusInWindow();
        }
    });
}

From source file:ca.phon.plugins.praat.export.TextGridExportWizard.java

private WizardStep setupExportOptionsStep() {
    final WizardStep retVal = new WizardStep();

    final DialogHeader header = new DialogHeader("Generate TextGrids", "Setup export options.");

    overwriteBox = new JCheckBox();
    overwriteBox.setText(OVERWRITE_MESSAGE);

    nameField = new JTextField();
    nameField.setEnabled(false);/*from  w  w w. j a  v  a  2 s.  com*/

    defaultNameButton = new JRadioButton(
            "Save as default TextGrid for session (__res/textgrids/.../default.TextGrid)");
    customNameButton = new JRadioButton("Save TextGrid with custom name");
    defaultNameButton.setSelected(true);

    defaultNameButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            boolean state = defaultNameButton.isSelected();
            if (state) {
                nameField.setEnabled(false);
            }
        }

    });

    customNameButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean state = customNameButton.isSelected();
            if (state) {
                nameField.setEnabled(true);
            }
        }
    });

    nameGroup = new ButtonGroup();
    nameGroup.add(defaultNameButton);
    nameGroup.add(customNameButton);

    final TextGridExporter exporter = new TextGridExporter();
    exportsTree = new ExportEntryCheckboxTree(session);
    exportsTree.setBorder(BorderFactory.createTitledBorder("Select tiers"));
    exportsTree.setChecked(exporter.getExports(getProject()));
    final JScrollPane exportsScroller = new JScrollPane(exportsTree);

    final JPanel topPanel = new JPanel();
    topPanel.setLayout(new VerticalLayout());
    topPanel.setBorder(BorderFactory.createTitledBorder("Options"));
    topPanel.add(defaultNameButton);
    topPanel.add(customNameButton);
    topPanel.add(nameField);
    topPanel.add(overwriteBox);

    final JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new BorderLayout());
    centerPanel.add(topPanel, BorderLayout.NORTH);
    centerPanel.add(exportsScroller, BorderLayout.CENTER);

    retVal.setLayout(new BorderLayout());
    retVal.add(header, BorderLayout.NORTH);
    retVal.add(centerPanel, BorderLayout.CENTER);

    return retVal;
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopOptionsGroup.java

private void addItem(final ValueWrapper item) {
    JToggleButton button;//from w  w  w.j  av a2  s .c o m
    if (multiselect) {
        button = new JCheckBox(item.toString());
    } else {
        if (buttonGroup == null)
            buttonGroup = new ButtonGroup();
        button = new JRadioButton(item.toString());
        buttonGroup.add(button);
    }
    button.setEnabled(enabled && editable);
    button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (!multiselect) {
                Object newValue = item.getValue();
                if (!Objects.equals(newValue, prevValue)) {
                    updateInstance(newValue);
                    fireChangeListeners(newValue);
                }
                updateMissingValueState();
            } else {
                Set<Object> newValue = new LinkedHashSet<>();
                for (Map.Entry<ValueWrapper, JToggleButton> item : items.entrySet()) {
                    if (item.getValue().isSelected()) {
                        newValue.add(item.getKey().getValue());
                    }
                }
                if ((prevValue != null && !CollectionUtils.isEqualCollection(newValue, (Collection) prevValue))
                        || (prevValue == null)) {
                    updateInstance(newValue);
                    fireChangeListeners(newValue);
                }
                updateMissingValueState();
            }
        }
    });

    impl.add(button);
    items.put(item, button);
}