Example usage for javax.swing ButtonGroup ButtonGroup

List of usage examples for javax.swing ButtonGroup ButtonGroup

Introduction

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

Prototype

public ButtonGroup() 

Source Link

Document

Creates a new ButtonGroup.

Usage

From source file:com.mirth.connect.client.ui.panels.connectors.SourceSettingsPanel.java

private void initComponents() {
    setBackground(UIConstants.BACKGROUND_COLOR);
    setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Source Settings",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11)));

    sourceQueueLabel = new JLabel("Source Queue:");

    sourceQueueComboBox = new MirthComboBox();
    sourceQueueComboBox.setModel(new DefaultComboBoxModel(
            new String[] { "OFF (Respond after processing)", "ON (Respond before processing)" }));
    sourceQueueComboBox.setToolTipText(//from   www.  j a va2 s  .c o  m
            "<html>Selecting OFF will process the message before sending the response (can use response from destinations)<br>Selecting ON will queue messages and immediately send a response (cannot use response from destinations)</html>");
    sourceQueueComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            sourceQueueComboBoxActionPerformed(evt);
        }
    });

    queueWarningLabel = new JLabel("Queuing is not supported by the current message storage mode.");
    queueWarningLabel.setForeground(Color.RED);

    queueBufferSizeLabel = new JLabel("Queue Buffer Size:");
    queueBufferSizeField = new JTextField();
    queueBufferSizeField.setDocument(new MirthFieldConstraints(0, false, false, true));
    queueBufferSizeField.setToolTipText(
            "<html>The buffer size for the source queue.<br/>Up to this many connector messages may<br/>be held in memory at once when queuing.</html>");

    responseLabel = new JLabel("Response:");

    responseComboBox = new MirthComboBox();
    responseComboBox
            .setModel(new DefaultComboBoxModel(new String[] { "Auto-generate (After source transformer)",
                    "None", "Auto-generate (Before processing)", "Auto-generate (After source transformer)",
                    "Auto-generate (Destinations completed)", "Post-processor", "Destination 1" }));
    responseComboBox.setToolTipText(
            "<html>Select a destination's response, the postprocessor return value, or a response map variable.<br/>Select <b>\"Auto-generate\"</b> to send a response generated by the inbound data type using the raw message:<br/>&nbsp;- <b>Before processing:</b> Response generated before the channel processes the message (SENT status)<br/>&nbsp;- <b>After source transformer:</b> Response generated after the channel processes the message (source status)<br/>&nbsp;- <b>Destinations completed:</b> Response generated after the channel processes the message, with a status<br/>&nbsp;&nbsp;&nbsp;&nbsp;based on the destination statuses, using a precedence of ERROR, QUEUED, SENT, FILTERED<br/></html>");

    processBatchLabel = new JLabel("Process Batch:");
    ButtonGroup processBatchButtonGroup = new ButtonGroup();

    processBatchYesRadio = new MirthRadioButton("Yes");
    processBatchYesRadio.setBackground(getBackground());
    processBatchYesRadio.setToolTipText(
            "<html>Select Yes to enable batch processing. Batch messages are only supported if<br>the source connector's inbound properties contains a <b>Batch</b> section.</html>");
    processBatchYesRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            processBatchYesRadioActionPerformed(evt);
        }
    });
    processBatchButtonGroup.add(processBatchYesRadio);

    processBatchNoRadio = new MirthRadioButton("No");
    processBatchNoRadio.setBackground(getBackground());
    processBatchNoRadio.setToolTipText(
            "<html>Select Yes to enable batch processing. Batch messages are only supported if<br>the source connector's inbound properties contains a <b>Batch</b> section.</html>");
    processBatchNoRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            processBatchNoRadioActionPerformed(evt);
        }
    });
    processBatchButtonGroup.add(processBatchNoRadio);

    batchResponseLabel = new JLabel("Batch Response:");
    ButtonGroup batchResponseButtonGroup = new ButtonGroup();

    batchResponseFirstRadio = new MirthRadioButton("First");
    batchResponseFirstRadio.setBackground(getBackground());
    batchResponseFirstRadio.setToolTipText(
            "<html>Each message in the batch contains its own response that is generated via the method selected above.<br> Select either the response from the first or last message in the batch to be sent back to the originating system.</html>");
    batchResponseButtonGroup.add(batchResponseFirstRadio);

    batchResponseLastRadio = new MirthRadioButton("Last");
    batchResponseLastRadio.setBackground(getBackground());
    batchResponseLastRadio.setToolTipText(
            "<html>Each message in the batch contains its own response that is generated via the method selected above.<br> Select either the response from the first or last message in the batch to be sent back to the originating system.</html>");
    batchResponseButtonGroup.add(batchResponseLastRadio);

    processingThreadsLabel = new JLabel("Max Processing Threads:");

    processingThreadsField = new MirthTextField();
    processingThreadsField.setDocument(new MirthFieldConstraints(0, false, false, true));
    processingThreadsField.setToolTipText(
            "<html>The maximum number of messages that can process through<br/>the channel simultaneously. Note that when this value<br/>is greater than 1, message order is NOT guaranteed.</html>");
}

From source file:JDAC.JDAC.java

public static void searchForPorts() {
    portSubMenu.removeAll();//from   w ww  .j av  a  2s  .  c  o m

    Enumeration ports = CommPortIdentifier.getPortIdentifiers();
    ActionListener mPortListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            selectedPortName = e.getActionCommand();
        }
    };
    ButtonGroup sensorGroup = new ButtonGroup();

    while (ports.hasMoreElements()) {
        CommPortIdentifier curPort = (CommPortIdentifier) ports.nextElement();

        //get only serial ports
        if (curPort.getPortType() == CommPortIdentifier.PORT_SERIAL) {
            JRadioButtonMenuItem tmpRadioButton = new JRadioButtonMenuItem(curPort.getName());
            sensorGroup.add(tmpRadioButton);
            portSubMenu.add(tmpRadioButton);
            tmpRadioButton.addActionListener(mPortListener);

            portMap.put(curPort.getName(), curPort);
        }
    }
}

From source file:metdemo.Finance.Pluggable.java

