Example usage for javax.swing BoxLayout PAGE_AXIS

List of usage examples for javax.swing BoxLayout PAGE_AXIS

Introduction

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

Prototype

int PAGE_AXIS

To view the source code for javax.swing BoxLayout PAGE_AXIS.

Click Source Link

Document

Specifies that components should be laid out in the direction that lines flow across a page as determined by the target container's ComponentOrientation property.

Usage

From source file:uk.nhs.cfh.dsp.srth.desktop.modules.querycreationtreepanel.ConstraintPanel.java

/**
 * Inits the components./*from w  w  w . j a  va2 s.  c  om*/
 */
private void initComponents() {

    String[] fields = new String[] { "has_dose", "has_value" };
    fieldBox = new JComboBox(fields);
    fieldBox.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent arg0) {
            // get selected item
            selectedField = fieldBox.getSelectedItem().toString();
        }
    });
    // select has_value by default
    fieldBox.setSelectedItem(fields[1]);
    JPanel p1 = new JPanel();
    p1.setLayout(new BoxLayout(p1, BoxLayout.LINE_AXIS));
    p1.add(new JLabel("Field Name"));
    p1.add(Box.createHorizontalStrut(10));
    p1.add(fieldBox);

    Operator[] ops = { Operator.EQUAL_TO, Operator.BETWEEN, Operator.LESS_THAN, Operator.GREATER_THAN };
    operatorsBox = new JComboBox(ops);
    // select operator 'equal to' by default
    operatorsBox.setSelectedItem(Operator.EQUAL_TO);
    selectedOperator = Operator.EQUAL_TO;
    operatorsBox.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            // get selected operator
            selectedOperator = Operator.valueOf(operatorsBox.getSelectedItem().toString());

            if (selectedOperator == Operator.BETWEEN) {
                // enable second value spinner
                valueSpinner2.setEnabled(true);
                valueSpinnerCheckBox2.setEnabled(true);
            } else if (selectedOperator == Operator.EQUAL_TO) {
                // disable value 1 checkbox
                valueSpinnerCheckBox1.setEnabled(false);

                // disable value spinner 2
                valueSpinner2.setEnabled(false);
                valueSpinnerCheckBox2.setEnabled(false);
            } else {
                // disable value 1 checkbox
                valueSpinnerCheckBox1.setEnabled(true);

                // disable value spinner 2
                valueSpinner2.setEnabled(false);
                valueSpinnerCheckBox2.setEnabled(false);
            }
        }
    });
    JPanel p2 = new JPanel();
    p2.setLayout(new BoxLayout(p2, BoxLayout.LINE_AXIS));
    p2.add(new JLabel("Operator"));
    p2.add(Box.createHorizontalStrut(20));
    p2.add(operatorsBox);

    // create spinners
    SpinnerNumberModel model1 = new SpinnerNumberModel(0, 0, 10000, 0.1);
    SpinnerNumberModel model2 = new SpinnerNumberModel(0, 0, 10000, 0.1);
    valueSpinner1 = new JSpinner(model1);
    valueSpinner1.setName("valueSpinner1");
    valueSpinner2 = new JSpinner(model2);
    valueSpinner2.setName("valueSpinner2");
    // disable spinner 2 by default
    valueSpinner2.setEnabled(false);
    // create check boxes for inclusive ranges...
    valueSpinnerCheckBox1 = new JCheckBox(new AbstractAction("Inclusive") {

        public void actionPerformed(ActionEvent e) {
            value1Inclusive = valueSpinnerCheckBox1.isSelected();
        }
    });
    valueSpinnerCheckBox2 = new JCheckBox(new AbstractAction("Inclusive") {

        public void actionPerformed(ActionEvent e) {
            value2Inclusive = valueSpinnerCheckBox2.isSelected();
        }
    });
    JPanel p3 = new JPanel();
    p3.setLayout(new BoxLayout(p3, BoxLayout.LINE_AXIS));
    p3.add(new JLabel("Lower Bound"));
    p3.add(Box.createHorizontalStrut(10));
    p3.add(valueSpinner1);
    JPanel lowerBoundPanel = new JPanel(new GridLayout(0, 1));
    lowerBoundPanel.add(p3);
    lowerBoundPanel.add(valueSpinnerCheckBox1);
    JPanel p4 = new JPanel();
    p4.setLayout(new BoxLayout(p4, BoxLayout.LINE_AXIS));
    p4.add(new JLabel("Upper Bound"));
    p4.add(Box.createHorizontalStrut(10));
    p4.add(valueSpinner2);
    JPanel upperBoundPanel = new JPanel(new GridLayout(0, 1));
    upperBoundPanel.add(p4);
    upperBoundPanel.add(valueSpinnerCheckBox2);

    // set grid layout
    this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    add(p1);
    add(p2);
    add(lowerBoundPanel);
    add(upperBoundPanel);
}

From source file:org.opendatakit.appengine.updater.UpdaterWindow.java

/**
 * Create the application./*  w w  w.j  a  v  a 2s . c  om*/
 */
