Example usage for javax.swing BoxLayout X_AXIS

List of usage examples for javax.swing BoxLayout X_AXIS

Introduction

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

Prototype

int X_AXIS

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

Click Source Link

Document

Specifies that components should be laid out left to right.

Usage

From source file:uk.ac.ebi.demo.picr.swing.PICRBLASTDemo.java

public PICRBLASTDemo() {

    //set general layout
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    add(Box.createVerticalStrut(5));

    //create components
    JPanel row1 = new JPanel();
    row1.setLayout(new BoxLayout(row1, BoxLayout.X_AXIS));
    row1.add(Box.createHorizontalStrut(5));
    row1.setBorder(BorderFactory.createTitledBorder(""));
    row1.add(new JLabel("Fragment:"));
    row1.add(Box.createHorizontalStrut(10));
    final JTextArea sequenceArea = new JTextArea(5, 40);
    sequenceArea.setMaximumSize(sequenceArea.getPreferredSize());
    row1.add(Box.createHorizontalStrut(10));

    row1.add(sequenceArea);/*from  ww w  .j a v a  2s. c  o m*/
    row1.add(Box.createHorizontalGlue());

    JPanel row2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    row2.setBorder(BorderFactory.createTitledBorder("Target Databases"));
    final JList databaseList = new JList();
    JScrollPane listScroller = new JScrollPane(databaseList);
    listScroller.setMaximumSize(new Dimension(100, 10));
    JButton loadDBButton = new JButton("Load Databases");
    row2.add(listScroller);
    row2.add(loadDBButton);

    JPanel row3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    JCheckBox onlyActiveCheckBox = new JCheckBox("Only Active");
    onlyActiveCheckBox.setSelected(true);
    row3.add(new JLabel("Options:  "));
    row3.add(onlyActiveCheckBox);

    add(row1);
    add(row2);
    add(row3);

    final String[] columns = new String[] { "Database", "Accession", "Version", "Taxon ID" };
    final JTable dataTable = new JTable(new Object[0][0], columns);
    dataTable.setShowGrid(true);
    add(new JScrollPane(dataTable));

    JPanel buttonPanel = new JPanel();
    JButton mapAccessionButton = new JButton("Generate Mapping!");
    buttonPanel.add(mapAccessionButton);
    add(buttonPanel);

    //create listeners!

    //update boolean flag in communication class
    onlyActiveCheckBox.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            client.setOnlyActive(((JCheckBox) e.getSource()).isSelected());
        }
    });

    //performs mapping call and updates interface with results
    mapAccessionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            try {

                if (!"".equals(sequenceArea.getText())) {
                    //TODO filters and database are hardcoded here.  They should be added to the input panel at a later revision.
                    java.util.List<UPEntry> entries = client.performBlastMapping(sequenceArea.getText(),
                            databaseList.getSelectedValues(), "90", "", "IDENTITY", "UniprotKB", "", false,
                            new BlastParameter());

                    //compute size of array
                    if (entries != null) {
                        int size = 0;
                        for (UPEntry entry : entries) {
                            for (CrossReference xref : entry.getIdenticalCrossReferences()) {
                                size++;
                            }
                            for (CrossReference xref : entry.getLogicalCrossReferences()) {
                                size++;
                            }
                        }

                        if (size > 0) {

                            final Object[][] data = new Object[size][4];
                            int i = 0;
                            for (UPEntry entry : entries) {
                                for (CrossReference xref : entry.getIdenticalCrossReferences()) {
                                    data[i][0] = xref.getDatabaseName();
                                    data[i][1] = xref.getAccession();
                                    data[i][2] = xref.getAccessionVersion();
                                    data[i][3] = xref.getTaxonId();
                                    i++;
                                }
                                for (CrossReference xref : entry.getLogicalCrossReferences()) {
                                    data[i][0] = xref.getDatabaseName();
                                    data[i][1] = xref.getAccession();
                                    data[i][2] = xref.getAccessionVersion();
                                    data[i][3] = xref.getTaxonId();
                                    i++;
                                }
                            }

                            //refresh
                            DefaultTableModel dataModel = new DefaultTableModel();
                            dataModel.setDataVector(data, columns);
                            dataTable.setModel(dataModel);

                            System.out.println("update done");

                        } else {
                            JOptionPane.showMessageDialog(null, "No Mappind data found.");
                        }
                    } else {
                        JOptionPane.showMessageDialog(null, "No Mappind data found.");
                    }
                } else {
                    JOptionPane.showMessageDialog(null, "You must enter a valid FASTA sequence to map.");
                }
            } catch (SOAPFaultException soapEx) {
                JOptionPane.showMessageDialog(null, "A SOAP Error occurred.");
                soapEx.printStackTrace();
            }
        }
    });

    //loads list of mapping databases from communication class
    loadDBButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            try {

                java.util.List<String> databases = client.loadDatabases();
                if (databases != null && databases.size() > 0) {

                    databaseList.setListData(databases.toArray());
                    System.out.println("database refresh done");

                } else {
                    JOptionPane.showMessageDialog(null, "No Databases Loaded!.");
                }

            } catch (SOAPFaultException soapEx) {
                JOptionPane.showMessageDialog(null, "A SOAP Error occurred.");
                soapEx.printStackTrace();
            }
        }
    });

}