protected void addBottomControls(final JPanel jp) {
    final JPanel control_panel = new JPanel();
    jp.add(control_panel, BorderLayout.SOUTH);
    control_panel.setLayout(new BorderLayout());
    final Box vertex_panel = Box.createVerticalBox();
    vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices"));
    final Box edge_panel = Box.createVerticalBox();
    edge_panel.setBorder(BorderFactory.createTitledBorder("Edges"));
    final Box both_panel = Box.createVerticalBox();

    control_panel.add(vertex_panel, BorderLayout.WEST);
    control_panel.add(edge_panel, BorderLayout.EAST);
    control_panel.add(both_panel, BorderLayout.CENTER);

    // set up vertex controls
    v_color = new JCheckBox("vertex seed coloring");
    v_color.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            vcf.setSeedColoring(v_color.isSelected());
        }/*w  w w. j a v a 2s  .c om*/
    });

    v_stroke = new JCheckBox("<html>vertex selection<p>stroke highlighting</html>");
    v_stroke.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            vsh.setHighlight(v_stroke.isSelected());
        }
    });

    v_labels = new JCheckBox("show vertex ranks (voltages)");
    v_labels.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (v_labels.isSelected())
                pr.setVertexStringer(vs);
            else
                pr.setVertexStringer(vs_none);
        }
    });

    v_shape = new JCheckBox("vertex degree shapes");
    v_shape.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            vssa.useFunnyShapes(v_shape.isSelected());
        }
    });

    v_size = new JCheckBox("vertex voltage size");
    v_size.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            vssa.setScaling(v_size.isSelected());
        }
    });
    v_aspect = new JCheckBox("vertex degree ratio stretch");
    v_aspect.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            vssa.setStretching(v_aspect.isSelected());
        }
    });

    v_small = new JCheckBox("filter vertices of degree < " + VertexDisplayPredicate.MIN_DEGREE);
    v_small.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            show_vertex.filterSmall(v_small.isSelected());
        }
    });

    vertex_panel.add(v_color);
    vertex_panel.add(v_stroke);
    vertex_panel.add(v_labels);
    vertex_panel.add(v_shape);
    vertex_panel.add(v_size);
    vertex_panel.add(v_aspect);
    vertex_panel.add(v_small);

    // set up edge controls
    JPanel gradient_panel = new JPanel(new GridLayout(1, 0));
    gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint"));
    no_gradient = new JRadioButton("Solid color");
    no_gradient.setSelected(true);
    no_gradient.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            gradient_level = GRADIENT_NONE;
        }
    });
    //      gradient_absolute = new JRadioButton("Absolute gradient");
    //      gradient_absolute.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { gradient_level = GRADIENT_ABSOLUTE;}});
    gradient_relative = new JRadioButton("Gradient");
    gradient_relative.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            gradient_level = GRADIENT_RELATIVE;
        }
    });

    ButtonGroup bg_grad = new ButtonGroup();
    bg_grad.add(no_gradient);
    bg_grad.add(gradient_relative);
    //bg_grad.add(gradient_absolute);
    gradient_panel.add(no_gradient);
    //gradientGrid.add(gradient_absolute);
    gradient_panel.add(gradient_relative);

    JPanel shape_panel = new JPanel(new GridLayout(3, 2));
    shape_panel.setBorder(BorderFactory.createTitledBorder("Edge shape"));
    e_line = new JRadioButton("line");
    e_line.setSelected(true);
    e_line.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            pr.setEdgeShapeFunction(new EdgeShape.Line());
        }
    });
    //        e_bent = new JRadioButton("bent line");
    //        e_bent.setSelected(true);
    e_wedge = new JRadioButton("wedge");
    e_wedge.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            pr.setEdgeShapeFunction(new EdgeShape.Wedge(10));
        }
    });
    e_quad = new JRadioButton("quad curve");
    e_quad.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            pr.setEdgeShapeFunction(new EdgeShape.QuadCurve());
        }
    });
    e_cubic = new JRadioButton("cubic curve");
    e_cubic.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            pr.setEdgeShapeFunction(new EdgeShape.CubicCurve());
        }
    });
    ButtonGroup bg_shape = new ButtonGroup();
    bg_shape.add(e_line);
    //        bg.add(e_bent);
    bg_shape.add(e_wedge);
    bg_shape.add(e_quad);
    bg_shape.add(e_cubic);
    shape_panel.add(e_line);
    //        shape_panel.add(e_bent);
    shape_panel.add(e_wedge);
    shape_panel.add(e_quad);
    shape_panel.add(e_cubic);
    fill_edges = new JCheckBox("fill edge shapes");
    fill_edges.setSelected(false);
    fill_edges.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            edgePaint.useFill(fill_edges.isSelected());
        }
    });
    shape_panel.add(fill_edges);
    shape_panel.setOpaque(true);
    e_color = new JCheckBox("edge weight highlighting");
    e_color.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ewcs.setWeighted(e_color.isSelected());
        }
    });

    e_labels = new JCheckBox("show edge weights");
    e_labels.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (e_labels.isSelected())
                pr.setEdgeStringer(es);
            else
                pr.setEdgeStringer(es_none);
        }
    });

    e_uarrow_pred = new JCheckBox("undirected");
    e_uarrow_pred.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            show_arrow.showUndirected(e_uarrow_pred.isSelected());
        }
    });
    e_darrow_pred = new JCheckBox("directed");
    e_darrow_pred.setSelected(true);
    e_darrow_pred.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            show_arrow.showDirected(e_darrow_pred.isSelected());
        }
    });
    JPanel arrow_panel = new JPanel(new GridLayout(1, 0));
    arrow_panel.setBorder(BorderFactory.createTitledBorder("Show arrows"));
    arrow_panel.add(e_uarrow_pred);
    arrow_panel.add(e_darrow_pred);

    e_show_d = new JCheckBox("directed");
    e_show_d.setSelected(true);
    e_show_d.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            show_edge.showDirected(e_show_d.isSelected());
        }
    });
    e_show_u = new JCheckBox("undirected");
    e_show_u.setSelected(true);
    e_show_u.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            show_edge.showUndirected(e_show_u.isSelected());
        }
    });
    JPanel show_edge_panel = new JPanel(new GridLayout(1, 0));
    show_edge_panel.setBorder(BorderFactory.createTitledBorder("Show edges"));
    show_edge_panel.add(e_show_u);
    show_edge_panel.add(e_show_d);

    shape_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(shape_panel);
    gradient_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(gradient_panel);
    show_edge_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(show_edge_panel);
    arrow_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(arrow_panel);

    e_color.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(e_color);
    e_labels.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(e_labels);

    // set up zoom controls
    zoom_at_mouse = new JCheckBox("<html><center>zoom at mouse<p>(wheel only)</center></html>");
    zoom_at_mouse.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            gm.setZoomAtMouse(zoom_at_mouse.isSelected());
        }
    });
    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // call listener in GraphMouse instead of manipulating vv scale directly
            // this is so the crossover from zoom to scale works with the buttons
            // as well as with the mouse wheel
            Dimension d = vv.getSize();
            gm.mouseWheelMoved(new MouseWheelEvent(vv, MouseEvent.MOUSE_WHEEL, System.currentTimeMillis(), 0,
                    d.width / 2, d.height / 2, 1, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, 1));
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // call listener in GraphMouse instead of manipulating vv scale directly
            // this is so the crossover from zoom to scale works with the buttons
            // as well as with the mouse wheel
            Dimension d = vv.getSize();
            gm.mouseWheelMoved(new MouseWheelEvent(vv, MouseEvent.MOUSE_WHEEL, System.currentTimeMillis(), 0,
                    d.width / 2, d.height / 2, 1, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, -1));
        }
    });
    Box zoomPanel = Box.createVerticalBox();
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom"));
    plus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(plus);
    minus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(minus);
    zoom_at_mouse.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(zoom_at_mouse);

    // add font and zoom controls to center panel
    font = new JCheckBox("bold text");
    font.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ff.setBold(font.isSelected());
        }
    });
    font.setAlignmentX(Component.CENTER_ALIGNMENT);

    both_panel.add(zoomPanel);
    both_panel.add(font);

    JComboBox modeBox = gm.getModeComboBox();
    modeBox.setAlignmentX(Component.CENTER_ALIGNMENT);
    JPanel modePanel = new JPanel(new BorderLayout()) {
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);
    both_panel.add(modePanel);
}