public UpdaterWindow(CommandLine cmd) {
    super();
    AnnotationProcessor.process(this);// if not using AOP
    this.cmd = cmd;
    frame = new JFrame();
    frame.setBounds(100, 100, isLinux() ? 720 : 680, 595);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.addWindowListener(new WindowListener() {
        @Override
        public void windowOpened(WindowEvent e) {
        }

        @Override
        public void windowClosing(WindowEvent e) {
        }

        @Override
        public void windowClosed(WindowEvent e) {
        }

        @Override
        public void windowIconified(WindowEvent e) {
        }

        @Override
        public void windowDeiconified(WindowEvent e) {
        }

        @Override
        public void windowActivated(WindowEvent e) {
        }

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

    JLabel lblEmail = new JLabel(t(TranslatedStrings.EMAIL_LABEL));

    txtEmail = new JTextField();
    txtEmail.setFocusable(true);
    txtEmail.setEditable(true);
    txtEmail.setColumns(60);
    txtEmail.setMaximumSize(txtEmail.getPreferredSize());
    if (cmd.hasOption(ArgumentNameConstants.EMAIL)) {
        txtEmail.setText(cmd.getOptionValue(ArgumentNameConstants.EMAIL));
    }
    lblEmail.setLabelFor(txtEmail);

    JLabel lblToken = new JLabel(t(TranslatedStrings.TOKEN_GRANTING_LABEL));

    txtToken = new JTextField();
    txtToken.setColumns(60);
    txtToken.setMaximumSize(txtToken.getPreferredSize());
    txtToken.setFocusable(false);
    txtToken.setEditable(false);
    if (cmd.hasOption(ArgumentNameConstants.TOKEN_GRANTING_CODE)) {
        txtToken.setText(cmd.getOptionValue(ArgumentNameConstants.TOKEN_GRANTING_CODE));
    }
    lblToken.setLabelFor(txtToken);

    // set up listener for updating warning message
    txtEmail.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent e) {
            updateUI();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            updateUI();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            updateUI();
        }

    });

    // set up listener for updating warning message
    txtToken.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent e) {
            updateUI();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            updateUI();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            updateUI();
        }

    });

    if ((txtEmail.getText().length() > 0) && ((txtToken.getText().length() > 0) || perhapsHasToken())) {
        lblWarning = new JLabel(t(TranslatedStrings.WARNING_ERRANT_LABEL));
    } else {
        lblWarning = new JLabel(t(TranslatedStrings.WARNING_REDIRECT_LABEL));
    }

    JLabel outputArea = new JLabel(t(TranslatedStrings.OUTPUT_LBL));
    editorArea = new JTextPane(new DefaultStyledDocument());
    editorArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
    //Put the editor pane in a scroll pane.
    editorScrollPane = new JScrollPane(editorArea);
    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPane.setPreferredSize(new Dimension(400, 300));
    editorScrollPane.setMinimumSize(new Dimension(10, 10));

    outputArea.setLabelFor(editorScrollPane);
    // Create a container so that we can add a title around
    // the scroll pane. Can't add a title directly to the
    // scroll pane because its background would be white.
    // Lay out the label and scroll pane from top to bottom.
    JPanel listPane = new JPanel();
    listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));
    listPane.add(outputArea);
    listPane.add(Box.createRigidArea(new Dimension(0, 5)));
    listPane.add(editorScrollPane);
    listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    btnDeleteToken = new JButton(t(TranslatedStrings.DELETE_TOKEN_LABEL));
    btnDeleteToken.addActionListener(new DeleteTokenActionListener());
    btnDeleteToken.setEnabled(perhapsHasToken());

    btnChoose = new JButton(t(TranslatedStrings.GET_TOKEN_LABEL));
    if ((txtEmail.getText().length() > 0) && (txtToken.getText().length() > 0) || perhapsHasToken()) {
        if (perhapsHasToken()) {
            btnChoose.setText(t(TranslatedStrings.VERIFY_TOKEN_LABEL));
        } else {
            btnChoose.setText(t(TranslatedStrings.SET_TOKEN_LABEL));
        }
    } else {
        btnChoose.setText(t(TranslatedStrings.GET_TOKEN_LABEL));
    }
    btnChoose.addActionListener(new GetTokenActionListener());
    btnChoose.setEnabled(txtEmail.getText().length() > 0);

    btnUpload = new JButton(t(TranslatedStrings.UPLOAD_LABEL));
    btnUpload.addActionListener(new UploadActionListener());
    btnUpload.setEnabled((txtEmail.getText().length() > 0) && perhapsHasToken());

    btnRollback = new JButton(t(TranslatedStrings.ROLLBACK_LABEL));
    btnRollback.addActionListener(new RollbackActionListener());
    btnRollback.setEnabled((txtEmail.getText().length() > 0) && perhapsHasToken());

    GroupLayout groupLayout = new GroupLayout(frame.getContentPane());
    groupLayout
            .setHorizontalGroup(
                    groupLayout.createSequentialGroup().addContainerGap()
                            .addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addComponent(lblEmail)
                                    .addComponent(txtEmail).addComponent(lblToken).addComponent(txtToken)
                                    .addComponent(lblWarning).addComponent(listPane)
                                    .addGroup(groupLayout.createSequentialGroup().addComponent(btnDeleteToken)
                                            .addGap(3 * HorizontalSpacing).addComponent(btnChoose)
                                            .addGap(HorizontalSpacing).addComponent(btnUpload)
                                            .addGap(3 * HorizontalSpacing, 4 * HorizontalSpacing,
                                                    Short.MAX_VALUE)
                                            .addComponent(btnRollback)))
                            .addContainerGap());

    groupLayout.setVerticalGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(lblEmail)
            .addPreferredGap(ComponentPlacement.RELATED).addComponent(txtEmail)
            .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(lblToken)
            .addPreferredGap(ComponentPlacement.RELATED).addComponent(txtToken)
            .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(lblWarning)
            .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(listPane)
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(btnDeleteToken)
                    .addComponent(btnChoose).addComponent(btnUpload).addComponent(btnRollback))
            .addContainerGap());

    frame.getContentPane().setLayout(groupLayout);

    frame.addWindowListener(this);
}

From source file:org.isatools.isacreatorconfigurator.configui.FieldInterface.java