From source file:VASSAL.launch.ModuleManagerWindow.java

public ModuleManagerWindow() {
    setTitle("VASSAL");
    setLayout(new BoxLayout(getContentPane(), BoxLayout.X_AXIS));

    ApplicationIcons.setFor(this);

    final AbstractAction shutDownAction = new AbstractAction() {
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            if (!AbstractLaunchAction.shutDown())
                return;

            final Prefs gl = Prefs.getGlobalPrefs();
            try {
                gl.write();//from w  w  w  . ja v a  2 s .co m
                gl.close();
            } catch (IOException ex) {
                WriteErrorDialog.error(ex, gl.getFile());
            } finally {
                IOUtils.closeQuietly(gl);
            }

            logger.info("Exiting");
            System.exit(0);
        }
    };
    shutDownAction.putValue(Action.NAME, Resources.getString(Resources.QUIT));

    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            shutDownAction.actionPerformed(null);
        }
    });

    // setup menubar and actions
    final MenuManager mm = MenuManager.getInstance();
    final MenuBarProxy mb = mm.getMenuBarProxyFor(this);

    // file menu
    final MenuProxy fileMenu = new MenuProxy(Resources.getString("General.file"));
    fileMenu.setMnemonic(Resources.getString("General.file.shortcut").charAt(0));

    fileMenu.add(mm.addKey("Main.play_module"));
    fileMenu.add(mm.addKey("Main.edit_module"));
    fileMenu.add(mm.addKey("Main.new_module"));
    fileMenu.add(mm.addKey("Main.import_module"));
    fileMenu.addSeparator();

    if (!SystemUtils.IS_OS_MAC_OSX) {
        fileMenu.add(mm.addKey("Prefs.edit_preferences"));
        fileMenu.addSeparator();
        fileMenu.add(mm.addKey("General.quit"));
    }

    // tools menu
    final MenuProxy toolsMenu = new MenuProxy(Resources.getString("General.tools"));

    // Initialize Global Preferences
    Prefs.getGlobalPrefs().getEditor().initDialog(this);
    Prefs.initSharedGlobalPrefs();

    final BooleanConfigurer serverStatusConfig = new BooleanConfigurer(SHOW_STATUS_KEY, null, Boolean.FALSE);
    Prefs.getGlobalPrefs().addOption(null, serverStatusConfig);

    dividerLocationConfig = new IntConfigurer(DIVIDER_LOCATION_KEY, null, -10);
    Prefs.getGlobalPrefs().addOption(null, dividerLocationConfig);

    toolsMenu.add(new CheckBoxMenuItemProxy(new AbstractAction(Resources.getString("Chat.server_status")) {
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            serverStatusView.toggleVisibility();
            serverStatusConfig.setValue(serverStatusConfig.booleanValue() ? Boolean.FALSE : Boolean.TRUE);
            if (serverStatusView.isVisible()) {
                setDividerLocation(getPreferredDividerLocation());
            }
        }
    }, serverStatusConfig.booleanValue()));

    // help menu
    final MenuProxy helpMenu = new MenuProxy(Resources.getString("General.help"));
    helpMenu.setMnemonic(Resources.getString("General.help.shortcut").charAt(0));

    helpMenu.add(mm.addKey("General.help"));
    helpMenu.add(mm.addKey("Main.tour"));
    helpMenu.addSeparator();
    helpMenu.add(mm.addKey("UpdateCheckAction.update_check"));
    helpMenu.add(mm.addKey("Help.error_log"));

    if (!SystemUtils.IS_OS_MAC_OSX) {
        helpMenu.addSeparator();
        helpMenu.add(mm.addKey("AboutScreen.about_vassal"));
    }

    mb.add(fileMenu);
    mb.add(toolsMenu);
    mb.add(helpMenu);

    // add actions
    mm.addAction("Main.play_module", new Player.PromptLaunchAction(this));
    mm.addAction("Main.edit_module", new Editor.PromptLaunchAction(this));
    mm.addAction("Main.new_module", new Editor.NewModuleLaunchAction(this));
    mm.addAction("Main.import_module", new Editor.PromptImportLaunchAction(this));
    mm.addAction("Prefs.edit_preferences", Prefs.getGlobalPrefs().getEditor().getEditAction());
    mm.addAction("General.quit", shutDownAction);

    URL url = null;
    try {
        url = new File(Documentation.getDocumentationBaseDir(), "README.html").toURI().toURL();
    } catch (MalformedURLException e) {
        ErrorDialog.bug(e);
    }
    mm.addAction("General.help", new ShowHelpAction(url, null));

    mm.addAction("Main.tour", new LaunchTourAction(this));
    mm.addAction("AboutScreen.about_vassal", new AboutVASSALAction(this));
    mm.addAction("UpdateCheckAction.update_check", new UpdateCheckAction(this));
    mm.addAction("Help.error_log", new ShowErrorLogAction(this));

    setJMenuBar(mm.getMenuBarFor(this));

    // Load Icons
    moduleIcon = new ImageIcon(getClass().getResource("/images/mm-module.png"));
    activeExtensionIcon = new ImageIcon(getClass().getResource("/images/mm-extension-active.png"));
    inactiveExtensionIcon = new ImageIcon(getClass().getResource("/images/mm-extension-inactive.png"));
    openGameFolderIcon = new ImageIcon(getClass().getResource("/images/mm-gamefolder-open.png"));
    closedGameFolderIcon = new ImageIcon(getClass().getResource("/images/mm-gamefolder-closed.png"));
    fileIcon = new ImageIcon(getClass().getResource("/images/mm-file.png"));

    // build module controls
    final JPanel moduleControls = new JPanel(new BorderLayout());
    modulePanelLayout = new CardLayout();
    moduleView = new JPanel(modulePanelLayout);
    buildTree();
    final JScrollPane scroll = new JScrollPane(tree);
    moduleView.add(scroll, "modules");

    final JEditorPane l = new JEditorPane("text/html", Resources.getString("ModuleManager.quickstart"));
    l.setEditable(false);

    // Try to get background color and font from LookAndFeel;
    // otherwise, use dummy JLabel to get color and font.
    Color bg = UIManager.getColor("control");
    Font font = UIManager.getFont("Label.font");

    if (bg == null || font == null) {
        final JLabel dummy = new JLabel();
        if (bg == null)
            bg = dummy.getBackground();
        if (font == null)
            font = dummy.getFont();
    }

    l.setBackground(bg);
    ((HTMLEditorKit) l.getEditorKit()).getStyleSheet()
            .addRule("body { font: " + font.getFamily() + " " + font.getSize() + "pt }");

    l.addHyperlinkListener(BrowserSupport.getListener());

    // FIXME: use MigLayout for this!
    // this is necessary to get proper vertical alignment
    final JPanel p = new JPanel(new GridBagLayout());
    final GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    p.add(l, c);

    moduleView.add(p, "quickStart");
    modulePanelLayout.show(moduleView, getModuleCount() == 0 ? "quickStart" : "modules");
    moduleControls.add(moduleView, BorderLayout.CENTER);
    moduleControls.setBorder(new TitledBorder(Resources.getString("ModuleManager.recent_modules")));

    add(moduleControls);

    // build server status controls
    final ServerStatusView serverStatusControls = new ServerStatusView(new CgiServerStatus());
    serverStatusControls.setBorder(new TitledBorder(Resources.getString("Chat.server_status")));

    serverStatusView = new ComponentSplitter().splitRight(moduleControls, serverStatusControls, false);
    serverStatusView.revalidate();

    // show the server status controls according to the prefs
    if (serverStatusConfig.booleanValue()) {
        serverStatusView.showComponent();
    }

    setDividerLocation(getPreferredDividerLocation());
    serverStatusView.addPropertyChangeListener("dividerLocation", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            setPreferredDividerLocation((Integer) e.getNewValue());
        }
    });

    final Rectangle r = Info.getScreenBounds(this);
    serverStatusControls.setPreferredSize(new Dimension((int) (r.width / 3.5), 0));

    setSize(3 * r.width / 4, 3 * r.height / 4);

    // Save/load the window position and size in prefs
    final PositionOption option = new PositionOption(PositionOption.key + "ModuleManager", this);
    Prefs.getGlobalPrefs().addOption(option);
}

