Search in sources :

Example 86 with JRadioButton

use of javax.swing.JRadioButton in project sldeditor by robward-scisys.

the class FieldConfigTimePeriod method createUIPanel.

/**
 * Creates the ui panel.
 *
 * @param fieldPanel the field panel
 * @param panelData the panel
 * @param index the index
 * @param title the title
 * @return the int
 */
private void createUIPanel(FieldPanel fieldPanel, TimePeriodPanel panelData, int index, String title) {
    panelData.panel = new JPanel();
    panelData.panel.setLayout(null);
    int row = 0;
    panelData.dateRadioButton = new JRadioButton();
    panelData.dateRadioButton.setBounds(2, getRowY(row), 20, BasePanel.WIDGET_HEIGHT);
    panelData.dateRadioButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateFields(panelData);
        }
    });
    panelData.panel.add(panelData.dateRadioButton);
    panelData.buttonGroup.add(panelData.dateRadioButton);
    JDatePanelImpl datePanel = new JDatePanelImpl(panelData.dateModel);
    panelData.datePicker = new JDatePickerImpl(datePanel);
    int xPos = getXPos();
    panelData.datePicker.setBounds(xPos + BasePanel.WIDGET_X_START, getRowY(row), BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
    panelData.panel.add(panelData.datePicker);
    panelData.dateModel.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            valueUpdated();
        }
    });
    // Time picker
    SpinnerDateModel model = new SpinnerDateModel();
    Calendar calendar = Calendar.getInstance();
    model.setValue(calendar.getTime());
    panelData.timePicker = new JSpinner(model);
    panelData.timePicker.setBounds(panelData.datePicker.getX() + panelData.datePicker.getWidth() + 10, getRowY(row), (int) (BasePanel.WIDGET_STANDARD_WIDTH * 0.75), BasePanel.WIDGET_HEIGHT);
    panelData.timePicker.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            valueUpdated();
        }
    });
    panelData.panel.add(panelData.timePicker);
    panelData.timeEditor = new JSpinner.DateEditor(panelData.timePicker, "HH:mm:ss");
    panelData.timePicker.setEditor(panelData.timeEditor);
    DateFormatter formatter = (DateFormatter) panelData.timeEditor.getTextField().getFormatter();
    formatter.setAllowsInvalid(false);
    formatter.setOverwriteMode(true);
    // 
    // Date
    // 
    row++;
    panelData.durationRadioButton = new JRadioButton();
    panelData.durationRadioButton.setBounds(2, getRowY(row), 20, BasePanel.WIDGET_HEIGHT);
    panelData.durationRadioButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateFields(panelData);
        }
    });
    panelData.panel.add(panelData.durationRadioButton);
    panelData.buttonGroup.add(panelData.durationRadioButton);
    panelData.dateCheckbox = new JCheckBox(Localisation.getString(FieldConfigBase.class, "FieldConfigTimePeriod.date"));
    panelData.dateCheckbox.setBounds(20, getRowY(row), 55, BasePanel.WIDGET_HEIGHT);
    panelData.dateCheckbox.setSelected(true);
    panelData.dateCheckbox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean enabled = panelData.dateCheckbox.isSelected();
            panelData.yearSpinner.setEnabled(enabled);
            panelData.monthSpinner.setEnabled(enabled);
            panelData.daySpinner.setEnabled(enabled);
        }
    });
    panelData.panel.add(panelData.dateCheckbox);
    int x = xPos + BasePanel.WIDGET_X_START - 10;
    // Year
    JLabel yearLbl = new JLabel(Localisation.getField(FieldConfigBase.class, "FieldConfigTimePeriod.year"));
    yearLbl.setHorizontalAlignment(SwingConstants.LEADING);
    yearLbl.setBounds(x, getRowY(row), 40, BasePanel.WIDGET_HEIGHT);
    panelData.panel.add(yearLbl);
    panelData.yearSpinner = new JSpinner();
    x = x + 40;
    int spinnerWidth = (int) (BasePanel.WIDGET_STANDARD_WIDTH * 0.4);
    panelData.yearSpinner.setBounds(x, getRowY(row), spinnerWidth, BasePanel.WIDGET_HEIGHT);
    panelData.panel.add(panelData.yearSpinner);
    panelData.yearSpinner.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            valueUpdated();
        }
    });
    // Month
    x = x + spinnerWidth + 2;
    JLabel monthLbl = new JLabel(Localisation.getField(FieldConfigBase.class, "FieldConfigTimePeriod.month"));
    monthLbl.setHorizontalAlignment(SwingConstants.LEADING);
    monthLbl.setBounds(x, getRowY(row), 40, BasePanel.WIDGET_HEIGHT);
    panelData.panel.add(monthLbl);
    x = x + 40;
    panelData.monthSpinner = new JSpinner();
    panelData.monthSpinner.setBounds(x, getRowY(row), spinnerWidth, BasePanel.WIDGET_HEIGHT);
    panelData.panel.add(panelData.monthSpinner);
    panelData.monthSpinner.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            valueUpdated();
        }
    });
    // Day
    x = x + spinnerWidth + 2;
    JLabel dayLbl = new JLabel(Localisation.getField(FieldConfigBase.class, "FieldConfigTimePeriod.day"));
    dayLbl.setHorizontalAlignment(SwingConstants.LEADING);
    dayLbl.setBounds(x, getRowY(row), 40, BasePanel.WIDGET_HEIGHT);
    panelData.panel.add(dayLbl);
    x = x + 40;
    panelData.daySpinner = new JSpinner();
    panelData.daySpinner.setBounds(x, getRowY(row), spinnerWidth, BasePanel.WIDGET_HEIGHT);
    panelData.panel.add(panelData.daySpinner);
    panelData.daySpinner.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            valueUpdated();
        }
    });
    // 
    // Time
    // 
    row++;
    panelData.timeCheckbox = new JCheckBox(Localisation.getString(FieldConfigBase.class, "FieldConfigTimePeriod.time"));
    panelData.timeCheckbox.setBounds(20, getRowY(row), 55, BasePanel.WIDGET_HEIGHT);
    panelData.timeCheckbox.setSelected(true);
    panelData.timeCheckbox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean enabled = panelData.timeCheckbox.isSelected();
            panelData.hourSpinner.setEnabled(enabled);
            panelData.minuteSpinner.setEnabled(enabled);
            panelData.secondSpinner.setEnabled(enabled);
        }
    });
    panelData.panel.add(panelData.timeCheckbox);
    x = xPos + BasePanel.WIDGET_X_START - 10;
    // Hours
    JLabel hoursLbl = new JLabel(Localisation.getField(FieldConfigBase.class, "FieldConfigTimePeriod.hours"));
    hoursLbl.setHorizontalAlignment(SwingConstants.LEADING);
    hoursLbl.setBounds(x, getRowY(row), 40, BasePanel.WIDGET_HEIGHT);
    panelData.panel.add(hoursLbl);
    panelData.hourSpinner = new JSpinner();
    x = x + 40;
    panelData.hourSpinner.setBounds(x, getRowY(row), spinnerWidth, BasePanel.WIDGET_HEIGHT);
    panelData.hourSpinner.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            valueUpdated();
        }
    });
    panelData.panel.add(panelData.hourSpinner);
    // Minutes
    x = x + spinnerWidth + 2;
    JLabel minuteLbl = new JLabel(Localisation.getField(FieldConfigBase.class, "FieldConfigTimePeriod.minutes"));
    minuteLbl.setHorizontalAlignment(SwingConstants.LEADING);
    minuteLbl.setBounds(x, getRowY(row), 40, BasePanel.WIDGET_HEIGHT);
    panelData.panel.add(minuteLbl);
    x = x + 40;
    panelData.minuteSpinner = new JSpinner();
    panelData.minuteSpinner.setBounds(x, getRowY(row), spinnerWidth, BasePanel.WIDGET_HEIGHT);
    panelData.minuteSpinner.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            valueUpdated();
        }
    });
    panelData.panel.add(panelData.minuteSpinner);
    // Seconds
    x = x + spinnerWidth + 2;
    JLabel secondLabel = new JLabel(Localisation.getField(FieldConfigBase.class, "FieldConfigTimePeriod.seconds"));
    secondLabel.setHorizontalAlignment(SwingConstants.LEADING);
    secondLabel.setBounds(x, getRowY(row), 40, BasePanel.WIDGET_HEIGHT);
    panelData.panel.add(secondLabel);
    x = x + 40;
    panelData.secondSpinner = new JSpinner();
    panelData.secondSpinner.setBounds(x, getRowY(row), spinnerWidth, BasePanel.WIDGET_HEIGHT);
    panelData.secondSpinner.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            valueUpdated();
        }
    });
    panelData.panel.add(panelData.secondSpinner);
    fieldPanel.add(panelData.panel);
    panelData.panel.setBounds(0, index * ((row * BasePanel.WIDGET_HEIGHT) + 50), BasePanel.FIELD_PANEL_WIDTH, (row + 2) * BasePanel.WIDGET_HEIGHT);
    Dimension preferredSize = new Dimension((int) panelData.panel.getPreferredSize().getWidth(), (row + 2) * BasePanel.WIDGET_HEIGHT);
    panelData.panel.setPreferredSize(preferredSize);
    panelData.panel.setBorder(BorderFactory.createTitledBorder(title));
}
Also used : JPanel(javax.swing.JPanel) JRadioButton(javax.swing.JRadioButton) ActionEvent(java.awt.event.ActionEvent) Calendar(java.util.Calendar) JDatePanelImpl(net.sourceforge.jdatepicker.impl.JDatePanelImpl) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) SpinnerDateModel(javax.swing.SpinnerDateModel) JDatePickerImpl(net.sourceforge.jdatepicker.impl.JDatePickerImpl) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) DateFormatter(javax.swing.text.DateFormatter) JSpinner(javax.swing.JSpinner) ChangeListener(javax.swing.event.ChangeListener)