private void instantiateFields(String initFieldName) {
    // OVERALL CONTAINER
    JPanel container = new JPanel();
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));
    container.setBackground(UIHelper.BG_COLOR);

    JLabel fieldDefinitionLab = new JLabel(fieldDefinitionHeader, JLabel.CENTER);
    container.add(fieldDefinitionLab);// w ww.  jav  a 2s .c o m

    container.add(Box.createVerticalStrut(5));

    // FIELD LABEL & INPUT BOX CONTAINER
    JPanel fieldCont = new JPanel(new GridLayout(1, 2));
    fieldCont.setBackground(UIHelper.BG_COLOR);

    fieldName = new RoundedJTextField(15);
    fieldName.setText(initFieldName);
    fieldName.setEditable(false);
    UIHelper.renderComponent(fieldName, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JLabel fieldNameLab = UIHelper.createLabel("Field Name: ", UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);
    fieldCont.add(fieldNameLab);
    fieldCont.add(fieldName);
    container.add(fieldCont);

    JPanel descCont = new JPanel(new GridLayout(1, 2));
    descCont.setBackground(UIHelper.BG_COLOR);
    description = new RoundedJTextArea();
    description.setLineWrap(true);
    description.setWrapStyleWord(true);
    UIHelper.renderComponent(description, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JScrollPane descScroll = new JScrollPane(description, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    descScroll.setBackground(UIHelper.BG_COLOR);
    descScroll.setPreferredSize(new Dimension(150, 65));
    descScroll.getViewport().setBackground(UIHelper.BG_COLOR);

    IAppWidgetFactory.makeIAppScrollPane(descScroll);

    JLabel descLab = UIHelper.createLabel("Description: ", UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);
    descLab.setVerticalAlignment(JLabel.TOP);
    descCont.add(descLab);
    descCont.add(descScroll);
    container.add(descCont);

    // add datatype information
    JPanel datatypeCont = new JPanel(new GridLayout(1, 2));
    datatypeCont.setBackground(UIHelper.BG_COLOR);

    DataTypes[] allowedDataTypes = initFieldName.equals(UNIT_STR) ? new DataTypes[] { DataTypes.ONTOLOGY_TERM }
            : DataTypes.values();

    datatype = new JComboBox(allowedDataTypes);
    datatype.addActionListener(this);
    UIHelper.renderComponent(datatype, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, UIHelper.BG_COLOR);

    JLabel dataTypeLab = UIHelper.createLabel("Datatype:", UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);
    datatypeCont.add(dataTypeLab);
    datatypeCont.add(datatype);
    container.add(datatypeCont);

    defaultValContStd = new JPanel(new GridLayout(1, 2));
    defaultValContStd.setBackground(UIHelper.BG_COLOR);

    defaultValCont = Box.createHorizontalBox();
    defaultValCont.setPreferredSize(new Dimension(150, 25));

    defaultValStd = new RoundedFormattedTextField(null, UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR,
            UIHelper.DARK_GREEN_COLOR);
    defaultValCont.setPreferredSize(new Dimension(120, 25));
    defaultValStd.setFormatterFactory(new DefaultFormatterFactory(
            new RegExFormatter(".*", defaultValStd, false, UIHelper.DARK_GREEN_COLOR, UIHelper.RED_COLOR,
                    UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR, UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR)));
    defaultValStd.setForeground(UIHelper.DARK_GREEN_COLOR);
    defaultValStd.setFont(UIHelper.VER_11_PLAIN);

    defaultValCont.add(defaultValStd);

    defaultValLabStd = UIHelper.createLabel(DEFAULT_VAL_STR, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);

    defaultValContStd.add(defaultValLabStd);
    defaultValContStd.add(defaultValCont);
    container.add(defaultValContStd);

    defaultValContBool = new JPanel(new GridLayout(1, 2));
    defaultValContBool.setBackground(UIHelper.BG_COLOR);
    defaultValContBool.setVisible(false);

    listDataSourceCont = new JPanel(new GridLayout(2, 1));
    listDataSourceCont.setBackground(UIHelper.BG_COLOR);
    listDataSourceCont.setVisible(false);

    JLabel listValLab = UIHelper.createLabel("Please enter comma separated list of values:",
            UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);
    listDataSourceCont.add(listValLab);

    listValues = new RoundedJTextArea("SampleVal1, SampleVal2, SampleVal3", 3, 5);
    listValues.setLineWrap(true);
    listValues.setWrapStyleWord(true);
    UIHelper.renderComponent(listValues, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JScrollPane listScroll = new JScrollPane(listValues, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    listScroll.setBackground(UIHelper.BG_COLOR);
    listScroll.getViewport().setBackground(UIHelper.BG_COLOR);

    listDataSourceCont.add(listScroll);
    container.add(listDataSourceCont);

    IAppWidgetFactory.makeIAppScrollPane(listScroll);

    sourceEntryPanel = new JPanel(new BorderLayout());
    sourceEntryPanel.setSize(new Dimension(125, 190));
    sourceEntryPanel.setOpaque(false);
    sourceEntryPanel.setVisible(false);

    preferredOntologySource = new JPanel();
    preferredOntologySource.setLayout(new BoxLayout(preferredOntologySource, BoxLayout.PAGE_AXIS));
    preferredOntologySource.setVisible(false);
    recommendOntologySource = new JCheckBox("Use recommended ontology source?", false);

    UIHelper.renderComponent(recommendOntologySource, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    recommendOntologySource.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (recommendOntologySource.isSelected()) {
                sourceEntryPanel.setVisible(true);
            } else {
                sourceEntryPanel.setVisible(false);
            }
        }
    });

    JPanel useOntologySourceCont = new JPanel(new GridLayout(1, 1));
    useOntologySourceCont.add(recommendOntologySource);

    preferredOntologySource.add(useOntologySourceCont);

    JPanel infoCont = new JPanel(new GridLayout(1, 1));
    JLabel infoLab = UIHelper.createLabel(
            "<html>click on the <strong>configure ontologies</strong> button to open the ontology configurator to edit the list of ontologies and search areas within an ontology</html>",
            UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR);
    infoLab.setPreferredSize(new Dimension(100, 40));
    infoCont.add(infoLab);

    sourceEntryPanel.add(infoCont, BorderLayout.NORTH);

    JLabel preferredOntologiesLab = new JLabel(preferredOntologiesSidePanelIcon);
    preferredOntologiesLab.setVerticalAlignment(SwingConstants.TOP);

    sourceEntryPanel.add(preferredOntologiesLab, BorderLayout.WEST);

    ontologiesToUseModel = new DefaultTableModel(new String[0][2], ontologyColumnHeaders) {
        @Override
        public boolean isCellEditable(int i, int i1) {
            return false;
        }
    };
    ontologiesToUse = new JTable(ontologiesToUseModel);
    ontologiesToUse.getTableHeader().setBackground(UIHelper.BG_COLOR);

    try {
        ontologiesToUse.setDefaultRenderer(Class.forName("java.lang.Object"),
                new CustomSpreadsheetCellRenderer());
    } catch (ClassNotFoundException e) {
        // empty
    }

    renderTableHeader();

    JScrollPane ontologiesToUseScroller = new JScrollPane(ontologiesToUse,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    ontologiesToUseScroller.setBorder(new EmptyBorder(0, 0, 0, 0));
    ontologiesToUseScroller.setPreferredSize(new Dimension(100, 80));
    ontologiesToUseScroller.setBackground(UIHelper.BG_COLOR);
    ontologiesToUseScroller.getViewport().setBackground(UIHelper.BG_COLOR);

    IAppWidgetFactory.makeIAppScrollPane(ontologiesToUseScroller);

    sourceEntryPanel.add(ontologiesToUseScroller);

    JPanel buttonCont = new JPanel(new BorderLayout());
    final JLabel openConfigButton = new JLabel(ontologyConfigIcon);
    openConfigButton.setVerticalAlignment(SwingConstants.TOP);
    openConfigButton.setHorizontalAlignment(SwingConstants.RIGHT);

    MouseAdapter showOntologyConfigurator = new MouseAdapter() {

        public void mouseEntered(MouseEvent mouseEvent) {
            openConfigButton.setIcon(ontologyConfigIconOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            openConfigButton.setIcon(ontologyConfigIcon);
        }

        public void mousePressed(MouseEvent mouseEvent) {

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    if (openConfigButton.isEnabled()) {
                        openConfigButton.setIcon(ontologyConfigIcon);
                        ontologyConfig = new OntologyConfigUI(ontologiesToQuery, selectedOntologies);
                        ontologyConfig.addPropertyChangeListener("ontologySelected",
                                new PropertyChangeListener() {
                                    public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
                                        selectedOntologies = (ListOrderedMap<String, RecommendedOntology>) propertyChangeEvent
                                                .getNewValue();
                                        updateTable();
                                    }
                                });
                        showPopupInCenter(ontologyConfig);
                    }
                }
            });
        }

    };

    openConfigButton.addMouseListener(showOntologyConfigurator);

    buttonCont.add(openConfigButton, BorderLayout.EAST);

    sourceEntryPanel.add(buttonCont, BorderLayout.SOUTH);
    preferredOntologySource.add(sourceEntryPanel);
    container.add(preferredOntologySource);

    String[] contents = new String[] { "true", "false" };
    defaultValBool = new

    JComboBox(contents);

    UIHelper.renderComponent(defaultValBool, UIHelper.VER_12_PLAIN, UIHelper.DARK_GREEN_COLOR,
            UIHelper.BG_COLOR);

    JLabel defaultValLabBool = UIHelper.createLabel(DEFAULT_VAL_STR, UIHelper.VER_12_BOLD,
            UIHelper.DARK_GREEN_COLOR);

    defaultValContBool.add(defaultValLabBool);
    defaultValContBool.add(defaultValBool);
    container.add(defaultValContBool);

    // RegExp data entry
    isInputFormatted = new JCheckBox("Is the input formatted?", false);
    isInputFormatted.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    isInputFormatted.setHorizontalAlignment(SwingConstants.LEFT);

    UIHelper.renderComponent(isInputFormatted, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    isInputFormatted.addActionListener(this);
    container.add(UIHelper.wrapComponentInPanel(isInputFormatted));

    inputFormatCont = new JPanel();

    inputFormatCont.setLayout(new BoxLayout(inputFormatCont, BoxLayout.LINE_AXIS));
    inputFormatCont.setVisible(false);
    inputFormatCont.setBackground(UIHelper.BG_COLOR);
    inputFormat = new RoundedJTextField(10);
    inputFormat.setText(".*");
    inputFormat.setSize(new Dimension(150, 19));

    inputFormat.setPreferredSize(new Dimension(160, 25));
    inputFormat.setToolTipText("Field expects a regular expression describing the input format.");
    UIHelper.renderComponent(inputFormat, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JLabel inputFormatLab = UIHelper.createLabel("Input format:", UIHelper.VER_11_BOLD,
            UIHelper.DARK_GREEN_COLOR);
    inputFormatLab.setVerticalAlignment(SwingConstants.TOP);

    inputFormatCont.add(inputFormatLab);
    inputFormatCont.add(inputFormat);
    JLabel checkRegExp = new JLabel(checkRegExIcon, JLabel.RIGHT);
    checkRegExp.setOpaque(false);
    checkRegExp.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            String regexToCheck = inputFormat.getText();

            final CheckRegExGUI regexChecker = new CheckRegExGUI(regexToCheck);
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    regexChecker.createGUI();
                }
            });
            regexChecker.addPropertyChangeListener("close", new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    main.getApplicationContainer().hideSheet();
                }
            });
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    main.getApplicationContainer().showJDialogAsSheet(regexChecker);
                }
            });
        }

    }

    );
    inputFormatCont.add(checkRegExp);
    container.add(inputFormatCont);

    usesTemplateForWizard = new JCheckBox("Requires template for wizard?", false);
    usesTemplateForWizard.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    usesTemplateForWizard.setHorizontalAlignment(SwingConstants.LEFT);

    UIHelper.renderComponent(usesTemplateForWizard, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    usesTemplateForWizard.addActionListener(this);
    container.add(UIHelper.wrapComponentInPanel(usesTemplateForWizard));

    wizardTemplatePanel = new JPanel(new GridLayout(1, 2));
    wizardTemplatePanel.setVisible(false);
    wizardTemplatePanel.setBackground(UIHelper.BG_COLOR);

    wizardTemplate = new RoundedJTextArea();
    wizardTemplate.setToolTipText("A template for the wizard to auto-create the data...");
    wizardTemplate.setLineWrap(true);
    wizardTemplate.setWrapStyleWord(true);
    UIHelper.renderComponent(wizardTemplate, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JScrollPane wizScroll = new JScrollPane(wizardTemplate, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    wizScroll.getViewport().setBackground(UIHelper.BG_COLOR);
    wizScroll.setPreferredSize(new Dimension(70, 60));

    IAppWidgetFactory.makeIAppScrollPane(wizScroll);

    JLabel wizardTemplateLab = UIHelper.createLabel("Template definition:", UIHelper.VER_11_BOLD,
            UIHelper.DARK_GREEN_COLOR);
    wizardTemplateLab.setVerticalAlignment(JLabel.TOP);

    wizardTemplatePanel.add(wizardTemplateLab);
    wizardTemplatePanel.add(wizScroll);

    container.add(wizardTemplatePanel);

    JPanel checkCont = new JPanel(new GridLayout(3, 2));
    checkCont.setBackground(UIHelper.BG_COLOR);
    checkCont.setBorder(new TitledBorder(new RoundedBorder(UIHelper.DARK_GREEN_COLOR, 4),
            "Behavioural Attributes", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
            UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR));

    required = new JCheckBox("Required ", true);

    UIHelper.renderComponent(required, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    checkCont.add(required);

    acceptsMultipleValues = new JCheckBox("Allow multiple instances", false);

    UIHelper.renderComponent(acceptsMultipleValues, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    checkCont.add(acceptsMultipleValues);
    acceptsFileLocations = new JCheckBox("Accepts file locations", false);

    acceptsFileLocations.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            acceptsMultipleValues.setSelected(false);
            acceptsMultipleValues.setEnabled(!acceptsFileLocations.isSelected());
        }
    });

    UIHelper.renderComponent(acceptsFileLocations, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    checkCont.add(acceptsFileLocations);

    hidden = new JCheckBox("hidden?", false);

    UIHelper.renderComponent(hidden, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    checkCont.add(hidden);

    forceOntologySelection = new JCheckBox("Force ontology selection", false);
    UIHelper.renderComponent(forceOntologySelection, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);

    checkCont.add(forceOntologySelection);

    container.add(checkCont);

    JScrollPane contScroll = new JScrollPane(container, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    contScroll.setBorder(null);
    contScroll.setAutoscrolls(true);

    IAppWidgetFactory.makeIAppScrollPane(contScroll);

    add(contScroll, BorderLayout.NORTH);
}

From source file:org.jdal.swing.PageableTable.java

/**
 * Create the right menu bar//from  w  w w.  ja  v a 2  s.  co m
 */
private void createMenu() {
    rightMenuBar = new JMenuBar();
    rightMenuBar.setLayout(new BoxLayout(rightMenuBar, BoxLayout.PAGE_AXIS));
    rightMenuBar.setMargin(new Insets(0, 0, 0, 0));
    // Add Visibility menu
    JMenu menu = new JMenu();
    menu.setMargin(new Insets(0, 0, 0, 0));
    menu.setIcon(visibilityMenuIcon);
    menu.setMaximumSize(new Dimension(50, 50));
    visibilityBox = new VisibilityBox(columnDescriptors);
    menu.add(visibilityBox);
    menu.getPopupMenu().addPopupMenuListener(new VisibilityPopupListener());
    JMenuItem okMenuItem = new JMenuItem(new OkVisibilityAction());
    JMenuItem cancelMenuItem = new JMenuItem(new CancelVisibilityAction());
    menu.addSeparator();
    menu.add(okMenuItem);
    menu.add(cancelMenuItem);
    rightMenuBar.add(menu);
    JMenu prefsMenu = new JMenu();
    prefsMenu.setMargin(new Insets(0, 0, 0, 0));
    prefsMenu.setIcon(userMenuIcon);
    prefsMenu.setMaximumSize(new Dimension(50, 50));
    prefsMenu.add(new JMenuItem(new LoadPreferencesAction(this, messageSource
            .getMessage("PageableTable.loadPreferences", null, "Load Preferences", Locale.getDefault()))));
    prefsMenu.add(new JMenuItem(new SavePreferencesAction(this, messageSource
            .getMessage("PageableTable.savePreferences", null, "Save Preferences", Locale.getDefault()))));
    rightMenuBar.add(prefsMenu);
    rightMenuBar.add(Box.createVerticalGlue());
    // Add menu bar to right
    add(rightMenuBar, BorderLayout.EAST);
}

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

public void createAndShowGUI() {
    JButton autoZoom = new JButton("Auto Scale");
    autoZoom.addActionListener(new ActionListener() {
        @Override/*  w w w  .  j  a  va  2 s.  com*/
        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:io.github.jeremgamer.editor.panels.Actions.java

public Actions(final JFrame frame, final ActionPanel ap) {
    this.frame = frame;

    this.setBorder(BorderFactory.createTitledBorder(""));
    JButton add = null;/*from w w  w .ja va 2  s  .  com*/
    try {
        add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    add.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                JOptionPane jop = new JOptionPane();
                @SuppressWarnings("static-access")
                String name = jop.showInputDialog(null, "Nommez l'action :", "Crer une action",
                        JOptionPane.QUESTION_MESSAGE);

                if (name != null) {
                    for (int i = 0; i < data.getSize(); i++) {
                        if (data.get(i).equals(name)) {
                            name += "1";
                        }
                    }
                    data.addElement(name);
                    new ActionSave(name);
                    OtherPanel.updateLists();
                    ButtonPanel.updateLists();
                    ActionPanel.updateLists();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

        }

    });

    JButton remove = null;
    try {
        remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    remove.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                if (actionList.getSelectedValue() != null) {
                    File file = new File("projects/" + Editor.getProjectName() + "/actions/"
                            + actionList.getSelectedValue() + ".rbd");
                    JOptionPane jop = new JOptionPane();
                    @SuppressWarnings("static-access")
                    int option = jop.showConfirmDialog(null,
                            "tes-vous sr de vouloir supprimer cette action?", "Avertissement",
                            JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);

                    if (option == JOptionPane.OK_OPTION) {
                        if (actionList.getSelectedValue().equals(ap.getFileName())) {
                            ap.setFileName("");
                        }
                        ap.hide();
                        file.delete();
                        data.remove(actionList.getSelectedIndex());
                        OtherPanel.updateLists();
                        ButtonPanel.updateLists();
                    }
                }
            } catch (NullPointerException npe) {
                npe.printStackTrace();
            }

        }

    });

    JPanel buttons = new JPanel();
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS));
    buttons.add(add);
    buttons.add(remove);

    updateList();
    actionList.addMouseListener(new MouseAdapter() {
        @SuppressWarnings("unchecked")
        public void mouseClicked(MouseEvent evt) {
            JList<String> list = (JList<String>) evt.getSource();
            if (evt.getClickCount() == 2) {
                int index = list.locationToIndex(evt.getPoint());
                if (isOpen == false) {
                    ap.show();
                    ap.load(new File("projects/" + Editor.getProjectName() + "/actions/"
                            + list.getModel().getElementAt(index) + ".rbd"));
                    previousSelection = list.getSelectedValue();
                    isOpen = true;
                } else {
                    try {
                        if (previousSelection.equals(list.getModel().getElementAt(index))) {
                            ap.hide();
                            previousSelection = list.getSelectedValue();
                            list.clearSelection();
                            isOpen = false;
                        } else {
                            ap.hideThenShow();
                            previousSelection = list.getSelectedValue();
                            ap.load(new File("projects/" + Editor.getProjectName() + "/actions/"
                                    + list.getModel().getElementAt(index) + ".rbd"));
                        }
                    } catch (NullPointerException npe) {
                        ap.hide();
                        list.clearSelection();
                    }
                }
            } else if (evt.getClickCount() == 3) {
                int index = list.locationToIndex(evt.getPoint());
                if (isOpen == false) {
                    ap.show();
                    ap.load(new File("projects/" + Editor.getProjectName() + "/actions/"
                            + list.getModel().getElementAt(index) + ".rbd"));
                    previousSelection = list.getSelectedValue();
                    isOpen = true;
                } else {
                    try {
                        if (previousSelection.equals(list.getModel().getElementAt(index))) {
                            ap.hide();
                            previousSelection = list.getSelectedValue();
                            list.clearSelection();
                            isOpen = false;
                        } else {
                            ap.hideThenShow();
                            previousSelection = list.getSelectedValue();
                            ap.load(new File("projects/" + Editor.getProjectName() + "/actions/"
                                    + list.getModel().getElementAt(index) + ".rbd"));
                        }
                    } catch (NullPointerException npe) {
                        ap.hide();
                        list.clearSelection();
                    }
                }
            }
        }
    });
    JScrollPane listPane = new JScrollPane(actionList);
    listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED);
    this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    this.add(buttons);
    this.add(listPane);
    OtherPanel.updateLists();
}

