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:de.evaluationtool.gui.EvaluationFrame.java

public EvaluationFrame(File loadLimitFile, File autoEvalDistanceFile, File nameSourceFile,
        File readmeTemplateFile) throws FileNotFoundException {
    super(DEFAULT_TITLE);
    this.nameSource = new NameSource(nameSourceFile);
    this.loadLimitFile = loadLimitFile;
    this.autoEvalDistanceFile = autoEvalDistanceFile;
    this.nameSourceFile = nameSourceFile;
    this.readmeTemplateFile = readmeTemplateFile;
    this.setLocation(100, 100);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setMinimumSize(new Dimension(800, 700));
    this.add(scrollPane);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));

    //      for(ReferenceFormat format: ReferenceFormats.referenceFormats)
    //      {/* www  .  ja va 2 s  .c o  m*/
    //         if(format.hasReadSupport())
    //         {
    //            JMenuItem item = new JMenuItem("Load "+format.getDescription());
    //            fileMenu.add(item);         
    //         }
    //         if(format.hasWriteSupport())
    //         {
    //            JMenuItem item = new JMenuItem("Save "+format.getDescription());
    //            saveMenu.add(item);         
    //         }
    //      }

    for (JMenuItem item : fileMenuItems) {
        fileMenu.add(item);
    }
    //      for(JMenuItem item : saveMenuItems) {saveMenu.add(item);}
    for (JMenuItem item : operationMenuItems) {
        operationMenu.add(item);
    }
    for (JMenuItem item : optionMenuItems) {
        optionMenu.add(item);
    }
    for (JMenuItem item : helpMenuItems) {
        helpMenu.add(item);
    }

    for (JMenu menu : menues) {
        for (Component component : menu.getMenuComponents()) {
            if (component instanceof JMenuItem) {
                ((JMenuItem) component).addActionListener(listener);
            }
        }
        menuBar.add(menu);
    }

    this.setJMenuBar(menuBar);
    this.pack();

    reloadNamesources();
    autoload();
}

From source file:eu.apenet.dpt.standalone.gui.APETabbedPane.java

private JComponent makeButtons() {
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
    p.add(convertBtn);/*from   w  w  w  .j  ava 2 s  .  c o m*/
    p.add(Box.createRigidArea(new Dimension(0, 10)));
    p.add(validateBtn);
    p.add(Box.createRigidArea(new Dimension(0, 10)));
    p.add(convertAndValidateBtn);
    p.add(Box.createRigidArea(new Dimension(0, 10)));
    p.add(convertEdmBtn);
    return p;
}

From source file:eu.apenet.dpt.standalone.gui.APETabbedPane.java

private JComponent makeCheckboxes() {
    xsltPanel.setLayout(new BoxLayout(xsltPanel, BoxLayout.PAGE_AXIS));
    xsltPanel.add(stylesheetLabel);/*from  w  ww.ja  v a2 s .  c  o m*/
    JRadioButton radioButton;
    for (File xsltFile : Utilities.getXsltFiles()) {
        radioButton = new JRadioButton(xsltFile.getName());
        if (xsltFile.getName().equals(retrieveFromDb.retrieveDefaultXsl()))
            radioButton.setSelected(true);
        radioButton.addActionListener(new XsltSelectorListener(dataPreparationToolGUI));
        dataPreparationToolGUI.getGroupXslt().add(radioButton);
        xsltPanel.add(radioButton);
        xsltPanel.add(Box.createRigidArea(new Dimension(0, 10)));
    }
    return xsltPanel;
}

From source file:io.github.jeremgamer.editor.panels.Others.java