From source file:VGL.SummaryChartUI.java

private void setupTraitSelectionPanel() {
    JPanel traitSelectionPanel = new JPanel();
    traitSelectionPanel.setLayout(new BoxLayout(traitSelectionPanel, BoxLayout.X_AXIS));
    traitSelectionPanel.setBorder(// ww  w  . ja  v  a2s . c  o  m
            BorderFactory.createTitledBorder(Messages.getInstance().getString("VGLII.SortOffspringBy") + ":"));

    Trait[] traits = manager.getTraitSet();
    traitCheckBoxes = new JCheckBox[traits.length];
    traitCheckBoxLabels = new JLabel[traits.length];
    //make the check boxes and labels
    for (int i = 0; i < traits.length; i++) {
        traitCheckBoxes[i] = new JCheckBox();
        traitCheckBoxes[i].addActionListener(this);
        traitCheckBoxes[i].setSelected(true);

        traitCheckBoxLabels[i] = new JLabel(Messages.getInstance().getTranslatedCharacterName(traits[i]));
    }

    //put them in GUI in randomized order
    for (int i = 0; i < traits.length; i++) {
        traitSelectionPanel.add(traitCheckBoxLabels[scrambledTraitOrder[i]]);
        traitSelectionPanel.add(traitCheckBoxes[scrambledTraitOrder[i]]);
        traitSelectionPanel.add(Box.createHorizontalStrut(15));
    }

    // add sex check box
    sexCheckBox = new JCheckBox();
    sexCheckBox.addActionListener(this);
    sexCheckBox.setSelected(true);

    traitSelectionPanel.add(new JLabel(Messages.getInstance().getString("VGLII.Sex")));
    traitSelectionPanel.add(sexCheckBox);
    traitSelectionPanel.add(Box.createHorizontalStrut(15));

    add(traitSelectionPanel, BorderLayout.NORTH);
    add(resultPanel, BorderLayout.CENTER);

    chiSquaredLabel = new JLabel(CHI_SQUARE_DEFAULT);
    add(chiSquaredLabel, BorderLayout.SOUTH);
}