From source file:edu.ucla.stat.SOCR.motionchart.MotionMouseListener.java

protected JPanel getPanel(final JDialog dialog, DefaultTableModel tModel, ArrayList<String> rowIdentifiers) {
    JPanel panel = new JPanel();
    JButton close = new JButton("Close");
    close.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);//from w  ww.j av a  2s  .c  om
        }
    });
    close.setAlignmentX(Component.CENTER_ALIGNMENT);

    RowHeaderTable table = new RowHeaderTable(tModel);
    table.getDataTable().setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.getDataTable().setDefaultRenderer(Object.class, new ColorRenderer(false));
    table.setCellsEditable(false);
    table.setHeadersEditable(false);

    for (int r = 0; r < tModel.getRowCount() && rowIdentifiers.size() <= tModel.getRowCount(); r++) {
        table.getRowHeaderModel().setValueAt(rowIdentifiers.get(r), r, 0);
    }

    Dimension d = table.getRowHeaderTable().getPreferredScrollableViewportSize();
    d.width = 55;
    table.getRowHeaderTable().setPreferredScrollableViewportSize(d);

    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    panel.add(table);
    panel.add(Box.createRigidArea(new Dimension(0, 5)));
    panel.add(close);

    return panel;
}

From source file:uk.nhs.cfh.dsp.yasb.expression.builder.RefinedExpressionBuilderPanel.java