From source file:com.diversityarrays.kdxplore.trials.AddScoringSetDialog.java

private Box createWantSampleButtons(SampleGroup curatedSampleGroup) {
    Box result = null;//from  ww  w  . ja v  a 2  s. c  o  m
    ActionListener rbListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            wantSampleValues = noSampleValuesButton != e.getSource();
        }
    };

    result = Box.createHorizontalBox();
    String noSampleValues = Msg.OPTION_NO_SAMPLE_VALUES();
    ButtonGroup bg = new ButtonGroup();
    for (String rbname : new String[] { noSampleValues, Msg.OPTION_CURATED_SAMPLE_VALUES() }) {
        JRadioButton rb = new JRadioButton(rbname);
        result.add(rb);
        bg.add(rb);
        rb.addActionListener(rbListener);
        if (noSampleValues.equals(rbname)) {
            noSampleValuesButton = rb;
        } else {
            rb.doClick();
        }
    }
    result.add(Box.createHorizontalGlue());

    return result;
}

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

/**
     * Creates new form FAdmin//from   w w  w .  j  a  va 2s. co  m
     */
    public FAdmin() {
        addWindowListener(new WindowListener() {

            @Override
            public void windowOpened(WindowEvent e) {
            }

            @Override
            public void windowClosing(WindowEvent e) {
                timer.stop();
            }

            @Override
            public void windowClosed(WindowEvent e) {
            }

            @Override
            public void windowIconified(WindowEvent e) {
            }

            @Override
            public void windowDeiconified(WindowEvent e) {
            }

            @Override
            public void windowActivated(WindowEvent e) {
                Uses.closeSplash();
            }

            @Override
            public void windowDeactivated(WindowEvent e) {
            }
        });
        initComponents();

        setTitle(getTitle() + " " + Uses.getLocaleMessage("project.name" + FAbout.getCMRC_SUFF()));

        try {
            setIconImage(
                    ImageIO.read(FAdmin.class.getResource("/ru/apertum/qsystem/client/forms/resources/admin.png")));
        } catch (IOException ex) {
            System.err.println(ex);
        }

        // 
        final Toolkit kit = Toolkit.getDefaultToolkit();
        setLocation((Math.round(kit.getScreenSize().width - getWidth()) / 2),
                (Math.round(kit.getScreenSize().height - getHeight()) / 2));
        // ? ?
        final JFrame fr = this;
        tray = QTray.getInstance(fr, "/ru/apertum/qsystem/client/forms/resources/admin.png",
                getLocaleMessage("tray.caption"));
        tray.addItem(getLocaleMessage("tray.caption"), (ActionEvent e) -> {
            setVisible(true);
            setState(JFrame.NORMAL);
        });
        tray.addItem("-", (ActionEvent e) -> {
        });
        tray.addItem(getLocaleMessage("tray.exit"), (ActionEvent e) -> {
            dispose();
            System.exit(0);
        });

        int ii = 1;
        final ButtonGroup bg = new ButtonGroup();
        final String currLng = Locales.getInstance().getLangCurrName();
        for (String lng : Locales.getInstance().getAvailableLocales()) {
            final JRadioButtonMenuItem item = new JRadioButtonMenuItem(
                    org.jdesktop.application.Application.getInstance(ru.apertum.qsystem.QSystem.class).getContext()
                            .getActionMap(FAdmin.class, fr).get("setCurrentLang"));
            bg.add(item);
            item.setSelected(lng.equals(currLng));
            item.setText(lng); // NOI18N
            item.setName("QRadioButtonMenuItem" + (ii++)); // NOI18N
            menuLangs.add(item);
        }

        //  ??    ??.
        listUsers.addListSelectionListener((ListSelectionEvent e) -> {
            userListChange();
        });
        //  ??    ??.
        listResponse.addListSelectionListener((ListSelectionEvent e) -> {
            responseListChange();
        });
        listSchedule.addListSelectionListener((ListSelectionEvent e) -> {
            scheduleListChange();
        });
        listCalendar.addListSelectionListener(new ListSelectionListener() {

            private int oldSelectedValue = 0;
            private int tmp = 0;

            public int getOldSelectedValue() {
                return oldSelectedValue;
            }

            public void setOldSelectedValue(int oldSelectedValue) {
                this.oldSelectedValue = tmp;
                this.tmp = oldSelectedValue;
            }

            private boolean canceled = false;

            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (canceled) {
                    canceled = false;
                } else {
                    if (tableCalendar.getModel() instanceof CalendarTableModel) {
                        final CalendarTableModel model = (CalendarTableModel) tableCalendar.getModel();
                        if (!model.isSaved()) {
                            final int res = JOptionPane.showConfirmDialog(null,
                                    getLocaleMessage("calendar.change.title"),
                                    getLocaleMessage("calendar.change.caption"), JOptionPane.YES_NO_CANCEL_OPTION,
                                    JOptionPane.QUESTION_MESSAGE);
                            switch (res) {
                            case 0: // ?  ??
                                model.save();
                                calendarListChange();
                                setOldSelectedValue(listCalendar.getSelectedIndex());
                                break;
                            case 1: // ??  ??

                                calendarListChange();
                                setOldSelectedValue(listCalendar.getSelectedIndex());

                                break;
                            case 2: //  ??  ???   
                                canceled = true;
                                listCalendar.setSelectedIndex(getOldSelectedValue());
                                break;
                            }
                        } else {
                            calendarListChange();
                            setOldSelectedValue(listCalendar.getSelectedIndex());
                        }
                    } else {
                        calendarListChange();
                        setOldSelectedValue(listCalendar.getSelectedIndex());
                    }
                }
            }
        });
        //  ??  ?  ??.
        treeServices.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        treeInfo.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        /*
         treeServices.setCellRenderer(new DefaultTreeCellRenderer() {
            
         @Override
         public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
         super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
         setText(((Element) value).attributeValue(Uses.TAG_NAME));
         return this;
         }
         });*/
        treeServices.addTreeSelectionListener((TreeSelectionEvent e) -> {
            serviceListChange();
        });
        treeInfo.addTreeSelectionListener((TreeSelectionEvent e) -> {
            infoListChange();
        });

        textFieldStartTime.setInputVerifier(DateVerifier);
        textFieldFinishTime.setInputVerifier(DateVerifier);

        // ?
        loadSettings();
        //   ? ?.
        startTimer();
        //  
        loadConfig();

        spinnerPropServerPort.getModel().addChangeListener(new ChangeNet());
        spinnerPropClientPort.getModel().addChangeListener(new ChangeNet());
        spinnerWebServerPort.getModel().addChangeListener(new ChangeNet());

        spinnerServerPort.getModel().addChangeListener(new ChangeSettings());
        spinnerClientPort.getModel().addChangeListener(new ChangeSettings());
        spinnerUserRS.getModel().addChangeListener(new ChangeUser());

        //?   .
        final Helper helper = Helper.getHelp("ru/apertum/qsystem/client/help/admin.hs");
        helper.setHelpListener(menuItemHelp);
        helper.enableHelpKey(jPanel1, "introduction");
        helper.enableHelpKey(jPanel3, "monitoring");
        helper.enableHelpKey(jPanel4, "configuring");
        helper.enableHelpKey(jPanel8, "net");

        helper.enableHelpKey(jPanel17, "schedulers");
        helper.enableHelpKey(jPanel19, "calendars");
        helper.enableHelpKey(jPanel2, "infoSystem");
        helper.enableHelpKey(jPanel13, "responses");
        helper.enableHelpKey(jPanel18, "results");

        treeServices.setTransferHandler(new TransferHandler() {

            @Override
            public boolean canImport(TransferHandler.TransferSupport info) {
                final JTree.DropLocation dl = (JTree.DropLocation) info.getDropLocation();
                if (dl.getChildIndex() == -1) {
                    return false;
                }
                // Get the string that is being dropped.
                final Transferable t = info.getTransferable();
                final QService data;
                try {
                    data = (QService) t.getTransferData(DataFlavor.stringFlavor);
                    return (data.getParent().getId()
                            .equals(((QService) dl.getPath().getLastPathComponent()).getId()));
                } catch (UnsupportedFlavorException | IOException e) {
                    return false;
                }
            }

            @Override
            public boolean importData(TransferHandler.TransferSupport info) {
                if (!info.isDrop()) {
                    return false;
                }
                final QService data;
                try {
                    data = (QService) info.getTransferable().getTransferData(DataFlavor.stringFlavor);
                } catch (UnsupportedFlavorException | IOException e) {
                    System.err.println(e);
                    return false;
                }
                final JTree.DropLocation dl = (JTree.DropLocation) info.getDropLocation();
                final TreePath tp = dl.getPath();
                final QService parent = (QService) tp.getLastPathComponent();
                ((QServiceTree) treeServices.getModel()).moveNode(data, parent, dl.getChildIndex());
                return true;
            }

            @Override
            public int getSourceActions(JComponent c) {
                return MOVE;
            }

            @Override
            protected Transferable createTransferable(JComponent c) {
                return (QService) ((JTree) c).getLastSelectedPathComponent();
            }
        });
        treeServices.setDropMode(DropMode.INSERT);

        //   ?
        final AnnotationSessionFactoryBean as = (AnnotationSessionFactoryBean) Spring.getInstance().getFactory()
                .getBean("conf");
        if (as.getServers().size() > 1) {
            final JMenu menu = new JMenu(getLocaleMessage("admin.servers"));
            as.getServers().stream().map((ser) -> {
                final JMenuItem mi1 = new JMenuItem(as);
                mi1.setText(ser.isCurrent() ? "<html><u><i>" + ser.getName() + "</i></u>" : ser.getName());
                return mi1;
            }).forEach((mi1) -> {
                menu.add(mi1);
            });
            jMenuBar1.add(menu, 4);
            jMenuBar1.add(new JLabel(
                    "<html><span style='font-size:13.0pt;color:red'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  ["
                            + as.getName() + "]"));
        }
        comboBoxVoices.setVisible(false);
    }