Example 87 with JRadioButton

use of javax.swing.JRadioButton in project cytoscape-impl by cytoscape.

the class PrefsColor method makeRadioButton.

// 
JRadioButton makeRadioButton(String s) {
    JRadioButton btn = new JRadioButton(s);
    btn.addActionListener(ctrlListener);
    btn.setActionCommand(s);
    buttonGroup.add(btn);
    return btn;
}
Also used : JRadioButton(javax.swing.JRadioButton)

Example 88 with JRadioButton

use of javax.swing.JRadioButton in project cytoscape-impl by cytoscape.

the class ImportTablePanel method initComponents.

private void initComponents() {
    attrTypeButtonGroup = new ButtonGroup();
    nodeRadioButton = new JRadioButton("Node");
    edgeRadioButton = new JRadioButton("Edge");
    networkRadioButton = new JRadioButton("Network");
    ontologyComboBox = new JComboBox<>();
    browseOntologyButton = new JButton("Browse...");
    annotationComboBox = new JComboBox<>();
    browseAnnotationButton = new JButton("Browse...");
    targetDataSourceTextField = new JTextField();
    selectAttributeFileButton = new JButton();
    mappingAttributeComboBox = new JComboBox<>();
    delimiterLabel = new JLabel("Delimiter:");
    delimiterLabel.setHorizontalAlignment(JLabel.RIGHT);
    commaCheckBox = new JCheckBox("<html><b><font size=+1 face=Monospaced>,<font></b> <font size=-2>(comma)</font><html>");
    semicolonCheckBox = new JCheckBox("<html><b><font size=+1 face=Monospaced>;<font></b> <font size=-2>(semicolon)</font><html>");
    spaceCheckBox = new JCheckBox("<html><b><font size=-1 face=Monospaced>SPACE<font></b><html>");
    tabCheckBox = new JCheckBox("<html><b><font size=-1 face=Monospaced>TAB<font></b><html>");
    otherCheckBox = new JCheckBox("Other:");
    otherDelimiterTextField = new JTextField();
    defaultInteractionTextField = new JTextField();
    attributeFileLabel = new JLabel();
    attrTypeButtonGroup.add(nodeRadioButton);
    attrTypeButtonGroup.add(edgeRadioButton);
    attrTypeButtonGroup.add(networkRadioButton);
    /*
		 * Set tooltips options.
		 */
    ToolTipManager tp = ToolTipManager.sharedInstance();
    tp.setInitialDelay(40);
    tp.setDismissDelay(50000);
    if (importType == ONTOLOGY_IMPORT) {
        /*
			 * Data Source Panel Layouts.
			 */
        nodeRadioButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
        nodeRadioButton.setMargin(new Insets(0, 0, 0, 0));
        nodeRadioButton.setSelected(true);
        nodeRadioButton.addActionListener((ActionEvent evt) -> {
            attributeRadioButtonActionPerformed(evt);
        });
        edgeRadioButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
        edgeRadioButton.setMargin(new Insets(0, 0, 0, 0));
        edgeRadioButton.addActionListener((ActionEvent evt) -> {
            attributeRadioButtonActionPerformed(evt);
        });
        networkRadioButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
        networkRadioButton.setMargin(new Insets(0, 0, 0, 0));
        networkRadioButton.addActionListener((ActionEvent evt) -> {
            attributeRadioButtonActionPerformed(evt);
        });
    }
    if (importType == ONTOLOGY_IMPORT) {
        panelBuilder = new OntologyPanelBuilder(this, factory, serviceRegistrar);
        panelBuilder.buildPanel();
    }
    if ((importType == TABLE_IMPORT) || (importType == NETWORK_IMPORT)) {
        // titleIconLabel.setIcon(SPREADSHEET_ICON_LARGE.getIcon());
        attributeFileLabel.setText("Input File");
        selectAttributeFileButton.setText("Select File(s)");
        selectAttributeFileButton.addActionListener((ActionEvent evt) -> {
            try {
                setPreviewPanel();
            } catch (Exception e) {
                JOptionPane.showMessageDialog(serviceRegistrar.getService(CySwingApplication.class).getJFrame(), "<html>Could not read selected file.<p>See <b>Help->Error Dialog</b> for further details.</html>", "Error", JOptionPane.ERROR_MESSAGE);
                logger.warn("Could not read selected file.", e);
            }
        });
    }
    /*
		 * Layout data for advanced panel
		 */
    if (importType == ONTOLOGY_IMPORT) {
        mappingAttributeComboBox.setEnabled(true);
        mappingAttributeComboBox.addActionListener((ActionEvent evt) -> {
            updateTypes(getPreviewPanel().getFileType());
            setKeyList();
        });
    }
    final ChangeListener delimitersChangeListener = new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent evt) {
            otherDelimiterTextField.setEnabled(otherCheckBox.isSelected());
            try {
                if (!updating)
                    updatePreview();
            } catch (IOException e) {
                logger.error("Error on ChangeEvent of checkbox " + ((JCheckBox) evt.getSource()).getText(), e);
            }
        }
    };
    commaCheckBox.addChangeListener(delimitersChangeListener);
    semicolonCheckBox.addChangeListener(delimitersChangeListener);
    spaceCheckBox.addChangeListener(delimitersChangeListener);
    tabCheckBox.addChangeListener(delimitersChangeListener);
    otherCheckBox.addChangeListener(delimitersChangeListener);
    otherDelimiterTextField.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent evt) {
        }

        @Override
        public void keyReleased(KeyEvent evt) {
            try {
                if (otherCheckBox.isSelected())
                    updatePreview();
            } catch (IOException e) {
                logger.error("Error on otherDelimiterTextField.keyReleased", e);
            }
        }

        @Override
        public void keyTyped(KeyEvent evt) {
        }
    });
    defaultInteractionTextField.setText(TypeUtil.DEFAULT_INTERACTION);
    defaultInteractionTextField.setToolTipText("<html>If <b>Default Interaction</b>" + " is selected, this value will be used for <i>Interaction Type</i><br></html>");
    globalLayout();
    if (basicPanel != null)
        basicPanel.repaint();
    this.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            getPreviewPanel().disposeEditDialog();
        }
    });
}
Also used : ToolTipManager(javax.swing.ToolTipManager) JRadioButton(javax.swing.JRadioButton) Insets(java.awt.Insets) MouseEvent(java.awt.event.MouseEvent) CySwingApplication(org.cytoscape.application.swing.CySwingApplication) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) IOException(java.io.IOException) JTextField(javax.swing.JTextField) IOException(java.io.IOException) InvalidFormatException(org.apache.poi.openxml4j.exceptions.InvalidFormatException) JAXBException(javax.xml.bind.JAXBException) JCheckBox(javax.swing.JCheckBox) KeyEvent(java.awt.event.KeyEvent) ChangeEvent(javax.swing.event.ChangeEvent) PropertyChangeEvent(java.beans.PropertyChangeEvent) IndexedPropertyChangeEvent(java.beans.IndexedPropertyChangeEvent) ButtonGroup(javax.swing.ButtonGroup) ChangeListener(javax.swing.event.ChangeListener) PropertyChangeListener(java.beans.PropertyChangeListener) KeyListener(java.awt.event.KeyListener)