/**
 * Inits the components./*from  ww  w  .  j a v  a  2  s .c om*/
 */
public synchronized void initComponents() {

    // generate and store concept corresponding to Side |182353008|
    if (terminologyConceptDAO != null) {
        lateralityParentConcept = TerminologyConceptUtils.getConceptForID(terminologyConceptDAO, "182353008");
    }

    // add a collapsible panel in NORTH position with a concept search panel
    searchPanel = new SearchPanel(terminologySearchService, selectionService, applicationService,
            terminologyConceptDAO);
    searchPanel.initComponents();
    searchPanel.setPreferredSize(new Dimension(350, 450));
    collapsiblePane = new JXCollapsiblePane(new BorderLayout());
    collapsiblePane.add(searchPanel, BorderLayout.CENTER);
    collapsiblePane.setCollapsed(true);

    // create panel for rendering label
    renderingLabel = new ExpressionRenderingLabel(humanReadableRender);
    renderingLabel.initComponents();

    focusConceptPanel = new ConceptPanel(humanReadableRender);
    focusConceptPanel.initComponents();

    // create top panel with some instructions
    JPanel p1 = new JPanel();
    p1.setLayout(new BoxLayout(p1, BoxLayout.LINE_AXIS));
    p1.add(focusConceptPanel);

    // add button for editing focus concept
    JideButton editFocusConceptButton = new JideButton(new AbstractAction("Edit") {
        public void actionPerformed(ActionEvent e) {
            if (collapsiblePane.isCollapsed()) {
                collapsiblePane.setCollapsed(false);
            } else {
                collapsiblePane.setCollapsed(true);
            }
        }
    });
    p1.add(Box.createHorizontalGlue());
    p1.add(editFocusConceptButton);

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.PAGE_AXIS));
    topPanel.add(renderingLabel);
    topPanel.add(p1);

    // create scrollPane that contains the properties
    propertyExpressionListModel = new PropertyExpressionListModel(normalFormGenerator);
    propertiesList = new JXList(propertyExpressionListModel);
    //        propertiesList.setCellRenderer(new PropertyExpressionListCellRenderer(selectionService,
    //                terminologyConceptDAO, applicationService, humanReadableRender));
    propertiesList.setCellRenderer(new ExpressionListCellRenderer(selectionService, terminologyConceptDAO,
            applicationService, humanReadableRender));
    propertiesScrollPane = new JScrollPane();
    propertiesScrollPane.setViewportView(propertiesList);

    //        // add mouse listeners to tree
    //        propertiesList.addMouseListener(new MouseAdapter() {
    //
    //            @Override
    //            public void mouseClicked(MouseEvent e) {
    //                int row = propertiesList.getSelectedIndex();
    //                if(row > -1 && e.getClickCount() == 2)
    //                {
    //                    // get selection
    //                    Object selection = propertiesList.getSelectedValue();
    //
    //                    // evaluate selection and set behaviour
    //                    if(selection instanceof SnomedRelationshipPropertyExpression)
    //                    {
    //                        SnomedRelationshipPropertyExpression propertyExpression =
    //                                (SnomedRelationshipPropertyExpression) selection;
    //                        // get contained relationship
    //                        SnomedRelationship relationship = propertyExpression.getRelationship();
    //                        if(relationship != null)
    //                        {
    //                            // set as selected propertyExpression
    //                            selectedPropertyExpression = propertyExpression;
    //                            // set as active relationship
    //                            activeRelationship = relationship;
    //                        }
    //                    }
    //                }
    //            }
    //        });

    // create laterality hierarchy panel
    createLateralityConceptHierarchyDialog();

    // add panel for adding laterality directly
    JPanel bottomPanel = new JPanel(new BorderLayout());
    // add label and button for laterilty value
    lateralityLabel = new JLabel();
    JButton editLateralityButton = new JButton(new AbstractAction("Edit") {
        public void actionPerformed(ActionEvent e) {
            /*
             get lateralityHierarchyPanel and set parent to
             Side |182353008|
            */

            lateralityHierarchyPanel.setConcept(lateralityParentConcept);
            // show conceptHierarchyDialog
            conceptHierarchyDialog.setLocationRelativeTo(activeFrame);
            conceptHierarchyDialog.setVisible(true);
        }
    });
    bottomPanel.add(new JLabel("<html><b>Laterality of concept </b></html>"), BorderLayout.WEST);
    bottomPanel.add(lateralityLabel, BorderLayout.CENTER);
    bottomPanel.add(editLateralityButton, BorderLayout.EAST);

    // add panels to this panel and main panel
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(topPanel, BorderLayout.NORTH);
    mainPanel.add(propertiesScrollPane, BorderLayout.CENTER);

    // add to this panel
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(borderOffset, borderOffset, borderOffset, borderOffset));
    add(collapsiblePane, BorderLayout.NORTH);
    add(mainPanel, BorderLayout.CENTER);
    add(bottomPanel, BorderLayout.SOUTH);
}

