Example usage for java.awt BorderLayout LINE_END

List of usage examples for java.awt BorderLayout LINE_END

Introduction

In this page you can find the example usage for java.awt BorderLayout LINE_END.

Prototype

String LINE_END

To view the source code for java.awt BorderLayout LINE_END.

Click Source Link

Document

The component goes at the end of the line direction for the layout.

Usage

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

/**
 * Setup the GUI.//  ww  w .j a  v  a  2  s.  com
 */
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:org.rdv.viz.dial.DialPanel.java

/**
 * Creates the panel containing settings.
 * //from  w w  w . j av  a  2 s  .  c  om
 * @return  the settings panel
 */
private JPanel createSettingsPanel() {
    JPanel settingsPanel = new JPanel();
    settingsPanel.setLayout(new BorderLayout());
    settingsPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5));

    lowerBoundTextField = new JTextField(6);
    lowerBoundTextField.setToolTipText("The minimum value for the dial");
    lowerBoundTextField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            setRangeFromTextFields();
        }
    });
    settingsPanel.add(lowerBoundTextField, BorderLayout.LINE_START);

    upperBoundTextField = new JTextField(6);
    upperBoundTextField.setToolTipText("The maximum value for the dial");
    upperBoundTextField.setHorizontalAlignment(JTextField.TRAILING);
    upperBoundTextField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            setRangeFromTextFields();
        }
    });
    settingsPanel.add(upperBoundTextField, BorderLayout.LINE_END);

    return settingsPanel;
}

From source file:com.tascape.qa.th.android.driver.App.java

/**
 * The method starts a GUI to let an user inspect element tree and take screenshot when the user is interacting
 * with the app-under-test manually. Please make sure to set timeout long enough for manual interaction.
 *
 * @param timeoutMinutes timeout in minutes to fail the manual steps
 *
 * @throws Exception if case of error//from w w w .  jav a  2 s. c om
 */