Example 89 with JRadioButton

use of javax.swing.JRadioButton in project cytoscape-impl by cytoscape.

the class PrefsText method getFunctionPanel.

private AntiAliasedPanel getFunctionPanel() {
    if (fFunctionPanel == null) {
        VBox p = new VBox("Components", true, false);
        AntiAliasedPanel.setSizes(p, new Dimension(240, 220));
        for (int currTrait = 0; currTrait < kNumTextTraits; currTrait++) {
            fRadioButtons[currTrait] = new JRadioButton(kTraitNames[currTrait]);
            fRadioButtons[currTrait].setToolTipText(kTraitTooltips[currTrait]);
            final int trait = currTrait;
            fRadioButtons[currTrait].addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    changeCurrentTarget(trait);
                }
            });
            // fRadioButtons[currTrait].setFont(panelFont);
            btnGroup.add(fRadioButtons[currTrait]);
            p.add(new HBox(true, true, fRadioButtons[currTrait]));
        }
        fRadioButtons[0].setSelected(true);
        fBtnSetAllTT = new JButton("Use For All");
        fBtnSetAllTT.setToolTipText("Assign the current font information to nodes, edges, annotations, and legends");
        fBtnSetAllTT.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                updateAllTraits();
            }
        });
        // fBtnSetAllTT.setFont(panelFont);
        p.addSpacer();
        p.add(fBtnSetAllTT);
        p.addSpacer();
        p.add(Box.createVerticalGlue());
        p.addSpacer();
        fFunctionPanel = p;
    }
    return fFunctionPanel;
}
Also used : HBox(org.cytoscape.internal.prefs.lib.HBox) JRadioButton(javax.swing.JRadioButton) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) VBox(org.cytoscape.internal.prefs.lib.VBox)