From source file:org.cloudml.ui.graph.Visu.java

public void createFrame() {
    final VisualizationViewer<Vertex, Edge> vv = v.getVisualisationViewer();

    vv.getRenderContext().setVertexIconTransformer(new Transformer<Vertex, Icon>() {
        public Icon transform(final Vertex v) {
            return new Icon() {

                public int getIconHeight() {
                    return 40;
                }//  w  ww  . ja  v  a 2s  . c  o  m

                public int getIconWidth() {
                    return 40;
                }

                public void paintIcon(java.awt.Component c, Graphics g, int x, int y) {
                    ImageIcon img;
                    if (v.getType() == "node") {
                        img = new ImageIcon(this.getClass().getResource("/server.png"));
                    } else if (v.getType() == "platform") {
                        img = new ImageIcon(this.getClass().getResource("/dbms.png"));
                    } else {
                        img = new ImageIcon(this.getClass().getResource("/soft.png"));
                    }
                    ImageObserver io = new ImageObserver() {

                        public boolean imageUpdate(Image img, int infoflags, int x, int y, int width,
                                int height) {
                            // TODO Auto-generated method stub
                            return false;
                        }
                    };
                    g.drawImage(img.getImage(), x, y, getIconHeight(), getIconWidth(), io);

                    if (!vv.getPickedVertexState().isPicked(v)) {
                        g.setColor(Color.black);
                    } else {
                        g.setColor(Color.red);

                        properties.setModel(new CPIMTable(v));
                        runtimeProperties.setModel(new CPSMTable(v));
                    }
                    g.drawString(v.getName(), x - 10, y + 50);
                }
            };
        }
    });

    // create a frame to hold the graph
    final JFrame frame = new JFrame();
    Container content = frame.getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel, BorderLayout.CENTER);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

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

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton save = new JButton("save");
    save.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fc = new JFileChooser();
            int returnVal = fc.showDialog(frame, "save");
            File result = fc.getSelectedFile();
            JsonCodec codec = new JsonCodec();
            OutputStream streamResult;
            try {
                streamResult = new FileOutputStream(result);
                codec.save(dmodel, streamResult);
            } catch (FileNotFoundException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    });
    JButton saveImage = new JButton("save as image");
    saveImage.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fc = new JFileChooser();
            int returnVal = fc.showDialog(frame, "save");
            File result = fc.getSelectedFile();
            JsonCodec codec = new JsonCodec();
            v.writeJPEGImage(result);
        }
    });
    //WE NEED TO UPDATE THE FACADE AND THE GUI
    JButton load = new JButton("load");
    load.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fc = new JFileChooser();
            int returnVal = fc.showDialog(frame, "load");
            File result = fc.getSelectedFile();
            JsonCodec codec = new JsonCodec();
            try {
                InputStream stream = new FileInputStream(result);
                Deployment model = (Deployment) codec.load(stream);
                dmodel = model;
                v.setDeploymentModel(dmodel);
                ArrayList<Vertex> V = v.drawFromDeploymentModel();
                nodeTypes.removeAll();
                nodeTypes.setModel(fillList());

                properties.setModel(new CPIMTable(V.get(0)));
                runtimeProperties.setModel(new CPSMTable(V.get(0)));

                CommandFactory fcommand = new CommandFactory();
                CloudMlCommand load = fcommand.loadDeployment(result.getPath());
                cml.fireAndWait(load);

            } catch (FileNotFoundException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });
    JButton deploy = new JButton("Deploy!");
    deploy.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //cad.deploy(dmodel);
            System.out.println("deploy");
            CommandFactory fcommand = new CommandFactory();
            CloudMlCommand deploy = fcommand.deploy();
            cml.fireAndWait(deploy);
        }
    });

    //right panel
    JPanel intermediary = new JPanel();
    intermediary.setLayout(new BoxLayout(intermediary, BoxLayout.PAGE_AXIS));
    intermediary.setBorder(BorderFactory.createLineBorder(Color.black));

    JLabel jlCPIM = new JLabel();
    jlCPIM.setText("CPIM");

    JLabel jlCPSM = new JLabel();
    jlCPSM.setText("CPSM");

    properties = new JTable(null);
    //properties.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    JTableHeader h = properties.getTableHeader();
    JPanel props = new JPanel();
    props.setLayout(new BorderLayout());
    props.add(new JScrollPane(properties), BorderLayout.CENTER);
    props.add(h, BorderLayout.NORTH);

    runtimeProperties = new JTable(null);
    //runtimeProperties.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    JTableHeader h2 = runtimeProperties.getTableHeader();
    JPanel runProps = new JPanel();
    runProps.setLayout(new BorderLayout());
    runProps.add(h2, BorderLayout.NORTH);
    runProps.add(new JScrollPane(runtimeProperties), BorderLayout.CENTER);

    intermediary.add(jlCPIM);
    intermediary.add(props);
    intermediary.add(jlCPSM);
    intermediary.add(runProps);

    content.add(intermediary, BorderLayout.EAST);

    //Left panel
    JPanel selection = new JPanel();
    JLabel nodes = new JLabel();
    nodes.setText("Types");
    selection.setLayout(new BoxLayout(selection, BoxLayout.PAGE_AXIS));
    nodeTypes = new JList(fillList());
    nodeTypes.setLayoutOrientation(JList.VERTICAL);
    nodeTypes.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    nodeTypes.setVisibleRowCount(10);
    JScrollPane types = new JScrollPane(nodeTypes);
    types.setPreferredSize(new Dimension(150, 80));
    selection.add(nodes);
    selection.add(types);

    content.add(selection, BorderLayout.WEST);

    ((DefaultModalGraphMouse<Integer, Number>) gm)
            .add(new MyEditingGraphMousePlugin(0, vv, v.getGraph(), nodeTypes, dmodel));
    JPanel controls = new JPanel();
    controls.add(plus);
    controls.add(minus);
    controls.add(save);
    controls.add(saveImage);
    controls.add(load);
    controls.add(deploy);
    controls.add(((DefaultModalGraphMouse<Integer, Number>) gm).getModeComboBox());
    content.add(controls, BorderLayout.SOUTH);

    frame.pack();
    frame.setVisible(true);
}