From source file:Widgets.Simulation.java

public Simulation(final JFrame aFrame, NetworkElement item) {
    super(aFrame);
    grn = ((DynamicalModelElement) item).getGeneNetwork();
    plot = new Plot2DPanel();

    //closing listener
    this.addWindowListener(new WindowAdapter() {
        @Override/*  w w  w . ja  v  a 2 s .c o  m*/
        public void windowClosing(WindowEvent windowEvent) {
            if (simulation != null && simulation.myThread_.isAlive()) {
                simulation.stop();
                System.out.print("Simulation is canceled.\n");
                JOptionPane.showMessageDialog(new Frame(), "Simulation is canceled.", "Warning!",
                        JOptionPane.INFORMATION_MESSAGE);
            }
            escapeAction();
        }
    });

    // Model
    model_.setModel(new DefaultComboBoxModel(new String[] { "Deterministic Model (ODEs)",
            "Stochastic Model (SDEs)", "Stochastic Simulation (Gillespie Algorithm)" }));
    model_.setSelectedIndex(0);

    setModelAction();

    //set plot part
    //display result
    if (grn.getTimeScale().size() >= 1) {
        //update parameters
        numTimeSeries_.setValue(grn.getTraj_itsValue());
        tmax_.setValue(grn.getTraj_maxTime());
        sdeDiffusionCoeff_.setValue(grn.getTraj_noise());

        if (grn.getTraj_model().equals("ode"))
            model_.setSelectedIndex(0);
        else if (grn.getTraj_model().equals("sde"))
            model_.setSelectedIndex(1);
        else
            model_.setSelectedIndex(2);

        //update plot
        trajPlot.removeAll();
        trajPlot.add(trajectoryTabb());
        trajPlot.updateUI();
        trajPlot.setVisible(true);
        trajPlot.repaint();

        analyzeResult.setVisible(true);
    }

    /**
     * ACTIONS
     */

    model_.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            setModelAction();
        }
    });

    analyzeResult.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent arg0) {
            final JDialog a = new JDialog();
            a.setSize(new Dimension(500, 450));
            a.setModal(true);
            a.setTitle("Gene List (seperated by ';')");
            a.setLocationRelativeTo(null);

            final JTextArea focusGenesArea = new JTextArea();
            focusGenesArea.setLineWrap(true);
            focusGenesArea.setEditable(false);
            focusGenesArea.setRows(3);

            String geneNames = "";
            for (int i = 0; i < grn.getNodes().size(); i++)
                geneNames += grn.getNodes().get(i).getLabel() + ";";
            focusGenesArea.setText(geneNames);

            JButton submitButton = new JButton("Submit");
            JButton cancelButton = new JButton("Cancel");
            JPanel buttonPanel = new JPanel();
            buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
            buttonPanel.add(submitButton);
            buttonPanel.add(cancelButton);

            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(final ActionEvent arg0) {
                    a.dispose();
                }
            });

            submitButton.addActionListener(new ActionListener() {
                public void actionPerformed(final ActionEvent arg0) {
                    a.dispose();
                    final JDialog a = new JDialog();
                    a.setSize(new Dimension(500, 450));
                    a.setModal(true);
                    a.setTitle("Statistics");
                    a.setLocationRelativeTo(null);

                    if (grn.getTimeSeries().isEmpty()) {
                        JOptionPane.showMessageDialog(new Frame(), "Please run the simulation first.",
                                "Warning!", JOptionPane.INFORMATION_MESSAGE);
                    } else {
                        JPanel infoPanel = new JPanel();
                        infoPanel.setLayout(new BorderLayout());

                        //output 
                        String[] focusGenes = focusGenesArea.getText().split(";");
                        ;
                        String content = "";

                        //discrete the final state
                        int dimension = grn.getNodes().size();

                        //get gene index
                        int[] focus_index = new int[focusGenes.length];
                        for (int j = 0; j < focusGenes.length; j++)
                            for (int i = 0; i < dimension; i++)
                                if (grn.getNode(i).getLabel().equals(focusGenes[j]))
                                    focus_index[j] = i;

                        JScrollPane jsp = new JScrollPane();
                        //calculate steady states      
                        grn.setLand_itsValue((Integer) numTimeSeries_.getModel().getValue());
                        int[] isConverge = new int[grn.getTraj_itsValue()];
                        String out = calculateSteadyStates(focusGenes, focus_index, isConverge);

                        //show the convergence
                        final JDialog ifconvergent = new JDialog();
                        ifconvergent.setSize(new Dimension(500, 450));
                        ifconvergent.setModal(true);
                        ifconvergent.setTitle("Convergence");
                        ifconvergent.setLocationRelativeTo(null);

                        ConvergenceTable tablePanel = new ConvergenceTable(isConverge);
                        JButton continueButton = new JButton("Click to check the attractors.");
                        continueButton.addActionListener(new ActionListener() {
                            public void actionPerformed(final ActionEvent arg0) {
                                ifconvergent.dispose();
                            }
                        });

                        JPanel ifconvergentPanel = new JPanel();
                        ifconvergentPanel.setLayout(new BorderLayout());
                        ifconvergentPanel.add(tablePanel, BorderLayout.NORTH);
                        ifconvergentPanel.add(continueButton, BorderLayout.SOUTH);

                        ifconvergent.add(ifconvergentPanel);
                        ifconvergent.setVisible(true);

                        //show attractors
                        if (out.equals("ok")) {
                            AttractorTable panel = new AttractorTable(grn, focusGenes);
                            jsp.setViewportView(panel);
                        } else if (grn.getSumPara().size() == 0)
                            content += "Cannot find a steady state!";
                        else
                            content += "\nI dont know why!";

                        if (content != "") {
                            JLabel warningLabel = new JLabel();
                            warningLabel.setText(content);
                            jsp.setViewportView(warningLabel);
                        }

                        grn.setSumPara(null);
                        grn.setCounts(null);

                        //jsp.setPreferredSize(new Dimension(280,130));
                        jsp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
                        jsp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
                        infoPanel.add(jsp, BorderLayout.CENTER);

                        a.add(infoPanel);
                        a.setVisible(true);
                    } //end of else
                }

            });

            JPanel options3 = new JPanel();
            options3.setLayout(new BorderLayout());
            options3.add(focusGenesArea, BorderLayout.NORTH);
            options3.add(buttonPanel);

            options3.setBorder(new EmptyBorder(5, 0, 5, 0));

            a.add(options3);
            a.setVisible(true);
        }
    });

    runButton_.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent arg0) {
            //System.out.print("Memory start: "+s_runtime.totalMemory()+"\n"); 
            enterAction();
        }
    });

    cancelButton_.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent arg0) {
            if (simulation != null)
                simulation.stop();
            System.out.print("Simulation is canceled!\n");
        }
    });

    fixButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent arg0) {
            JDialog a = new JDialog();
            a.setTitle("Fixed initial values");
            a.setSize(new Dimension(400, 400));
            a.setLocationRelativeTo(null);

            JPanel speciesPanel = new JPanel();
            String[] columnName = { "Name", "InitialValue" };
            boolean editable = false; //false;
            new SpeciesTable(speciesPanel, columnName, grn, editable);

            /** LAYOUT **/
            JPanel wholePanel = new JPanel();
            wholePanel.setLayout(new BoxLayout(wholePanel, BoxLayout.Y_AXIS));
            wholePanel.add(speciesPanel);

            a.add(wholePanel);
            a.setModal(true);
            a.setVisible(true);
        }
    });

    randomButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent arg0) {
            final JDialog a = new JDialog();
            a.setTitle("Set boundaries");
            a.setSize(new Dimension(300, 200));
            a.setModal(true);
            a.setLocationRelativeTo(null);

            JPanel upPanel = new JPanel();
            JLabel upLabel = new JLabel("Input the upper boundary: ");
            final JTextField upValue = new JTextField("3");
            upPanel.setLayout(new BoxLayout(upPanel, BoxLayout.X_AXIS));
            upPanel.add(upLabel);
            upPanel.add(upValue);

            JPanel lowPanel = new JPanel();
            JLabel lowLabel = new JLabel("Input the lower boundary: ");
            final JTextField lowValue = new JTextField("0");
            lowPanel.setLayout(new BoxLayout(lowPanel, BoxLayout.X_AXIS));
            lowPanel.add(lowLabel);
            lowPanel.add(lowValue);

            JPanel buttonPanel = new JPanel();
            JButton submit = new JButton("Submit");
            JButton cancel = new JButton("Cancel");
            buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
            buttonPanel.add(submit);
            buttonPanel.add(cancel);
            buttonPanel.setBorder(new EmptyBorder(5, 5, 5, 5));

            submit.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    if (upValue.getText().equals(""))
                        JOptionPane.showMessageDialog(null, "Please input upper boundary", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    else {
                        try {
                            upbound = Double.parseDouble(upValue.getText());

                            if (lowValue.getText().equals(""))
                                JOptionPane.showMessageDialog(null, "Please input lower boundary", "Error",
                                        JOptionPane.ERROR_MESSAGE);
                            else {
                                try {
                                    lowbound = Double.parseDouble(lowValue.getText());

                                    if (upbound < lowbound)
                                        JOptionPane.showMessageDialog(null,
                                                "Upper boundary should be not less than lower boundary",
                                                "Error", JOptionPane.ERROR_MESSAGE);
                                    else
                                        a.dispose();
                                } catch (Exception er) {
                                    JOptionPane.showMessageDialog(null, "Invalid value", "Error",
                                            JOptionPane.INFORMATION_MESSAGE);
                                    MsgManager.Messages.errorMessage(er, "Error", "");
                                }
                            }
                        } catch (Exception er) {
                            JOptionPane.showMessageDialog(null, "Invalid value", "Error",
                                    JOptionPane.INFORMATION_MESSAGE);
                            MsgManager.Messages.errorMessage(er, "Error", "");
                        }
                    }

                }
            });

            cancel.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    JOptionPane.showMessageDialog(null, "The default values are used!", "",
                            JOptionPane.INFORMATION_MESSAGE);
                    a.dispose();
                }
            });

            JPanel wholePanel = new JPanel();
            wholePanel.setLayout(new BoxLayout(wholePanel, BoxLayout.Y_AXIS));
            wholePanel.add(upPanel);
            wholePanel.add(lowPanel);
            wholePanel.add(buttonPanel);
            wholePanel.setBorder(new EmptyBorder(5, 5, 5, 5));

            a.add(wholePanel);
            a.setVisible(true);

        }
    });
}