Example 90 with JRadioButton

use of javax.swing.JRadioButton in project cytoscape-impl by cytoscape.

the class AbstractChartEditor method updateOrientation.

protected void updateOrientation() {
    final Orientation orientation = chart.get(ORIENTATION, Orientation.class, Orientation.VERTICAL);
    final JRadioButton orientRd = orientation == Orientation.HORIZONTAL ? getHorizontalRd() : getVerticalRd();
    getOrientationGrp().setSelected(orientRd.getModel(), true);
}
Also used : JRadioButton(javax.swing.JRadioButton) Orientation(org.cytoscape.ding.customgraphics.Orientation)

Aggregations

JRadioButton (javax.swing.JRadioButton)323 ButtonGroup (javax.swing.ButtonGroup)185 JPanel (javax.swing.JPanel)168 JLabel (javax.swing.JLabel)144 ActionEvent (java.awt.event.ActionEvent)104 ActionListener (java.awt.event.ActionListener)95 JTextField (javax.swing.JTextField)81 JButton (javax.swing.JButton)77 BoxLayout (javax.swing.BoxLayout)61 JCheckBox (javax.swing.JCheckBox)59 GridBagLayout (java.awt.GridBagLayout)57 BorderLayout (java.awt.BorderLayout)52 GridBagConstraints (java.awt.GridBagConstraints)52 Insets (java.awt.Insets)51 Dimension (java.awt.Dimension)45 FlowLayout (java.awt.FlowLayout)42 JScrollPane (javax.swing.JScrollPane)41 GridLayout (java.awt.GridLayout)32 JComboBox (javax.swing.JComboBox)32 ItemEvent (java.awt.event.ItemEvent)25