From source file:com.microsoft.azure.hdinsight.spark.ui.SparkSubmissionContentPanel.java

private void addSelectedArtifactLineItem() {
    final String tipInfo = "The Artifact you want to use.";
    JLabel artifactSelectLabel = new JLabel("Select an Artifact to submit");
    artifactSelectLabel.setToolTipText(tipInfo);

    selectedArtifactComboBox = new ComboBox();
    selectedArtifactComboBox.setToolTipText(tipInfo);

    errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()] = new JLabel(
            "Artifact should not be null!");
    errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()]
            .setForeground(DarkThemeManager.getInstance().getErrorMessageColor());
    errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()].setVisible(false);

    errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()] = new JLabel(
            "Could not find the local jar package for Artifact");
    errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()]
            .setForeground(DarkThemeManager.getInstance().getErrorMessageColor());
    errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()].setVisible(false);

    selectedArtifactTextField = new TextFieldWithBrowseButton();
    selectedArtifactTextField.setToolTipText("Artifact from local jar package.");
    selectedArtifactTextField.setEditable(true);
    selectedArtifactTextField.setEnabled(false);
    selectedArtifactTextField.getTextField().getDocument().addDocumentListener(new DocumentListener() {
        @Override/* w  w  w.  jav  a2 s  .  c o  m*/
        public void insertUpdate(DocumentEvent e) {
            setVisibleForFixedErrorMessageLabel(2,
                    !SparkSubmitHelper.isLocalArtifactPath(selectedArtifactTextField.getText()));
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            setVisibleForFixedErrorMessageLabel(2,
                    !SparkSubmitHelper.isLocalArtifactPath(selectedArtifactTextField.getText()));
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            setVisibleForFixedErrorMessageLabel(2,
                    !SparkSubmitHelper.isLocalArtifactPath(selectedArtifactTextField.getText()));
        }
    });

    selectedArtifactTextField.getButton().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(false, false, true, false, true,
                    false);
            chooserDescriptor.setTitle("Select Local Artifact File");
            VirtualFile chooseFile = FileChooser.chooseFile(chooserDescriptor, null, null);
            if (chooseFile != null) {
                String path = chooseFile.getPath();
                if (path.endsWith("!/")) {
                    path = path.substring(0, path.length() - 2);
                }
                selectedArtifactTextField.setText(path);
            }
        }
    });

    intelliJArtifactRadioButton = new JRadioButton("Artifact from IntelliJ project:", true);
    localArtifactRadioButton = new JRadioButton("Artifact from local disk:", false);

    intelliJArtifactRadioButton.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                selectedArtifactComboBox.setEnabled(true);
                selectedArtifactTextField.setEnabled(false);
                mainClassTextField.setButtonEnabled(true);

                setVisibleForFixedErrorMessageLabel(2, false);

                if (selectedArtifactComboBox.getItemCount() == 0) {
                    setVisibleForFixedErrorMessageLabel(2, true);
                }
            }
        }
    });

    localArtifactRadioButton.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                selectedArtifactComboBox.setEnabled(false);
                selectedArtifactTextField.setEnabled(true);
                mainClassTextField.setButtonEnabled(false);

                setVisibleForFixedErrorMessageLabel(1, false);

                if (StringHelper.isNullOrWhiteSpace(selectedArtifactTextField.getText())) {
                    setVisibleForFixedErrorMessageLabel(2, true);
                }
            }
        }
    });

    ButtonGroup group = new ButtonGroup();
    group.add(intelliJArtifactRadioButton);
    group.add(localArtifactRadioButton);

    intelliJArtifactRadioButton.setSelected(true);

    add(artifactSelectLabel, new GridBagConstraints(0, ++displayLayoutCurrentRow, 0, 1, 0, 0,
            GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, margin), 0, 0));

    add(intelliJArtifactRadioButton,
            new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.WEST,
                    GridBagConstraints.NONE, new Insets(margin / 3, margin * 3, 0, margin), 0, 0));

    add(selectedArtifactComboBox,
            new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST,
                    GridBagConstraints.HORIZONTAL, new Insets(margin / 3, margin, 0, margin), 0, 0));

    add(errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()],
            new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST,
                    GridBagConstraints.NONE, new Insets(0, margin, 0, 0), 0, 0));

    add(localArtifactRadioButton,
            new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.WEST,
                    GridBagConstraints.NONE, new Insets(margin / 3, margin * 3, 0, margin), 0, 0));

    add(selectedArtifactTextField,
            new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 0, 0, GridBagConstraints.WEST,
                    GridBagConstraints.HORIZONTAL, new Insets(margin / 3, margin, 0, margin), 0, 0));
    add(errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()],
            new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST,
                    GridBagConstraints.NONE, new Insets(0, margin, 0, 0), 0, 0));
}