public void interactManually(int timeoutMinutes) throws Exception {
    LOG.info("Start manual UI interaction");
    long end = System.currentTimeMillis() + timeoutMinutes * 60000L;

    AtomicBoolean visible = new AtomicBoolean(true);
    AtomicBoolean pass = new AtomicBoolean(false);
    String tName = Thread.currentThread().getName() + "m";
    SwingUtilities.invokeLater(() -> {
        JDialog jd = new JDialog((JFrame) null, "Manual Device UI Interaction - " + device.getProductDetail());
        jd.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

        JPanel jpContent = new JPanel(new BorderLayout());
        jd.setContentPane(jpContent);
        jpContent.setPreferredSize(new Dimension(1088, 828));
        jpContent.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

        JPanel jpInfo = new JPanel();
        jpContent.add(jpInfo, BorderLayout.PAGE_START);
        jpInfo.setLayout(new BorderLayout());
        {
            JButton jb = new JButton("PASS");
            jb.setForeground(Color.green.darker());
            jb.setFont(jb.getFont().deriveFont(Font.BOLD));
            jpInfo.add(jb, BorderLayout.LINE_START);
            jb.addActionListener(event -> {
                pass.set(true);
                jd.dispose();
                visible.set(false);
            });
        }
        {
            JButton jb = new JButton("FAIL");
            jb.setForeground(Color.red);
            jb.setFont(jb.getFont().deriveFont(Font.BOLD));
            jpInfo.add(jb, BorderLayout.LINE_END);
            jb.addActionListener(event -> {
                pass.set(false);
                jd.dispose();
                visible.set(false);
            });
        }

        JLabel jlTimeout = new JLabel("xxx seconds left", SwingConstants.CENTER);
        jpInfo.add(jlTimeout, BorderLayout.CENTER);
        jpInfo.add(jlTimeout, BorderLayout.CENTER);
        new SwingWorker<Long, Long>() {
            @Override
            protected Long doInBackground() throws Exception {
                while (System.currentTimeMillis() < end) {
                    Thread.sleep(1000);
                    long left = (end - System.currentTimeMillis()) / 1000;
                    this.publish(left);
                }
                return 0L;
            }

            @Override
            protected void process(List<Long> chunks) {
                Long l = chunks.get(chunks.size() - 1);
                jlTimeout.setText(l + " seconds left");
                if (l < 850) {
                    jlTimeout.setForeground(Color.red);
                }
            }
        }.execute();

        JPanel jpResponse = new JPanel(new BorderLayout());
        JPanel jpProgress = new JPanel(new BorderLayout());
        jpResponse.add(jpProgress, BorderLayout.PAGE_START);

        JTextArea jtaJson = new JTextArea();
        jtaJson.setEditable(false);
        jtaJson.setTabSize(4);
        Font font = jtaJson.getFont();
        jtaJson.setFont(new Font("Courier New", font.getStyle(), font.getSize()));

        JTree jtView = new JTree();

        JTabbedPane jtp = new JTabbedPane();
        jtp.add("tree", new JScrollPane(jtView));
        jtp.add("json", new JScrollPane(jtaJson));

        jpResponse.add(jtp, BorderLayout.CENTER);

        JPanel jpScreen = new JPanel();
        jpScreen.setMinimumSize(new Dimension(200, 200));
        jpScreen.setLayout(new BoxLayout(jpScreen, BoxLayout.PAGE_AXIS));
        JScrollPane jsp1 = new JScrollPane(jpScreen);
        jpResponse.add(jsp1, BorderLayout.LINE_START);

        JPanel jpJs = new JPanel(new BorderLayout());
        JTextArea jtaJs = new JTextArea();
        jpJs.add(new JScrollPane(jtaJs), BorderLayout.CENTER);

        JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jpResponse, jpJs);
        jSplitPane.setResizeWeight(0.88);
        jpContent.add(jSplitPane, BorderLayout.CENTER);

        JPanel jpLog = new JPanel();
        jpLog.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
        jpLog.setLayout(new BoxLayout(jpLog, BoxLayout.LINE_AXIS));

        JCheckBox jcbTap = new JCheckBox("Enable Click", null, false);
        jpLog.add(jcbTap);
        jpLog.add(Box.createHorizontalStrut(8));

        JButton jbLogUi = new JButton("Log Screen");
        jpResponse.add(jpLog, BorderLayout.PAGE_END);
        {
            jpLog.add(jbLogUi);
            jbLogUi.addActionListener((ActionEvent event) -> {
                jtaJson.setText("waiting for screenshot...");
                Thread t = new Thread(tName) {
                    @Override
                    public void run() {
                        LOG.debug("\n\n");
                        try {
                            WindowHierarchy wh = device.loadWindowHierarchy();
                            jtView.setModel(getModel(wh));

                            jtaJson.setText("");
                            jtaJson.append(wh.root.toJson().toString(2));
                            jtaJson.append("\n");

                            File png = device.takeDeviceScreenshot();
                            BufferedImage image = ImageIO.read(png);

                            int w = device.getDisplayWidth();
                            int h = device.getDisplayHeight();

                            BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
                            Graphics2D g2 = resizedImg.createGraphics();
                            g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                                    RenderingHints.VALUE_INTERPOLATION_BILINEAR);
                            g2.drawImage(image, 0, 0, w, h, null);
                            g2.dispose();

                            JLabel jLabel = new JLabel(new ImageIcon(resizedImg));
                            jpScreen.removeAll();
                            jsp1.setPreferredSize(new Dimension(w + 30, h));
                            jpScreen.add(jLabel);

                            jLabel.addMouseListener(new MouseAdapter() {
                                @Override
                                public void mouseClicked(MouseEvent e) {
                                    LOG.debug("clicked at {},{}", e.getPoint().getX(), e.getPoint().getY());
                                    if (jcbTap.isSelected()) {
                                        device.click(e.getPoint().x, e.getPoint().y);
                                        device.waitForIdle();
                                        jbLogUi.doClick();
                                    }
                                }
                            });
                        } catch (Exception ex) {
                            LOG.error("Cannot log screen", ex);
                            jtaJson.append("Cannot log screen");
                        }
                        jtaJson.append("\n\n\n");
                        LOG.debug("\n\n");

                        jd.setSize(jd.getBounds().width + 1, jd.getBounds().height + 1);
                        jd.setSize(jd.getBounds().width - 1, jd.getBounds().height - 1);
                    }
                };
                t.start();
            });
        }
        jpLog.add(Box.createHorizontalStrut(38));
        {
            JButton jbLogMsg = new JButton("Log Message");
            jpLog.add(jbLogMsg);
            JTextField jtMsg = new JTextField(10);
            jpLog.add(jtMsg);
            jtMsg.addFocusListener(new FocusListener() {
                @Override
                public void focusLost(final FocusEvent pE) {
                }

                @Override
                public void focusGained(final FocusEvent pE) {
                    jtMsg.selectAll();
                }
            });
            jtMsg.addKeyListener(new KeyAdapter() {
                @Override
                public void keyPressed(java.awt.event.KeyEvent e) {
                    if (e.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) {
                        jbLogMsg.doClick();
                    }
                }
            });
            jbLogMsg.addActionListener(event -> {
                Thread t = new Thread(tName) {
                    @Override
                    public void run() {
                        String msg = jtMsg.getText();
                        if (StringUtils.isNotBlank(msg)) {
                            LOG.info("{}", msg);
                            jtMsg.selectAll();
                        }
                    }
                };
                t.start();
                try {
                    t.join();
                } catch (InterruptedException ex) {
                    LOG.error("Cannot take screenshot", ex);
                }
                jtMsg.requestFocus();
            });
        }
        jpLog.add(Box.createHorizontalStrut(38));
        {
            JButton jbClear = new JButton("Clear");
            jpLog.add(jbClear);
            jbClear.addActionListener(event -> {
                jtaJson.setText("");
            });
        }

        JPanel jpAction = new JPanel();
        jpContent.add(jpAction, BorderLayout.PAGE_END);
        jpAction.setLayout(new BoxLayout(jpAction, BoxLayout.LINE_AXIS));
        jpJs.add(jpAction, BorderLayout.PAGE_END);

        jd.pack();
        jd.setVisible(true);
        jd.setLocationRelativeTo(null);

        jbLogUi.doClick();
    });

    while (visible.get()) {
        if (System.currentTimeMillis() > end) {
            LOG.error("Manual UI interaction timeout");
            break;
        }
        Thread.sleep(500);
    }

    if (pass.get()) {
        LOG.info("Manual UI Interaction returns PASS");
    } else {
        Assert.fail("Manual UI Interaction returns FAIL");
    }
}