public Others(final JFrame frame, final OtherPanel op, final PanelSave ps) {
    this.frame = frame;

    this.setBorder(BorderFactory.createTitledBorder(""));
    JButton add = null;//w w  w  .  ja  va 2 s  . co  m
    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((JFrame) SwingUtilities.windowForComponent(otherList),
                        "Nommez le composant :", "Crer un composant", 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 OtherSave(name);
                    ActionPanel.updateLists();
                    PanelsPanel.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 (otherList.getSelectedValue() != null) {
                    File file = new File("projects/" + Editor.getProjectName() + "/others/"
                            + otherList.getSelectedValue() + ".rbd");
                    JOptionPane jop = new JOptionPane();
                    @SuppressWarnings("static-access")
                    int option = jop.showConfirmDialog((JFrame) SwingUtilities.windowForComponent(otherList),
                            "tes-vous sr de vouloir supprimer ce composant?", "Avertissement",
                            JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);

                    if (option == JOptionPane.OK_OPTION) {
                        File dir = new File("projects/" + Editor.getProjectName() + "/panels");
                        for (File f : FileUtils.listFilesAndDirs(dir, TrueFileFilter.INSTANCE,
                                TrueFileFilter.INSTANCE)) {
                            if (!f.isDirectory()) {
                                try {
                                    ps.load(f);
                                } catch (IOException e) {
                                    e.printStackTrace();
                                }

                                OtherSave os = new OtherSave();
                                try {
                                    os.load(file);
                                } catch (IOException e1) {
                                    e1.printStackTrace();
                                }
                                String type = null;
                                switch (os.getInt("type")) {
                                case 0:
                                    type = "Zone de saisie";
                                    break;
                                case 1:
                                    type = "Zone de saisie de mot de passe";
                                    break;
                                case 2:
                                    type = "Zone de saisie (Grande)";
                                    break;
                                case 3:
                                    type = "Case  cocher";
                                    break;
                                case 4:
                                    type = "Menu droulant";
                                    break;
                                case 5:
                                    type = "Barre de progression";
                                    break;
                                case 6:
                                    type = "Slider";
                                    break;
                                case 7:
                                    type = "Spinner";
                                    break;
                                }
                                for (String section : ps.getSectionsContaining(
                                        otherList.getSelectedValue() + " (" + type + ")")) {
                                    ps.removeSection(section);
                                    try {
                                        ps.save(f);
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }
                        if (otherList.getSelectedValue().equals(op.getFileName())) {
                            op.setFileName("");
                        }
                        op.hide();
                        file.delete();
                        data.remove(otherList.getSelectedIndex());
                        ActionPanel.updateLists();
                        OtherPanel.updateLists();
                        PanelsPanel.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();
    otherList.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) {
                    op.show();
                    op.load(new File("projects/" + Editor.getProjectName() + "/others/"
                            + list.getModel().getElementAt(index) + ".rbd"));
                    previousSelection = list.getSelectedValue();
                    isOpen = true;
                } else {
                    try {
                        if (previousSelection.equals(list.getModel().getElementAt(index))) {
                            op.hide();
                            previousSelection = list.getSelectedValue();
                            list.clearSelection();
                            isOpen = false;
                        } else {
                            op.hideThenShow();
                            previousSelection = list.getSelectedValue();
                            op.load(new File("projects/" + Editor.getProjectName() + "/others/"
                                    + list.getModel().getElementAt(index) + ".rbd"));
                        }
                    } catch (NullPointerException npe) {
                        op.hide();
                        list.clearSelection();
                    }
                }
            } else if (evt.getClickCount() == 3) {
                int index = list.locationToIndex(evt.getPoint());
                if (isOpen == false) {
                    op.show();
                    op.load(new File("projects/" + Editor.getProjectName() + "/others/"
                            + list.getModel().getElementAt(index) + ".rbd"));
                    previousSelection = list.getSelectedValue();
                    isOpen = true;
                } else {
                    try {
                        if (previousSelection.equals(list.getModel().getElementAt(index))) {
                            op.hide();
                            previousSelection = list.getSelectedValue();
                            list.clearSelection();
                            isOpen = false;
                        } else {
                            op.hideThenShow();
                            previousSelection = list.getSelectedValue();
                            op.load(new File("projects/" + Editor.getProjectName() + "/others/"
                                    + list.getModel().getElementAt(index) + ".rbd"));
                        }
                    } catch (NullPointerException npe) {
                        op.hide();
                        list.clearSelection();
                    }
                }
            }
        }
    });
    JScrollPane listPane = new JScrollPane(otherList);
    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.applications.demo.PortfolioApplication.java

private void initSliders() {
    sliderPanel = new JPanel();

    JPanel rPanel = new JPanel();
    JPanel rPanel2 = new JPanel();
    rSliders = new FloatSlider[numStocks];
    R = new double[numStocks];
    double[] r = { 0.0064, 0.0022, 0.02117, 0.01, 0.0134 };

    JPanel matrixPanel = new JPanel();
    mSliders = new FloatSlider[15];
    CORR = new double[numStocks][numStocks];
    double[] m = { 0.0101, 0.0045, 0.0122, 0.0041, 0.0026, 0.0119, 0.0012, 0.0011, 0.0015, 0.0141, 0.0043,
            0.0022, 0.0058, 0.005, 0.0144 };

    rPanel.setLayout(new GridBagLayout());
    rPanel.add(new JLabel("Expected Return:"));
    for (int i = 0; i < numStocks; i++) {
        R[i] = r[i];// ww w  .  j av  a  2  s. co  m
        rSliders[i] = new edu.ucla.stat.SOCR.util.FloatSlider("E(R" + (i + 1) + ")", -0.1, 0.1, r[i], false);
        rSliders[i].setPreferredSize(new Dimension(CHART_SIZE_X / 3, 80));
        rSliders[i]
                .setToolTipText("Slider for adjusting the value of expected return for stock " + (i + 1) + ".");
        newMSlider(1, i, rSliders[i], r[i], rPanel);

    }

    rPanel2.setLayout(new GridBagLayout());
    rPanel2.add(new JLabel("Covariance:"));
    for (int i = 0; i < numStocks; i++) {
        R[i] = r[i];
        mSliders[i] = new edu.ucla.stat.SOCR.util.FloatSlider("VAR(R" + (i + 1) + ")", 0, 0.5);
        mSliders[i].setPreferredSize(new Dimension(CHART_SIZE_X / 3, 80));
        mSliders[i].setToolTipText("Slider for adjusting the value of covariance " + (i + 1) + ".");
        newMSlider(1, i, mSliders[i], m[i], rPanel2);
    }

    matrixPanel.setLayout(new GridBagLayout());
    matrixPanel.add(new JLabel("Correlation Matrix:"));
    int k = 0;
    for (int i = 0; i < numStocks; i++)
        for (int j = 0; j <= i; j++) {
            CORR[i][j] = m[k];
            if (i == j) {
                mSliders[k] = new edu.ucla.stat.SOCR.util.FloatSlider("VAR(R" + (i + 1) + ")", 0, 0.5);
                //   newMSlider(i,j,mSliders[k],m[k],matrixPanel);
            } else {
                mSliders[k] = new edu.ucla.stat.SOCR.util.FloatSlider("COV" + (j + 1) + (i + 1), 0, 0.5);
                mSliders[k].setPreferredSize(new Dimension(CHART_SIZE_X * 5 / 12, 80));
                mSliders[k].setToolTipText("Slider for adjusting the value of covariance matrix (" + (j + 1)
                        + "," + (i + 1) + ").");
                newMSlider(i, j, mSliders[k], m[k], matrixPanel);
            }
            k++;
        }

    sliderPanel.setLayout(new BoxLayout(sliderPanel, BoxLayout.PAGE_AXIS));
    /*Box box = Box.createVerticalBox();
    box.add(rPanel);
    box.add(rPanel2);
    box.add(new JLabel("Correlation Matrix:"));
    box.add(matrixPanel);
    sliderPanel.add(box);*/
    rPanel.setAlignmentX(LEFT_ALIGNMENT);
    rPanel2.setAlignmentX(LEFT_ALIGNMENT);
    matrixPanel.setAlignmentX(LEFT_ALIGNMENT);
    sliderPanel.add(rPanel);
    sliderPanel.add(rPanel2);
    sliderPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    sliderPanel.add(matrixPanel);
    sliderPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    //sliderPanel.setBackground(Color.white);
}

From source file:eu.apenet.dpt.standalone.gui.APETabbedPane.java

private JComponent makeCheckboxesXsd() {
    xsdPanel.setLayout(new BoxLayout(xsdPanel, BoxLayout.PAGE_AXIS));
    xsdPanel.add(schemaLabel);// w w w .  ja  v  a  2 s.co  m
    JRadioButton radioButton;
    for (Xsd_enum xsdEnum : Xsd_enum.values()) {
        radioButton = new JRadioButton(xsdEnum.getReadableName());
        if (xsdEnum.getReadableName().equals(retrieveFromDb.retrieveDefaultXsd()))
            radioButton.setSelected(true);
        radioButton.addActionListener(new XsdSelectorListener(dataPreparationToolGUI));
        dataPreparationToolGUI.getGroupXsd().add(radioButton);
        xsdPanel.add(radioButton);
        xsdPanel.add(Box.createRigidArea(new Dimension(0, 10)));
    }
    for (XsdObject additionalXsd : retrieveFromDb.retrieveAdditionalXsds()) {
        radioButton = new JRadioButton(additionalXsd.getName());
        radioButton.addActionListener(new XsdSelectorListener(dataPreparationToolGUI));
        dataPreparationToolGUI.getGroupXsd().add(radioButton);
        xsdPanel.add(radioButton);
        xsdPanel.add(Box.createRigidArea(new Dimension(0, 10)));
    }
    return xsdPanel;
}

From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.FileSelectionTable.java

/**
 * Returns the component hosting the collection of files to import.
 * /* ww  w. ja  v  a  2  s  . c  o  m*/
 * @return See above.
 */
private JPanel buildTablePane() {
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
    p.add(Box.createVerticalStrut(5));
    p.add(new JScrollPane(table));
    return p;
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopComponentsHelper.java

/**
 * Determines real size of HTML label with text on screen.
 *
 * @param html text with html markup//from  w  ww  .  j  a v a2  s . c  o m
 * @return size of label
 */
public static Dimension measureHtmlText(String html) {
    JFrame testFrame = new JFrame();
    testFrame.setLayout(new BoxLayout(testFrame.getContentPane(), BoxLayout.PAGE_AXIS));
    JLabel testLabel = new JLabel(html);
    testFrame.add(testLabel);
    testFrame.pack();

    Dimension size = testLabel.getSize();

    testFrame.dispose();

    return new Dimension(size);
}

From source file:uk.nhs.cfh.dsp.yasb.searchpanel.SearchPanel.java

/**
 * Creates the button panel./*from  w  w  w. ja  v  a2 s. c  o  m*/
 */
private void createButtonPanel() {

    buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.PAGE_AXIS));

    JPanel fieldsPanel = new JPanel();
    fieldsPanel.add(new JLabel("Search using "));
    fieldsPanel.add(Box.createHorizontalStrut(5));
    fieldsPanel.setLayout(new BoxLayout(fieldsPanel, BoxLayout.LINE_AXIS));
    // create button group for term selection
    JRadioButton allRadioButton = new JRadioButton(new AbstractAction("Term") {

        public void actionPerformed(ActionEvent event) {
            // set search on term
            searchConceptId = false;
            doSearch();
        }
    });

    JRadioButton idRadioButton = new JRadioButton(new AbstractAction("ID") {

        public void actionPerformed(ActionEvent event) {
            // set search on id
            searchConceptId = true;
            doSearch();
        }
    });

    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(allRadioButton);
    buttonGroup.add(idRadioButton);
    buttonGroup.setSelected(allRadioButton.getModel(), true);

    // add search field terms to fields panel
    fieldsPanel.add(allRadioButton);
    fieldsPanel.add(idRadioButton);
    fieldsPanel.add(Box.createHorizontalGlue());

    // create panel that contains button that toggles display of controlsPane
    JideButton controlsButton = new JideButton(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (controlsPane.isCollapsed()) {
                controlsPane.setCollapsed(false);
            } else {
                controlsPane.setCollapsed(true);
            }
        }
    });
    controlsButton.setIcon(new ImageIcon(SearchPanel.class.getResource("resources/configure.png")));
    controlsButton.setToolTipText("Click to display or hide configuration panel");
    JPanel panel4 = new JPanel();
    panel4.setLayout(new BoxLayout(panel4, BoxLayout.LINE_AXIS));
    panel4.add(Box.createHorizontalGlue());
    panel4.add(new JLabel("Change search and display preferences "));
    panel4.add(controlsButton);

    // add panels to button panel
    buttonsPanel.add(fieldsPanel);
    buttonsPanel.add(panel4);
}