From source file:Widgets.Simulation.java

protected JPanel trajectoryTabb() {
    JPanel trajectoryPanel = new JPanel();

    //judge if converged
    //final JLabel convergePanel = new JLabel();   
    plot.removeAllPlots();/*from ww w. j  a  v a  2 s  . c  o m*/

    plot.setAxisLabel(0, "t");
    plot.setAxisLabel(1, "Expression Level");
    plot.setPreferredSize(new Dimension(440, 390));

    //ArrayList<DoubleMatrix2D> timeSeries_ = grn.getTimeSeries();
    //ArrayList<DoubleMatrix1D> timeScale_ = grn.getTimeScale();

    //display multiple time series
    //combobox
    //generate time series List
    String[] timeSeriesList = new String[grn.getTimeSeries().size()];

    for (int i = 0; i < grn.getTimeSeries().size(); i++)
        timeSeriesList[i] = Integer.toString(i);

    JLabel selectPanelName = new JLabel("Select trajectory: ");
    JPanel selectPanel = new JPanel();
    //selectPanel.setPreferredSize(new Dimension(1000,10));
    final JComboBox<String> combo = new JComboBox<String>(timeSeriesList);

    //view window
    final JPanel trajectoryViewPanel = new JPanel();
    //trajectoryViewPanel.setPreferredSize(new Dimension(990,500));

    plot.setPreferredSize(new Dimension(440, 350));
    double[] t = grn.getTimeScale().get(0).toArray();
    for (int k = 0; k < grn.getTimeSeries().get(0).columns(); k++)
        plot.addLinePlot(grn.getNode(k).getLabel(), t, grn.getTimeSeries().get(0).viewColumn(k).toArray());
    plot.addLegend("SOUTH");
    plot.repaint();

    //combobox action             
    combo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int row = combo.getSelectedIndex();

            plot.removeAllPlots();

            double[] t = grn.getTimeScale().get(row).toArray();
            for (int k = 0; k < grn.getTimeSeries().get(row).columns(); k++) {
                plot.addLinePlot(grn.getNode(k).getLabel(), t,
                        grn.getTimeSeries().get(row).viewColumn(k).toArray());
            }

            trajectoryViewPanel.repaint();
            trajectoryViewPanel.setVisible(true);
        }
    });

    selectPanel.setLayout(new BoxLayout(selectPanel, BoxLayout.X_AXIS));
    selectPanel.add(selectPanelName);
    selectPanel.add(combo);
    trajectoryViewPanel.add(plot);

    //set layout
    trajectoryPanel.setLayout(new GridBagLayout());
    NetLand.addComponent(trajectoryPanel, trajectoryViewPanel, 0, 0, 1, 1, GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH, 0, 1);
    NetLand.addComponent(trajectoryPanel, selectPanel, 0, 1, 1, 1, GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH, 1, 0);
    //NetLand.addComponent(trajectoryPanel, convergePanel, 0, 2, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, 1, 0);

    return trajectoryPanel;
}