From source file:com.googlecode.bpmn_simulator.gui.BPMNSimulatorFrame.java

private JComponent createToolBars() {
    final JPanel panel = new JPanel(new BorderLayout());

    final JPanel toolbarPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
    toolbarPanel.add(createDefinitionToolbar());
    toolbarPanel.add(instancesToolbar);/*  w w  w.j a  v a  2s .  c o  m*/
    toolbarPanel.add(animationToolbar);
    panel.add(toolbarPanel, BorderLayout.CENTER);

    messagesButton.setContentAreaFilled(false);
    messagesButton.setFocusable(false);
    messagesButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent event) {
            showFrame(logFrame);
        }
    });
    panel.add(messagesButton, BorderLayout.LINE_END);
    updateMessagesInfo();

    return panel;
}

From source file:TextSamplerDemo.java

public TextSamplerDemo() {
    setLayout(new BorderLayout());

    //Create a regular text field.
    JTextField textField = new JTextField(10);
    textField.setActionCommand(textFieldString);
    textField.addActionListener(this);

    //Create a password field.
    JPasswordField passwordField = new JPasswordField(10);
    passwordField.setActionCommand(passwordFieldString);
    passwordField.addActionListener(this);

    //Create a formatted text field.
    JFormattedTextField ftf = new JFormattedTextField(java.util.Calendar.getInstance().getTime());
    ftf.setActionCommand(textFieldString);
    ftf.addActionListener(this);

    //Create some labels for the fields.
    JLabel textFieldLabel = new JLabel(textFieldString + ": ");
    textFieldLabel.setLabelFor(textField);
    JLabel passwordFieldLabel = new JLabel(passwordFieldString + ": ");
    passwordFieldLabel.setLabelFor(passwordField);
    JLabel ftfLabel = new JLabel(ftfString + ": ");
    ftfLabel.setLabelFor(ftf);/*from www.j a v a  2 s  . c o  m*/

    //Create a label to put messages during an action event.
    actionLabel = new JLabel("Type text and then Enter in a field.");
    actionLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));

    //Lay out the text controls and the labels.
    JPanel textControlsPane = new JPanel();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    textControlsPane.setLayout(gridbag);

    JLabel[] labels = { textFieldLabel, passwordFieldLabel, ftfLabel };
    JTextField[] textFields = { textField, passwordField, ftf };
    addLabelTextRows(labels, textFields, gridbag, textControlsPane);

    c.gridwidth = GridBagConstraints.REMAINDER; //last
    c.anchor = GridBagConstraints.WEST;
    c.weightx = 1.0;
    textControlsPane.add(actionLabel, c);
    textControlsPane.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("Text Fields"), BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    //Create a text area.
    JTextArea textArea = new JTextArea("This is an editable JTextArea. "
            + "A text area is a \"plain\" text component, " + "which means that although it can display text "
            + "in any font, all of the text is in the same font.");
    textArea.setFont(new Font("Serif", Font.ITALIC, 16));
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    JScrollPane areaScrollPane = new JScrollPane(textArea);
    areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    areaScrollPane.setPreferredSize(new Dimension(250, 250));
    areaScrollPane.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Plain Text"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)),
            areaScrollPane.getBorder()));

    //Create an editor pane.
    JEditorPane editorPane = createEditorPane();
    JScrollPane editorScrollPane = new JScrollPane(editorPane);
    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPane.setPreferredSize(new Dimension(250, 145));
    editorScrollPane.setMinimumSize(new Dimension(10, 10));

    //Create a text pane.
    JTextPane textPane = createTextPane();
    JScrollPane paneScrollPane = new JScrollPane(textPane);
    paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    paneScrollPane.setPreferredSize(new Dimension(250, 155));
    paneScrollPane.setMinimumSize(new Dimension(10, 10));

    //Put the editor pane and the text pane in a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, editorScrollPane, paneScrollPane);
    splitPane.setOneTouchExpandable(true);
    splitPane.setResizeWeight(0.5);
    JPanel rightPane = new JPanel(new GridLayout(1, 0));
    rightPane.add(splitPane);
    rightPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Styled Text"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    //Put everything together.
    JPanel leftPane = new JPanel(new BorderLayout());
    leftPane.add(textControlsPane, BorderLayout.PAGE_START);
    leftPane.add(areaScrollPane, BorderLayout.CENTER);

    add(leftPane, BorderLayout.LINE_START);
    add(rightPane, BorderLayout.LINE_END);
}

From source file:com.egangotri.transliteratorAsSwing.TransliteratorJFrame.java