From source file:com.mirth.connect.plugins.datapruner.DataPrunerPanel.java

private void initComponents() {
    setBackground(UIConstants.BACKGROUND_COLOR);

    statusPanel = new JPanel();
    statusPanel.setBackground(UIConstants.BACKGROUND_COLOR);
    statusPanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Status",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11)));

    currentStateLabel = new JLabel("Current State:");
    currentStateTextLabel = new JLabel("Unknown");

    currentProcessLabel = new JLabel("Current Process:");
    currentProcessTextLabel = new JLabel("Unknown");

    lastProcessLabel = new JLabel("Last Process:");
    lastProcessTextLabel = new JLabel("Unknown");

    nextProcessLabel = new JLabel("Next Process:");
    nextProcessTextLabel = new JLabel("Unknown");

    pruningSchedulePanel = new JPanel();
    pruningSchedulePanel.setBackground(UIConstants.BACKGROUND_COLOR);
    pruningSchedulePanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Schedule",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
            new java.awt.Font("Tahoma", 1, 11)));

    enabledLabel = new JLabel("Enable:");

    yesEnabledRadio = new MirthRadioButton("Yes");
    yesEnabledRadio.setFocusable(false);
    yesEnabledRadio.setBackground(Color.white);
    yesEnabledRadio.addActionListener(new ActionListener() {
        @Override/*  www.ja  va  2s  . c o m*/
        public void actionPerformed(ActionEvent event) {
            enabledActionPerformed();
        }
    });

    noEnabledRadio = new MirthRadioButton("No");
    noEnabledRadio.setFocusable(false);
    noEnabledRadio.setBackground(Color.white);
    noEnabledRadio.setSelected(true);
    noEnabledRadio.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            enabledActionPerformed();
        }
    });

    enabledButtonGroup = new ButtonGroup();
    enabledButtonGroup.add(yesEnabledRadio);
    enabledButtonGroup.add(noEnabledRadio);

    pollingSettingsPanel = new PollingSettingsPanel(false);

    pruneSettingsPanel = new JPanel();
    pruneSettingsPanel.setBackground(UIConstants.BACKGROUND_COLOR);
    pruneSettingsPanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Prune Settings",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11))); // NOI18N

    blockSizeLabel = new JLabel("Block Size:");
    blockSizeTextField = new MirthTextField();
    blockSizeTextField.setToolTipText(
            "<html>The number of messages that will be pruned at a time. This value must<br/>be between 50 and 10000. The recommended value for most servers is 1000.</html>");

    pruneEventsLabel = new JLabel("Prune Events:");

    pruneEventsYes = new MirthRadioButton("Yes");
    pruneEventsYes.setBackground(UIConstants.BACKGROUND_COLOR);
    pruneEventsYes.setToolTipText(
            "<html>If Yes, event records older than the Event Age will be pruned. If No, event records will not be pruned.</html>");
    pruneEventsYes.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            pruneEventsActionPerformed(evt);
        }
    });

    pruneEventsNo = new MirthRadioButton("No");
    pruneEventsNo.setBackground(UIConstants.BACKGROUND_COLOR);
    pruneEventsNo.setToolTipText(
            "<html>If Yes, event records will be pruned in addition to messages. If No, event records will not be pruned.</html>");
    pruneEventsNo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            pruneEventsActionPerformed(evt);
        }
    });

    pruneEventsButtonGroup = new ButtonGroup();
    pruneEventsButtonGroup.add(pruneEventsYes);
    pruneEventsButtonGroup.add(pruneEventsNo);

    pruneEventAgeLabel = new JLabel("Prune Event Age:");

    pruneEventAgeTextField = new MirthTextField();
    pruneEventAgeTextField.setToolTipText(
            "<html>Events older than this number of days will be pruned if Prune Events is set to Yes.</html>");

    eventDaysLabel = new JLabel("days");
    eventDaysLabel.setEnabled(false);

    archiverContainerPanel = new JPanel();
    archiverContainerPanel.setBackground(UIConstants.BACKGROUND_COLOR);
    archiverContainerPanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Archive Settings",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11))); // NOI18N
    archiverContainerPanel.setLayout(null);

    archiverPanel = new MessageExportPanel(Frame.userPreferences, true, false);
    archiverPanel.setBackground(archiverContainerPanel.getBackground());
    archiverContainerPanel.setLayout(new MigLayout("fillx, insets 0 0 0 0", "[grow,fill]", "[grow,fill]"));
    archiverContainerPanel.add(archiverPanel, "height 195!, aligny top");

    enabledActionPerformed();
}

From source file:cl.almejo.vsim.gui.SimWindow.java

private void addMainToolbar() {
    JToolBar toolBar = new JToolBar();
    toolBar.add(newToolbarButton(NEW_ACTION));
    toolBar.add(newToolbarButton(OPEN_ACTION));
    toolBar.add(newToolbarButton(SAVE_ACTION));

    toolBar.addSeparator();/*  www  .  jav  a2s .c om*/

    toolBar.add(newToolbarButton(UNDO_ACTION));
    toolBar.add(newToolbarButton(REDO_ACTION));
    toolBar.add(newToolbarButton(CUT_ACTION));
    toolBar.add(newToolbarButton(COPY_ACTION));
    toolBar.add(newToolbarButton(PASTE_ACTION));

    toolBar.addSeparator();
    ButtonGroup group = new ButtonGroup();

    toolBar.add(newGrouppedButton(START_ACTION, group));
    toolBar.add(newGrouppedButton(PAUSE_ACTION, group));

    getContentPane().add(toolBar, BorderLayout.NORTH);
}

From source file:net.sf.taverna.t2.activities.spreadsheet.views.SpreadsheetImportConfigView.java