From source file:wigraph.ShortestPathRelation.java

/**
 *
 *//*from   ww w  . j  a v  a 2s.  c o  m*/
private JPanel setUpControls() {
    JPanel jp = new JPanel();
    jp.setBackground(Color.WHITE);
    jp.setLayout(new BoxLayout(jp, BoxLayout.PAGE_AXIS));
    jp.setBorder(BorderFactory.createLineBorder(Color.black, 3));

    // jp_ss - word wist 1 (ss) horizontal panel
    JPanel jp_wl1 = new JPanel();
    jp_wl1.setLayout(new BoxLayout(jp_wl1, BoxLayout.X_AXIS));

    JLabel word1_label = new JLabel("List of words 1 separated by comma");//, Label.RIGHT)
    word_set1 = new JTextField(20);
    word1_label.setDisplayedMnemonic('W');
    word_set1.setFocusAccelerator('W');

    word_set1.setText(INITIAL_WORD_SET1);
    jp_wl1.add(word1_label);
    jp_wl1.add(word_set1);

    // jp_ss - word wist 1 (ss) horizontal panel
    JPanel jp_wl2 = new JPanel();
    jp_wl2.setLayout(new BoxLayout(jp_wl2, BoxLayout.X_AXIS));

    JLabel word2_label = new JLabel("List of words 2");//, Label.RIGHT)
    word_set2 = new JTextField(20);
    word2_label.setDisplayedMnemonic('o');
    word_set2.setFocusAccelerator('o');

    word_set2.setText(INITIAL_WORD_SET2);
    jp_wl2.add(word2_label);
    jp_wl2.add(word_set2);

    jp_wl2.add(Box.createRigidArea(new Dimension(5, 0)));
    jp_wl2.add(search_path_btn);

    jp.add(jp_wl1);
    jp.add(jp_wl2);

    result_len = new JTextField(20);
    jp.add(result_len);

    jp.add(new JLabel("Select a pair of vertices for which a shortest path will be displayed"));
    JPanel jp2 = new JPanel();
    jp2.add(new JLabel("vertex from", SwingConstants.LEFT));
    jp2.add(getSelectionBox(true));
    jp2.setBackground(Color.white);
    JPanel jp3 = new JPanel();
    jp3.add(new JLabel("vertex to", SwingConstants.LEFT));
    jp3.add(getSelectionBox(false));
    jp3.setBackground(Color.white);
    jp.add(jp2);
    jp.add(jp3);

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();
    vv.setGraphMouse(graphMouse);
    JComboBox modeBox = graphMouse.getModeComboBox();
    jp.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    jp.add(modeBox);

    return jp;
}