public TransliteratorJFrame() {
    super("eGangotri Indic Transliterator");

    PrintWriter pw = new PrintWriter(System.out, true);
    setSize(650, 650);/*  ww  w  .  j a  va2s . c  o m*/

    // menubar
    menubar = new JMenuBar();

    // menus
    file = new JMenu("File");
    help = new JMenu("Help");

    // JMenuItem
    save_1 = new JMenuItem("Save Input");
    save_1.setActionCommand("save_1");
    save_1.addActionListener(this);

    save_2 = new JMenuItem("Save Output-1");
    save_2.setActionCommand("save_2");
    save_2.addActionListener(this);

    save_3 = new JMenuItem("Save Output-2");
    save_3.setActionCommand("save_3");
    save_3.addActionListener(this);

    open_1 = new JMenuItem("Open File for Input");
    open_1.setActionCommand("open_1");
    open_1.addActionListener(this);

    exitItem = new JMenuItem("Exit");
    exitItem.setActionCommand("Exit");
    exitItem.addActionListener(this);

    aboutItem = new JMenuItem("About");
    aboutItem.setActionCommand("about_item");
    aboutItem.addActionListener(this);

    itransItem = new JMenuItem("ITRANS " + Constants.ENCODING_SCHEME);
    itransItem.setActionCommand("itrans_encoding");
    itransItem.addActionListener(this);

    slpItem = new JMenuItem("SLP " + Constants.ENCODING_SCHEME);
    slpItem.setActionCommand("slp_encoding");
    slpItem.addActionListener(this);

    hkItem = new JMenuItem("Harvard Kyoto " + Constants.ENCODING_SCHEME);
    hkItem.setActionCommand("hk_encoding");
    hkItem.addActionListener(this);

    velthuisItem = new JMenuItem("Velthuis " + Constants.ENCODING_SCHEME);
    velthuisItem.setActionCommand("velthuis_encoding");
    velthuisItem.addActionListener(this);

    dvnItem = new JMenuItem("Devanagari " + Constants.ENCODING_SCHEME);
    dvnItem.setActionCommand("devanagari_encoding");
    dvnItem.addActionListener(this);

    iastItem = new JMenuItem("IAST " + Constants.ENCODING_SCHEME);
    iastItem.setActionCommand("iast_encoding");
    iastItem.addActionListener(this);

    // add menuitems to menu
    file.add(open_1);
    file.add(save_1);
    file.add(save_2);
    file.add(save_3);
    file.add(exitItem);

    help.add(aboutItem);
    help.add(itransItem);
    help.add(slpItem);
    help.add(hkItem);
    help.add(velthuisItem);
    help.add(dvnItem);
    help.add(iastItem);

    // add menus to menubar
    menubar.add(file);
    menubar.add(help);
    // menus end

    // JPanel Initilization
    p1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    p1a = new JPanel(new BorderLayout());
    p2 = new JPanel();
    p3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    p3a = new JPanel(new BorderLayout());

    p4 = new JPanel();
    p5 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    p5a = new JPanel(new BorderLayout());

    p6 = new JPanel();
    p6a = new JPanel();
    p7 = new JPanel();

    // JLabel Initialization
    label1 = new JLabel("Input:");
    label2 = new JLabel("Output-1");
    label3 = new JLabel("Output-2");

    capitalize = new JCheckBox("Capitalize Extended Latin");
    capitalize.setSelected(capitalizeIAST);
    capitalize.setActionCommand("capitalize");
    capitalize.addActionListener(this);

    // Buttons
    clearButton = new JButton("Clear");
    clearButton.setActionCommand("clear");
    clearButton.setToolTipText("Clear all Fields");

    refreshButton = new JButton("Refresh");
    refreshButton.setActionCommand("refresh");
    refreshButton.setToolTipText("Refesh the View");

    exitButton = new JButton("Exit");
    exitButton.setActionCommand("Exit");
    exitButton.setToolTipText("Quit the Application.");

    clipboardButton1 = new JButton("Clipboard");
    clipboardButton1.setActionCommand("clipboard-1");
    clipboardButton1.setToolTipText("Clipboard Input");

    clipboardButton2 = new JButton("Clipboard");
    clipboardButton2.setActionCommand("clipboard-2");
    clipboardButton2.setToolTipText("Clipboard Output-1");

    clipboardButton3 = new JButton("Clipboard");
    clipboardButton3.setActionCommand("clipboard-3");
    clipboardButton3.setToolTipText("Clipboard Output-2");

    clearButton.addActionListener(this);
    refreshButton.addActionListener(this);
    exitButton.addActionListener(this);

    clipboardButton1.addActionListener(this);
    clipboardButton2.addActionListener(this);
    clipboardButton3.addActionListener(this);

    Container contentPane = getContentPane();

    // JTextBox
    tb1 = new JTextArea(new PlainDocument(), null, 6, 45);
    tb1.setLineWrap(true);
    tb1.setWrapStyleWord(true);
    tb1.addKeyListener(this);

    tb2 = new JTextArea(new PlainDocument(), null, 6, 45);
    tb2.setLineWrap(true);
    tb2.setWrapStyleWord(true);
    tb2.addKeyListener(this);

    tb3 = new JTextArea(new PlainDocument(), null, 6, 45);
    tb3.setLineWrap(true);
    tb3.setWrapStyleWord(true);
    tb3.addKeyListener(this);

    // Setting Fonts
    Font unicodeFont = new Font(Constants.ARIAL_UNICODE_MS, Font.PLAIN, Constants.FONT_SIZE);
    tb1.setFont(unicodeFont);
    tb2.setFont(unicodeFont);
    tb3.setFont(unicodeFont);

    comboBox1 = new JComboBox(Constants.ENCODINGS.toArray());
    comboBox1.setActionCommand("comboBox1");
    comboBox1.setSelectedItem(Constants.ITRANS);
    comboBox1.addActionListener(this);

    comboBox2 = new JComboBox(Constants.ENCODINGS.toArray());
    comboBox2.setActionCommand("comboBox2");
    comboBox2.setSelectedItem(Constants.UNICODE_DVN);
    comboBox2.addActionListener(this);

    comboBox3 = new JComboBox(Constants.ENCODINGS.toArray());
    comboBox3.setActionCommand("comboBox3");
    comboBox3.setSelectedItem(Constants.IAST);
    comboBox3.addActionListener(this);

    /** *EXPERIMENT*** */
    textPane = new JTextPane();
    RTFEditorKit rtfkit = new RTFEditorKit();
    // HTMLEditorKit htmlkit = new HTMLEditorKit();
    textPane.setEditorKit(rtfkit); // set Kit which will read RTF Doc
    // textPane.setEditorKit(htmlkit);
    textPane.setEditable(false); // make uneditable
    textPane.setPreferredSize(new Dimension(200, 200));
    textPane.setText(""); // set

    p1.add(label1);
    p1a.add(comboBox1, BorderLayout.LINE_END);
    p1a.add(clipboardButton1, BorderLayout.LINE_START);

    p2.add(new JScrollPane(tb1));

    p3.add(label2);
    p3a.add(comboBox2, BorderLayout.LINE_END);
    p3a.add(clipboardButton2, BorderLayout.LINE_START);

    p4.add(new JScrollPane(tb2));

    p5.add(label3);
    p5a.add(comboBox3, BorderLayout.LINE_END);
    p5a.add(clipboardButton3, BorderLayout.LINE_START);

    p6.add(new JScrollPane(tb3));

    p6a.add(capitalize);
    p7.add(clearButton);
    p7.add(refreshButton);
    p7.add(exitButton);
    this.setJMenuBar(menubar);

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

    contentPane.add(p1);
    contentPane.add(p1a);
    contentPane.add(p2);
    contentPane.add(p3);
    contentPane.add(p3a);
    contentPane.add(p4);
    contentPane.add(p5);
    contentPane.add(p5a);
    contentPane.add(p6);
    contentPane.add(p6a);
    contentPane.add(p7);

}