From source file:edu.ucla.stat.SOCR.applications.demo.PortfolioApplication2.java

public void init() {

    //   dataPoints = new LinkedList();
    t1_x = t2_x = 0;/*from  ww  w  . ja  v a2s  .  c  om*/
    t1_y = t2_y = 0.001;
    simulatedPoints = setupUniformSimulate(numStocks, numSimulate);
    tabbedPanelContainer = new JTabbedPane();
    show_tangent = true;

    //   addGraph(chartPanel);
    //   addToolbar(sliderPanel);
    initGraphPanel();
    initMixPanel();
    initInputPanel();
    emptyTool();
    emptyTool2();
    leftControl = new JPanel();
    leftControl.setLayout(new BoxLayout(leftControl, BoxLayout.PAGE_AXIS));
    addRadioButton2Left("Number of Stocks:", "", numStocksArray, numStocks - 2, this);
    addRadioButton2Left("Show Tangent Line :", "", on_off, 0, this);

    JScrollPane mixPanelContainer = new JScrollPane(mixPanel);
    mixPanelContainer.setPreferredSize(new Dimension(600, CHART_SIZE_Y + 100));

    addTabbedPane(GRAPH, graphPanel);

    addTabbedPane(INPUT, inputPanel);

    addTabbedPane(ALL, mixPanelContainer);

    setChart();

    tabbedPanelContainer.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == ALL) {
                mixPanel.removeAll();
                setMixPanel();
                mixPanel.validate();
            } else if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == GRAPH) {
                graphPanel.removeAll();
                setChart();

            } else if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == INPUT) {
                //
                setInputPanel();
            }
        }
    });

    statusTextArea = new JTextPane(); //right side lower
    statusTextArea.setEditable(false);
    JScrollPane statusContainer = new JScrollPane(statusTextArea);
    statusContainer.setPreferredSize(new Dimension(600, 140));

    JSplitPane upContainer = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(leftControl),
            new JScrollPane(tabbedPanelContainer));

    this.getMainPanel().removeAll();
    if (SHOW_STATUS_TEXTAREA) {
        JSplitPane container = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(upContainer),
                statusContainer);
        container.setContinuousLayout(true);
        container.setDividerLocation(0.6);
        this.getMainPanel().add(container, BorderLayout.CENTER);
    } else {

        this.getMainPanel().add(new JScrollPane(upContainer), BorderLayout.CENTER);
    }
    this.getMainPanel().validate();

}