From source file:org.nuxeo.launcher.gui.NuxeoFrame.java

protected Component buildSummaryPanel() {
    JPanel summaryPanel = new JPanel();
    summaryPanel.setLayout(new BoxLayout(summaryPanel, BoxLayout.PAGE_AXIS));
    summaryPanel.setBackground(new Color(35, 37, 59));
    summaryPanel.setForeground(Color.WHITE);

    summaryPanel.add(//from   w w  w.j  a  va2s.c o  m
            new JLabel("<html><font color=#ffffdd>" + NuxeoLauncherGUI.getMessage("summary.status.label")));
    summaryStatus = new JLabel(controller.launcher.status());
    summaryStatus.setForeground(Color.WHITE);
    summaryPanel.add(summaryStatus);

    summaryPanel
            .add(new JLabel("<html><font color=#ffffdd>" + NuxeoLauncherGUI.getMessage("summary.url.label")));
    summaryURL = new JLabel(controller.launcher.getURL());
    summaryURL.setForeground(Color.WHITE);
    summaryPanel.add(summaryURL);

    errorMessageLabel = new JLabel();
    errorMessageLabel.setForeground(Color.RED);
    summaryPanel.add(errorMessageLabel);

    summaryPanel.add(new JSeparator());
    ConfigurationGenerator config = controller.launcher.getConfigurationGenerator();
    summaryPanel.add(
            new JLabel("<html><font color=#ffffdd>" + NuxeoLauncherGUI.getMessage("summary.homedir.label")));
    summaryPanel.add(new JLabel("<html><font color=white>" + config.getNuxeoHome().getPath()));
    summaryPanel.add(
            new JLabel("<html><font color=#ffffdd>" + NuxeoLauncherGUI.getMessage("summary.nuxeoconf.label")));
    summaryPanel.add(new JLabel("<html><font color=white>" + config.getNuxeoConf().getPath()));
    summaryPanel.add(
            new JLabel("<html><font color=#ffffdd>" + NuxeoLauncherGUI.getMessage("summary.datadir.label")));
    summaryPanel.add(new JLabel("<html><font color=white>" + config.getDataDir().getPath()));
    return summaryPanel;
}