From source file:org.imos.abos.plot.JfreeChartDemo.java

public void createAndShowGUI() {
    JButton autoZoom = new JButton("Auto Scale");
    autoZoom.addActionListener(new ActionListener() {
        @Override//  w ww  .  ja  v a  2s  .c o m
        public void actionPerformed(ActionEvent e) {
            System.out.println("Auto Zoom");

            chart.getXYPlot().getDomainAxis().setAutoRange(true);
            chart.getXYPlot().getRangeAxis().setAutoRange(true);
        }
    });
    JButton pdfButton = new JButton("PDF");
    pdfButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("PDF");
            createPDF(pdfName);
        }
    });
    yMax = new JTextField(10);
    yMax.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("yMax Set " + yMax.getText());
            double max = new Double(yMax.getText());
            double min = chart.getXYPlot().getRangeAxis().getRange().getLowerBound();
            chart.getXYPlot().getRangeAxis().setRange(min, max);
        }
    });
    yMin = new JTextField(10);
    yMin.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("yMin Set " + yMin.getText());
            double min = new Double(yMin.getText());
            double max = chart.getXYPlot().getRangeAxis().getRange().getUpperBound();
            chart.getXYPlot().getRangeAxis().setRange(min, max);
        }
    });
    JCheckBox showPoints = new JCheckBox("Show Points");
    showPoints.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.DESELECTED) {
                XYItemRenderer r = plot.getRenderer();
                if (r instanceof XYLineAndShapeRenderer) {
                    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
                    renderer.setBaseShapesVisible(false);
                }
            } else if (e.getStateChange() == ItemEvent.SELECTED) {
                XYItemRenderer r = plot.getRenderer();
                if (r instanceof XYLineAndShapeRenderer) {
                    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
                    renderer.setBaseShapesVisible(true);
                }
            }
        }

    });

    final JPanel jpanel = new JPanel();
    jpanel.setLayout(new BorderLayout());
    jpanel.add(chartPanel, BorderLayout.CENTER);
    JPanel right = new JPanel();
    JPanel ypmax = new JPanel();
    ypmax.add(yMax);
    JPanel ypmin = new JPanel();
    ypmin.add(yMin);
    right.setLayout(new BoxLayout(right, BoxLayout.PAGE_AXIS));
    right.add(ypmax);
    right.add(ypmin);
    right.add(autoZoom);
    right.add(pdfButton);
    right.add(showPoints);
    jpanel.add(right, BorderLayout.LINE_END);

    setContentPane(jpanel);

    pack();
    setLocationRelativeTo(null);
    setVisible(true);
}

From source file:de.uka.aifb.com.systemDynamics.gui.ModelExecutionChartPanel.java