@Override
protected void initialise() {
    super.initialise();
    newConfiguration = getJson().deepCopy();

    // title/*from w ww .  j  ava  2  s.  c o m*/
    titlePanel = new JPanel(new BorderLayout());
    titlePanel.setBackground(Color.WHITE);
    addDivider(titlePanel, SwingConstants.BOTTOM, true);

    titleLabel = new JLabel(SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.panelTitle"));
    titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 13.5f));
    titleIcon = new JLabel("");
    titleMessage = new DialogTextArea(DEFAULT_MESSAGE);
    titleMessage.setMargin(new Insets(5, 10, 10, 10));
    // titleMessage.setMinimumSize(new Dimension(0, 30));
    titleMessage.setFont(titleMessage.getFont().deriveFont(11f));
    titleMessage.setEditable(false);
    titleMessage.setFocusable(false);
    // titleMessage.setFont(titleLabel.getFont().deriveFont(Font.PLAIN,
    // 12f));

    // column range
    columnLabel = new JLabel(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.columnSectionLabel"));

    JsonNode columnRange = newConfiguration.get("columnRange");
    columnFromValue = new JTextField(new UpperCaseDocument(),
            SpreadsheetUtils.getColumnLabel(columnRange.get("start").intValue()), 4);
    columnFromValue.setMinimumSize(columnFromValue.getPreferredSize());
    columnToValue = new JTextField(new UpperCaseDocument(),
            SpreadsheetUtils.getColumnLabel(columnRange.get("end").intValue()), 4);
    columnToValue.setMinimumSize(columnToValue.getPreferredSize());

    columnFromValue.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
        }

        public void insertUpdate(DocumentEvent e) {
            checkValue(columnFromValue.getText());
        }

        public void removeUpdate(DocumentEvent e) {
            checkValue(columnFromValue.getText());
        }

        private void checkValue(String text) {
            if (text.trim().equals("")) {
                addErrorMessage(EMPTY_FROM_COLUMN_ERROR_MESSAGE);
            } else if (text.trim().matches("[A-Za-z]+")) {
                String fromColumn = columnFromValue.getText().toUpperCase();
                String toColumn = columnToValue.getText().toUpperCase();
                int fromColumnIndex = SpreadsheetUtils.getColumnIndex(fromColumn);
                int toColumnIndex = SpreadsheetUtils.getColumnIndex(toColumn);
                if (checkColumnRange(fromColumnIndex, toColumnIndex)) {
                    columnMappingTableModel.setFromColumn(fromColumnIndex);
                    columnMappingTableModel.setToColumn(toColumnIndex);
                    newConfiguration.set("columnRange", newConfiguration.objectNode()
                            .put("start", fromColumnIndex).put("end", toColumnIndex));
                    validatePortNames();
                }
                removeErrorMessage(FROM_COLUMN_ERROR_MESSAGE);
                removeErrorMessage(EMPTY_FROM_COLUMN_ERROR_MESSAGE);
            } else {
                addErrorMessage(FROM_COLUMN_ERROR_MESSAGE);
                removeErrorMessage(EMPTY_FROM_COLUMN_ERROR_MESSAGE);
            }
        }

    });

    columnToValue.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
        }

        public void insertUpdate(DocumentEvent e) {
            checkValue(columnToValue.getText());
        }

        public void removeUpdate(DocumentEvent e) {
            checkValue(columnToValue.getText());
        }

        private void checkValue(String text) {
            if (text.trim().equals("")) {
                addErrorMessage(EMPTY_TO_COLUMN_ERROR_MESSAGE);
            } else if (text.trim().matches("[A-Za-z]+")) {
                String fromColumn = columnFromValue.getText().toUpperCase();
                String toColumn = columnToValue.getText().toUpperCase();
                int fromColumnIndex = SpreadsheetUtils.getColumnIndex(fromColumn);
                int toColumnIndex = SpreadsheetUtils.getColumnIndex(toColumn);
                if (checkColumnRange(fromColumnIndex, toColumnIndex)) {
                    columnMappingTableModel.setFromColumn(fromColumnIndex);
                    columnMappingTableModel.setToColumn(toColumnIndex);
                    newConfiguration.set("columnRange", newConfiguration.objectNode()
                            .put("start", fromColumnIndex).put("end", toColumnIndex));
                    validatePortNames();
                }
                removeErrorMessage(TO_COLUMN_ERROR_MESSAGE);
                removeErrorMessage(EMPTY_TO_COLUMN_ERROR_MESSAGE);

            } else {
                addErrorMessage(TO_COLUMN_ERROR_MESSAGE);
                removeErrorMessage(EMPTY_TO_COLUMN_ERROR_MESSAGE);
            }
        }
    });

    // row range
    rowLabel = new JLabel(SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.rowSectionLabel"));
    addDivider(rowLabel, SwingConstants.TOP, false);

    rowSelectAllOption = new JCheckBox(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.selectAllRowsOption"));
    rowExcludeFirstOption = new JCheckBox(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.excludeHeaderRowOption"));
    rowIgnoreBlankRows = new JCheckBox(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.ignoreBlankRowsOption"));
    rowSelectAllOption.setFocusable(false);
    rowExcludeFirstOption.setFocusable(false);

    JsonNode rowRange = newConfiguration.get("rowRange");
    rowFromValue = new JTextField(new NumericDocument(), String.valueOf(rowRange.get("start").intValue() + 1),
            4);
    if (rowRange.get("end").intValue() == -1) {
        rowToValue = new JTextField(new NumericDocument(), "", 4);
    } else {
        rowToValue = new JTextField(new NumericDocument(), String.valueOf(rowRange.get("end").intValue() + 1),
                4);
    }
    rowFromValue.setMinimumSize(rowFromValue.getPreferredSize());
    rowToValue.setMinimumSize(rowToValue.getPreferredSize());

    if (newConfiguration.get("allRows").booleanValue()) {
        rowSelectAllOption.setSelected(true);
        rowFromValue.setEditable(false);
        rowFromValue.setEnabled(false);
        rowToValue.setEditable(false);
        rowToValue.setEnabled(false);
    } else {
        rowExcludeFirstOption.setEnabled(false);
    }
    rowExcludeFirstOption.setSelected(newConfiguration.get("excludeFirstRow").booleanValue());
    rowIgnoreBlankRows.setSelected(newConfiguration.get("ignoreBlankRows").booleanValue());

    rowFromValue.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
        }

        public void insertUpdate(DocumentEvent e) {
            checkValue(rowFromValue.getText());
        }

        public void removeUpdate(DocumentEvent e) {
            checkValue(rowFromValue.getText());
        }

        private void checkValue(String text) {
            if (text.trim().equals("")) {
                addErrorMessage(EMPTY_FROM_ROW_ERROR_MESSAGE);
            } else if (text.trim().matches("[1-9][0-9]*")) {
                checkRowRange(rowFromValue.getText(), rowToValue.getText());
                int fromRow = Integer.parseInt(rowFromValue.getText());
                ((ObjectNode) newConfiguration.get("rowRange")).put("start", fromRow - 1);
                removeErrorMessage(FROM_ROW_ERROR_MESSAGE);
                removeErrorMessage(EMPTY_FROM_ROW_ERROR_MESSAGE);
            } else {
                addErrorMessage(FROM_ROW_ERROR_MESSAGE);
                removeErrorMessage(EMPTY_FROM_ROW_ERROR_MESSAGE);
            }
        }
    });

    rowToValue.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
        }

        public void insertUpdate(DocumentEvent e) {
            checkValue(rowToValue.getText());
        }

        public void removeUpdate(DocumentEvent e) {
            checkValue(rowToValue.getText());
        }

        private void checkValue(String text) {
            if (text.trim().equals("")) {
                ((ObjectNode) newConfiguration.get("rowRange")).put("end", -1);
                removeErrorMessage(TO_ROW_ERROR_MESSAGE);
                removeErrorMessage(INCONSISTENT_ROW_MESSAGE);
            } else if (text.trim().matches("[0-9]+")) {
                checkRowRange(rowFromValue.getText(), rowToValue.getText());
                int toRow = Integer.parseInt(rowToValue.getText());
                ((ObjectNode) newConfiguration.get("rowRange")).put("end", toRow - 1);
                removeErrorMessage(TO_ROW_ERROR_MESSAGE);
            } else {
                addErrorMessage(TO_ROW_ERROR_MESSAGE);
            }
        }
    });

    rowSelectAllOption.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                newConfiguration.put("allRows", true);
                rowExcludeFirstOption.setEnabled(true);
                if (rowExcludeFirstOption.isSelected()) {
                    rowFromValue.setText("2");
                } else {
                    rowFromValue.setText("1");
                }
                rowToValue.setText("");
                rowFromValue.setEditable(false);
                rowFromValue.setEnabled(false);
                rowToValue.setEditable(false);
                rowToValue.setEnabled(false);
            } else {
                newConfiguration.put("allRows", false);
                rowExcludeFirstOption.setEnabled(false);
                rowFromValue.setEditable(true);
                rowFromValue.setEnabled(true);
                rowToValue.setEditable(true);
                rowToValue.setEnabled(true);
            }
        }
    });

    rowExcludeFirstOption.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                newConfiguration.put("excludeFirstRow", true);
                rowFromValue.setText("2");
                ((ObjectNode) newConfiguration.get("rowRange")).put("start", 1);
            } else {
                newConfiguration.put("excludeFirstRow", false);
                rowFromValue.setText("1");
                ((ObjectNode) newConfiguration.get("rowRange")).put("start", 0);
            }
        }
    });

    rowIgnoreBlankRows.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            newConfiguration.put("ignoreBlankRows", e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    // empty cells
    emptyCellLabel = new JLabel(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.emptyCellSectionLabel"));
    addDivider(emptyCellLabel, SwingConstants.TOP, false);

    emptyCellButtonGroup = new ButtonGroup();
    emptyCellEmptyStringOption = new JRadioButton(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.emptyStringOption"));
    emptyCellUserDefinedOption = new JRadioButton(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.userDefinedOption"));
    emptyCellErrorValueOption = new JRadioButton(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.generateErrorOption"));
    emptyCellEmptyStringOption.setFocusable(false);
    emptyCellUserDefinedOption.setFocusable(false);
    emptyCellErrorValueOption.setFocusable(false);

    emptyCellUserDefinedValue = new JTextField(newConfiguration.get("emptyCellValue").textValue());

    emptyCellButtonGroup.add(emptyCellEmptyStringOption);
    emptyCellButtonGroup.add(emptyCellUserDefinedOption);
    emptyCellButtonGroup.add(emptyCellErrorValueOption);

    if (newConfiguration.get("emptyCellPolicy").textValue().equals("GENERATE_ERROR")) {
        emptyCellErrorValueOption.setSelected(true);
        emptyCellUserDefinedValue.setEnabled(false);
        emptyCellUserDefinedValue.setEditable(false);
    } else if (newConfiguration.get("emptyCellPolicy").textValue().equals("EMPTY_STRING")) {
        emptyCellEmptyStringOption.setSelected(true);
        emptyCellUserDefinedValue.setEnabled(false);
        emptyCellUserDefinedValue.setEditable(false);
    } else {
        emptyCellUserDefinedOption.setSelected(true);
        emptyCellUserDefinedValue.setText(newConfiguration.get("emptyCellValue").textValue());
        emptyCellUserDefinedValue.setEnabled(true);
        emptyCellUserDefinedValue.setEditable(true);
    }

    emptyCellEmptyStringOption.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            newConfiguration.put("emptyCellPolicy", "EMPTY_STRING");
            emptyCellUserDefinedValue.setEnabled(false);
            emptyCellUserDefinedValue.setEditable(false);
        }
    });
    emptyCellUserDefinedOption.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            newConfiguration.put("emptyCellPolicy", "USER_DEFINED");
            emptyCellUserDefinedValue.setEnabled(true);
            emptyCellUserDefinedValue.setEditable(true);
            emptyCellUserDefinedValue.requestFocusInWindow();
        }
    });
    emptyCellErrorValueOption.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            newConfiguration.put("emptyCellPolicy", "GENERATE_ERROR");
            emptyCellUserDefinedValue.setEnabled(false);
            emptyCellUserDefinedValue.setEditable(false);
        }
    });

    emptyCellUserDefinedValue.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            newConfiguration.put("emptyCellValue", emptyCellUserDefinedValue.getText());
        }

        public void insertUpdate(DocumentEvent e) {
            newConfiguration.put("emptyCellValue", emptyCellUserDefinedValue.getText());
        }

        public void removeUpdate(DocumentEvent e) {
            newConfiguration.put("emptyCellValue", emptyCellUserDefinedValue.getText());
        }
    });

    // column mappings
    columnMappingLabel = new JLabel(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.columnMappingSectionLabel"));
    addDivider(columnMappingLabel, SwingConstants.TOP, false);

    Map<String, String> columnToPortMapping = new HashMap<>();
    if (newConfiguration.has("columnNames")) {
        for (JsonNode columnName : newConfiguration.get("columnNames")) {
            columnToPortMapping.put(columnName.get("column").textValue(), columnName.get("port").textValue());
        }
    }
    columnMappingTableModel = new SpreadsheetImportConfigTableModel(columnFromValue.getText(),
            columnToValue.getText(), columnToPortMapping);

    columnMappingTable = new JTable();
    columnMappingTable.setRowSelectionAllowed(false);
    columnMappingTable.getTableHeader().setReorderingAllowed(false);
    columnMappingTable.setGridColor(Color.LIGHT_GRAY);
    // columnMappingTable.setFocusable(false);

    columnMappingTable.setColumnModel(new DefaultTableColumnModel() {
        public TableColumn getColumn(int columnIndex) {
            TableColumn column = super.getColumn(columnIndex);
            if (columnIndex == 0) {
                column.setMaxWidth(100);
            }
            return column;
        }
    });

    TableCellEditor defaultEditor = columnMappingTable.getDefaultEditor(String.class);
    if (defaultEditor instanceof DefaultCellEditor) {
        DefaultCellEditor defaultCellEditor = (DefaultCellEditor) defaultEditor;
        defaultCellEditor.setClickCountToStart(1);
        Component editorComponent = defaultCellEditor.getComponent();
        if (editorComponent instanceof JTextComponent) {
            final JTextComponent textField = (JTextComponent) editorComponent;
            textField.getDocument().addDocumentListener(new DocumentListener() {
                public void changedUpdate(DocumentEvent e) {
                    updateModel(textField.getText());
                }

                public void insertUpdate(DocumentEvent e) {
                    updateModel(textField.getText());
                }

                public void removeUpdate(DocumentEvent e) {
                    updateModel(textField.getText());
                }

                private void updateModel(String text) {
                    int row = columnMappingTable.getEditingRow();
                    int column = columnMappingTable.getEditingColumn();
                    columnMappingTableModel.setValueAt(text, row, column);

                    ArrayNode columnNames = newConfiguration.arrayNode();
                    Map<String, String> columnToPortMapping = columnMappingTableModel.getColumnToPortMapping();
                    for (Entry<String, String> entry : columnToPortMapping.entrySet()) {
                        columnNames.add(newConfiguration.objectNode().put("column", entry.getKey()).put("port",
                                entry.getValue()));
                    }
                    newConfiguration.put("columnNames", columnNames);
                    validatePortNames();
                }

            });
        }
    }

    columnMappingTable.setModel(columnMappingTableModel);

    // output format
    outputFormatLabel = new JLabel(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.outputFormatSectionLabel"));

    outputFormatMultiplePort = new JRadioButton(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.multiplePortOption"));
    outputFormatSinglePort = new JRadioButton(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.singlePortOption"));
    outputFormatMultiplePort.setFocusable(false);
    outputFormatSinglePort.setFocusable(false);

    outputFormatDelimiterLabel = new JLabel(
            SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.userDefinedCsvDelimiter"));
    outputFormatDelimiter = new JTextField(newConfiguration.get("csvDelimiter").textValue(), 5);

    outputFormatButtonGroup = new ButtonGroup();
    outputFormatButtonGroup.add(outputFormatMultiplePort);
    outputFormatButtonGroup.add(outputFormatSinglePort);

    if (newConfiguration.get("outputFormat").textValue().equals("PORT_PER_COLUMN")) {
        outputFormatMultiplePort.setSelected(true);
        outputFormatDelimiterLabel.setEnabled(false);
        outputFormatDelimiter.setEnabled(false);
    } else {
        outputFormatSinglePort.setSelected(true);
        columnMappingLabel.setEnabled(false);
        enableTable(columnMappingTable, false);
    }

    outputFormatMultiplePort.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            outputFormatDelimiterLabel.setEnabled(false);
            outputFormatDelimiter.setEnabled(false);
            columnMappingLabel.setEnabled(true);
            enableTable(columnMappingTable, true);
            newConfiguration.put("outputFormat", "PORT_PER_COLUMN");
        }
    });
    outputFormatSinglePort.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            outputFormatDelimiterLabel.setEnabled(true);
            outputFormatDelimiter.setEnabled(true);
            columnMappingLabel.setEnabled(false);
            enableTable(columnMappingTable, false);
            newConfiguration.put("outputFormat", "SINGLE_PORT");
        }

    });
    outputFormatDelimiter.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            handleUpdate();
        }

        public void insertUpdate(DocumentEvent e) {
            handleUpdate();
        }

        public void removeUpdate(DocumentEvent e) {
            handleUpdate();
        }

        private void handleUpdate() {
            String text = null;
            try {
                text = StringEscapeUtils.unescapeJava(outputFormatDelimiter.getText());
            } catch (RuntimeException re) {
            }
            if (text == null || text.length() == 0) {
                newConfiguration.put("csvDelimiter", ",");
            } else {
                newConfiguration.put("csvDelimiter", text.substring(0, 1));
            }
        }

    });

    // buttons
    nextButton = new JButton(SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.nextButton"));
    nextButton.setFocusable(false);
    nextButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            backButton.setVisible(true);
            nextButton.setVisible(false);
            cardLayout.last(contentPanel);
        }
    });

    backButton = new JButton(SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.backButton"));
    backButton.setFocusable(false);
    backButton.setVisible(false);
    backButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            nextButton.setVisible(true);
            backButton.setVisible(false);
            cardLayout.first(contentPanel);
        }
    });

    buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    addDivider(buttonPanel, SwingConstants.TOP, true);

    removeAll();
    layoutPanel();
}