/**
 * Creates panel./* w  ww. j a  v  a 2 s.c o  m*/
 */
private void createPanel() {
    setLayout(new BorderLayout());

    // CENTER: chart
    ChartPanel chartPanel = new ChartPanel(createChart());
    // no context menu
    chartPanel.setPopupMenu(null);
    // not zoomable
    chartPanel.setMouseZoomable(false);
    add(chartPanel, BorderLayout.CENTER);

    // LINE_END: series table
    JPanel tablePanel = new JPanel(new GridBagLayout());
    String[] columnNames = { messages.getString("ModelExecutionChartPanel.Table.ColumnNames.ExtraAxis"),
            messages.getString("ModelExecutionChartPanel.Table.ColumnNames.LevelNode") };
    final MyTableModel tableModel = new MyTableModel(columnNames, xySeriesArray.length);
    for (int i = 0; i < xySeriesArray.length; i++) {
        tableModel.addEntry((String) xySeriesArray[i].getKey());
    }
    JTable table = new JTable(tableModel);
    table.setRowSelectionAllowed(false);
    JScrollPane tableScrollPane = new JScrollPane(table);
    int width = (int) Math.min(300, table.getPreferredSize().getWidth());
    int height = (int) Math.min(200, table.getPreferredSize().getHeight());
    tableScrollPane.getViewport().setPreferredSize(new Dimension(width, height));
    tableScrollPane.setMaximumSize(tableScrollPane.getViewport().getPreferredSize());
    axesButton = new JButton(messages.getString("ModelExecutionChartPanel.AxesButton.Text"));
    axesButton.setToolTipText(messages.getString("ModelExecutionChartPanel.AxesButton.ToolTipText"));
    axesButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // create XYSeriesCollections (and renderer)
            XYSeriesCollection standardData = new XYSeriesCollection();
            XYLineAndShapeRenderer standardRenderer = new XYLineAndShapeRenderer(true, false);
            LinkedList<XYSeriesCollection> extraDataList = new LinkedList<XYSeriesCollection>();
            LinkedList<XYLineAndShapeRenderer> extraRendererList = new LinkedList<XYLineAndShapeRenderer>();
            for (int i = 0; i < tableModel.getRowCount(); i++) {
                if (tableModel.getValueAt(i, 0).equals(Boolean.FALSE)) {
                    standardData.addSeries(xySeriesArray[i]);
                    standardRenderer.setSeriesPaint(standardData.getSeriesCount() - 1,
                            DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[i
                                    % DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length]);
                } else {
                    // extra axis
                    XYSeriesCollection extraData = new XYSeriesCollection();
                    extraData.addSeries(xySeriesArray[i]);
                    extraDataList.add(extraData);
                    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
                    extraRendererList.add(renderer);
                    renderer.setSeriesPaint(0, DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[i
                            % DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length]);
                }
            }
            LinkedList<XYSeriesCollection> dataList = new LinkedList<XYSeriesCollection>();
            LinkedList<XYLineAndShapeRenderer> rendererList = new LinkedList<XYLineAndShapeRenderer>();
            if (!standardData.getSeries().isEmpty()) {
                dataList.add(standardData);
                rendererList.add(standardRenderer);
            }
            for (XYSeriesCollection data : extraDataList) {
                dataList.add(data);
            }
            for (XYLineAndShapeRenderer renderer : extraRendererList) {
                rendererList.add(renderer);
            }

            // creates axes
            LinkedList<NumberAxis> axesList = new LinkedList<NumberAxis>();
            if (!standardData.getSeries().isEmpty()) {
                NumberAxis axis = new NumberAxis(messages.getString("ModelExecutionChartPanel.Value"));
                axis.setNumberFormatOverride(NumberFormat.getInstance(locale));
                axesList.add(axis);
            }
            for (XYSeriesCollection data : extraDataList) {
                NumberAxis axis = new NumberAxis((String) data.getSeries(0).getKey());
                axis.setNumberFormatOverride(NumberFormat.getInstance(locale));
                axesList.add(axis);
            }

            // store data and axes in plot
            XYPlot plot = chart.getXYPlot();
            plot.clearRangeAxes();
            plot.setRangeAxes(axesList.toArray(new NumberAxis[0]));
            for (int i = 0; i < plot.getDatasetCount(); i++) {
                plot.setDataset(i, null);
            }
            int datasetIndex = 0;
            Iterator<XYSeriesCollection> datasetIterator = dataList.iterator();
            Iterator<XYLineAndShapeRenderer> rendererIterator = rendererList.iterator();
            while (datasetIterator.hasNext()) {
                plot.setDataset(datasetIndex, datasetIterator.next());
                plot.setRenderer(datasetIndex, rendererIterator.next());
                datasetIndex++;
            }
            for (int i = 0; i < plot.getDatasetCount(); i++) {
                plot.mapDatasetToRangeAxis(i, i);
            }
        }
    });
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.CENTER;
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(0, 0, 10, 0);
    tablePanel.add(tableScrollPane, c);
    c.gridx = 0;
    c.gridy = 1;
    tablePanel.add(axesButton, c);
    add(tablePanel, BorderLayout.LINE_END);

    // PAGE_END: number of rounds and execution button
    JPanel commandPanel = new JPanel();
    commandPanel.add(new JLabel(messages.getString("ModelExecutionChartPanel.NumberRounds")));
    final JTextField numberRoundsField = new JTextField("1", 5);
    numberRoundsField.addFocusListener(this);
    commandPanel.add(numberRoundsField);
    executionButton = new JButton(messages.getString("ModelExecutionChartPanel.ExecutionButton.Text"));
    executionButton.setToolTipText(messages.getString("ModelExecutionChartPanel.ExecutionButton.ToolTipText"));
    executionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int numberRounds = 0;
            boolean correctNumber = false;
            try {
                numberRounds = integerNumberFormatter.parse(numberRoundsField.getText()).intValue();
            } catch (ParseException parseExcep) {
                // do nothing
            }

            if (numberRounds >= 1) {
                correctNumber = true;
            }

            if (correctNumber) {
                ModelExecutionThread executionThread = new ModelExecutionThread(numberRounds);
                executionThread.start();
            } else {
                JOptionPane.showMessageDialog(null,
                        messages.getString("ModelExecutionChartPanel.Error.Message"),
                        messages.getString("ModelExecutionChartPanel.Error.Title"), JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    commandPanel.add(executionButton);
    add(commandPanel, BorderLayout.PAGE_END);
}

From source file:view.PnIncome.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*from   w  ww  .  j av  a2 s .com*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    pnFunction = new javax.swing.JPanel();
    jPanel2 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    cbTime = new javax.swing.JComboBox<>();
    pnFind = new javax.swing.JPanel();
    pnCenter = new javax.swing.JPanel();

    setBackground(new java.awt.Color(251, 250, 202));
    setLayout(new java.awt.BorderLayout());

    pnFunction.setBackground(new java.awt.Color(251, 250, 202));

    jPanel2.setBackground(new java.awt.Color(251, 250, 202));
    jPanel2.setBorder(javax.swing.BorderFactory.createCompoundBorder(
            javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5),
            javax.swing.BorderFactory.createTitledBorder(
                    new javax.swing.border.LineBorder(new java.awt.Color(0, 255, 204), 1, true),
                    "Khong th?i gian", javax.swing.border.TitledBorder.LEFT,
                    javax.swing.border.TitledBorder.TOP, new java.awt.Font("Tahoma", 1, 11),
                    new java.awt.Color(0, 255, 204)))); // NOI18N

    jLabel1.setText("Th?i gian");

    cbTime.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Thng", "Qu", "Nm" }));
    cbTime.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            cbTimeActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(jPanel2Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1).addComponent(cbTime, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    190, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(0, 0, Short.MAX_VALUE)));
    jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                    .addComponent(jLabel1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
                    .addComponent(cbTime, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));

    pnFind.setBackground(new java.awt.Color(251, 250, 202));
    pnFind.setLayout(new java.awt.BorderLayout());

    javax.swing.GroupLayout pnFunctionLayout = new javax.swing.GroupLayout(pnFunction);
    pnFunction.setLayout(pnFunctionLayout);
    pnFunctionLayout.setHorizontalGroup(pnFunctionLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnFind, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE)
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE));
    pnFunctionLayout.setVerticalGroup(pnFunctionLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnFunctionLayout.createSequentialGroup()
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, 0).addComponent(pnFind, javax.swing.GroupLayout.DEFAULT_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    add(pnFunction, java.awt.BorderLayout.LINE_END);

    pnCenter.setBackground(new java.awt.Color(251, 250, 202));
    pnCenter.setLayout(new java.awt.BorderLayout());
    add(pnCenter, java.awt.BorderLayout.CENTER);
}

From source file:e3fraud.gui.MainWindow.java

public MainWindow() {
    super(new BorderLayout(5, 5));

    extended = false;/*from  w  w  w. j a v a 2  s.co m*/

    //Create the log first, because the action listeners
    //need to refer to it.
    log = new JTextArea(10, 50);
    log.setMargin(new Insets(5, 5, 5, 5));
    log.setEditable(false);
    logScrollPane = new JScrollPane(log);
    DefaultCaret caret = (DefaultCaret) log.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    //        create the progress bar
    progressBar = new JProgressBar(0, 100);
    progressBar.setValue(progressBar.getMinimum());
    progressBar.setVisible(false);
    progressBar.setStringPainted(true);
    //Create the settings pane
    generationSettingLabel = new JLabel("Generate:");
    SpinnerModel collusionsSpinnerModel = new SpinnerNumberModel(1, 0, 3, 1);
    collusionSettingsPanel = new JPanel(new FlowLayout()) {
        @Override
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    // collusionSettingsPanel.setLayout(new BoxLayout(collusionSettingsPanel, BoxLayout.X_AXIS));
    collusionsButton = new JSpinner(collusionsSpinnerModel);
    collusionsLabel = new JLabel("collusion(s)");
    collusionSettingsPanel.add(collusionsButton);
    collusionSettingsPanel.add(collusionsLabel);

    rankingSettingLabel = new JLabel("Rank by:");
    lossButton = new JRadioButton("loss");
    lossButton.setToolTipText("Sort sub-ideal models based on loss for Target of Assessment (high -> low)");
    gainButton = new JRadioButton("gain");
    gainButton.setToolTipText(
            "Sort sub-ideal models based on gain of any actor except Target of Assessment (high -> low)");
    lossGainButton = new JRadioButton("loss + gain");
    lossGainButton.setToolTipText(
            "Sort sub-ideal models based on loss for Target of Assessment and, if equal, on gain of any actor except Target of Assessment");
    //gainLossButton = new JRadioButton("gain + loss");
    lossGainButton.setSelected(true);
    rankingGroup = new ButtonGroup();
    rankingGroup.add(lossButton);
    rankingGroup.add(gainButton);
    rankingGroup.add(lossGainButton);
    //rankingGroup.add(gainLossButton);
    groupingSettingLabel = new JLabel("Group by:");
    groupingButton = new JCheckBox("collusion");
    groupingButton.setToolTipText(
            "Groups sub-ideal models based on the pair of actors colluding before ranking them");
    groupingButton.setSelected(false);
    refreshButton = new JButton("Refresh");
    refreshButton.addActionListener(this);

    settingsPanel = new JPanel();
    settingsPanel.setLayout(new BoxLayout(settingsPanel, BoxLayout.PAGE_AXIS));
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(generationSettingLabel);
    collusionSettingsPanel.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(collusionSettingsPanel);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    rankingSettingLabel.setAlignmentY(TOP_ALIGNMENT);
    settingsPanel.add(rankingSettingLabel);
    settingsPanel.add(lossButton);
    settingsPanel.add(gainButton);
    settingsPanel.add(lossGainButton);
    //settingsPanel.add(gainLossButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(groupingSettingLabel);
    settingsPanel.add(groupingButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(refreshButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 20)));
    progressBar.setPreferredSize(
            new Dimension(settingsPanel.getSize().width, progressBar.getPreferredSize().height));
    settingsPanel.add(progressBar);

    //Create the result tree
    root = new DefaultMutableTreeNode("No models to display");
    treeModel = new DefaultTreeModel(root);
    tree = new JTree(treeModel);
    //tree.setUI(new CustomTreeUI());
    tree.setCellRenderer(new CustomTreeCellRenderer(tree));
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setLargeModel(true);
    resultScrollPane = new JScrollPane(tree);
    tree.addTreeSelectionListener(treeSelectionListener);

    //tree.setShowsRootHandles(true);
    //Create a file chooser for saving
    sfc = new JFileChooser();
    FileFilter jpegFilter = new FileNameExtensionFilter("JPEG image", new String[] { "jpg", "jpeg" });
    sfc.addChoosableFileFilter(jpegFilter);
    sfc.setFileFilter(jpegFilter);

    //Create a file chooser for loading
    fc = new JFileChooser();
    FileFilter rdfFilter = new FileNameExtensionFilter("RDF file", "RDF");
    fc.addChoosableFileFilter(rdfFilter);
    fc.setFileFilter(rdfFilter);

    //Create the open button.  
    openButton = new JButton("Load model", createImageIcon("images/Open24.png"));
    openButton.addActionListener(this);
    openButton.setToolTipText("Load a e3value model");

    //Create the ideal graph button. 
    idealGraphButton = new JButton("Show ideal graph", createImageIcon("images/Plot.png"));
    idealGraphButton.setToolTipText("Display ideal profitability graph");
    idealGraphButton.addActionListener(this);

    Dimension thinButtonDimension = new Dimension(15, 420);

    //Create the expand subideal graph button. 
    expandButton = new JButton(">");
    expandButton.setPreferredSize(thinButtonDimension);
    expandButton.setMargin(new Insets(0, 0, 0, 0));
    expandButton.setToolTipText("Expand to show non-ideal profitability graph for selected model");
    expandButton.addActionListener(this);

    //Create the collapse sub-ideal graph button. 
    collapseButton = new JButton("<");
    collapseButton.setPreferredSize(thinButtonDimension);
    collapseButton.setMargin(new Insets(0, 0, 0, 0));
    collapseButton.setToolTipText("Collapse non-ideal profitability graph for selected model");
    collapseButton.addActionListener(this);

    //Create the generation button. 
    generateButton = new JButton("Generate sub-ideal models", createImageIcon("images/generate.png"));
    generateButton.addActionListener(this);
    generateButton.setToolTipText("Generate sub-ideal models for the e3value model currently loaded");

    //Create the chart panel
    chartPane = new JPanel();
    chartPane.setLayout(new FlowLayout(FlowLayout.LEFT));
    chartPane.add(expandButton);

    //For layout purposes, put the buttons in a separate panel
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(openButton);
    buttonPanel.add(Box.createRigidArea(new Dimension(20, 0)));
    buttonPanel.add(generateButton);
    buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
    buttonPanel.add(idealGraphButton);

    //Add the buttons, the ranking options, the result list and the log to this panel.
    add(buttonPanel, BorderLayout.PAGE_START);
    add(settingsPanel, BorderLayout.LINE_START);
    add(resultScrollPane, BorderLayout.CENTER);

    add(logScrollPane, BorderLayout.PAGE_END);
    add(chartPane, BorderLayout.LINE_END);
    //and make a nice border around it
    setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10));
}