From source file:edu.ucla.stat.SOCR.chart.SuperXYChart_QQ.java

public void initMapPanel() {
    listIndex = new int[dataTable.getColumnCount()];
    for (int j = 0; j < listIndex.length; j++)
        listIndex[j] = 1;//from w w  w  .  j  a  v a 2  s  .c  om
    bPanel = new JPanel(new BorderLayout());
    mapPanel = new JPanel(new GridLayout(2, 3, 50, 50));
    bPanel.add(mapPanel, BorderLayout.CENTER);

    addButton1.addActionListener(this);
    addButton2.addActionListener(this);
    removeButton1.addActionListener(this);
    removeButton2.addActionListener(this);

    lModelAdded = new DefaultListModel();
    lModelDep = new DefaultListModel();
    lModelIndep = new DefaultListModel();

    int cellWidth = 10;

    listAdded = new JList(lModelAdded);
    listAdded.setSelectedIndex(0);
    listDepRemoved = new JList(lModelDep);
    listIndepRemoved = new JList(lModelIndep);

    paintMappingLists(listIndex);
    listAdded.setFixedCellWidth(cellWidth);
    listDepRemoved.setFixedCellWidth(cellWidth);
    listIndepRemoved.setFixedCellWidth(cellWidth);

    tools1 = new JToolBar(JToolBar.VERTICAL);
    tools2 = new JToolBar(JToolBar.VERTICAL);

    tools1.add(depLabel);
    //    tools2.add(indLabel);

    tools1.setFloatable(false);
    tools2.setFloatable(false);
    tools1.add(addButton1);
    tools1.add(removeButton1);
    //  tools2.add(addButton2);
    //   tools2.add(removeButton2);

    JRadioButton disChoices_normal;
    JRadioButton disChoices_poisson;

    //
    JPanel choicesPanel = new JPanel();
    disChoices_normal = new JRadioButton("Normal");
    disChoices_normal.addActionListener(this);
    disChoices_normal.setActionCommand(NORMAL);
    disChoices_normal.setSelected(true);
    disChoice = NORMAL;

    disChoices_poisson = new JRadioButton("Poisson");
    disChoices_poisson.addActionListener(this);
    disChoices_poisson.setActionCommand(POISSON);

    ButtonGroup group = new ButtonGroup();
    group.add(disChoices_normal);
    group.add(disChoices_poisson);
    choicesPanel.add(new JLabel("Choices of distribution:"));
    choicesPanel.add(disChoices_normal);
    choicesPanel.add(disChoices_poisson);
    choicesPanel.setPreferredSize(new Dimension(200, 100));

    mapPanel.add(new JScrollPane(listAdded));
    mapPanel.add(tools1);
    mapPanel.add(new JScrollPane(listDepRemoved));
    //      JPanel emptyPanel = new JPanel(new GridLayout(0,1));
    //   mapPanel.add(emptyPanel);
    mapPanel.add(choicesPanel);
    mapPanel.add(tools2);
    mapPanel.add(new JScrollPane(listIndepRemoved));

}