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:Main.java

public static Box createVertBox(Component... comps) {
    return createBox(BoxLayout.PAGE_AXIS, comps);
}

From source file:Main.java

public Main() {
    JPanel textPanel = new JPanel();
    textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.PAGE_AXIS));

    firstTextArea = new JTextArea(10, 50);
    secondTextArea = new JTextArea(10, 50);

    textPanel.add(new JScrollPane(firstTextArea));
    textPanel.add(new JScrollPane(secondTextArea));

    testFrame.add(textPanel, BorderLayout.CENTER);

    copyTextButton = new JButton("Copy text");
    copyTextButton.addActionListener(e -> copyText());
    testFrame.add(copyTextButton, BorderLayout.SOUTH);
}

From source file:Main.java

public Main() {
    JPanel panel = new JPanel();
    BoxLayout boxLayout = new BoxLayout(panel, BoxLayout.PAGE_AXIS);
    panel.setLayout(boxLayout);//from   ww  w  .  j a v  a 2s  .  c om
    for (int i = 0; i < 40; i++) {
        panel.add(new JButton("Button " + i));
    }
    buttons = panel.getComponents();
    activeComponent = buttons[index];
    final JScrollPane scroll = new JScrollPane(panel);

    Timer timer = new Timer(500, new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ((JButton) activeComponent).setForeground(Color.BLACK);
            if (index >= buttons.length - 1) {
                index = 0;
            } else {
                index++;
            }
            activeComponent = buttons[index];
            ((JButton) activeComponent).setForeground(Color.red);
            setView(scroll, activeComponent);
            System.out.println(((JButton) activeComponent).getActionCommand());
        }
    });
    timer.start();

    scroll.setPreferredSize(new Dimension(200, 300));
    JFrame frame = new JFrame();
    frame.add(scroll);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public JPanel createUI() {
    intro.setLabelFor(name);//w w w .  j a v  a  2 s.co m
    final JButton button = new JButton("Pick a new name...");
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 10, 20));
    intro.setAlignmentX(JComponent.CENTER_ALIGNMENT);
    name.setAlignmentX(JComponent.CENTER_ALIGNMENT);
    button.setAlignmentX(JComponent.CENTER_ALIGNMENT);
    panel.add(intro);
    panel.add(Box.createVerticalStrut(5));
    panel.add(name);
    panel.add(Box.createRigidArea(new Dimension(150, 10)));
    panel.add(button);
    return panel;
}

From source file:Main.java

public void createUI() {
    JPanel borderPanel = new JPanel(new BorderLayout());

    JLabel northLabel = new JLabel("Nawth");
    borderPanel.add(northLabel, BorderLayout.NORTH);

    JComboBox southCombo = new JComboBox();
    borderPanel.add(southCombo, BorderLayout.SOUTH);

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

    JComboBox firstCombo = new JComboBox();
    centerPanel.add(firstCombo);/*from  w  ww.j  av a 2  s . c om*/
    centerPanel.add(Box.createVerticalGlue());
    JPanel centerPanelConstrain = new JPanel(new GridBagLayout());
    centerPanelConstrain.add(centerPanel);
    borderPanel.add(centerPanelConstrain, BorderLayout.CENTER);

    getContentPane().add(borderPanel);
    pack();
}

From source file:CardLayoutDemo.java

public void addCardsToPane(Container pane) {
    JRadioButton[] rb = new JRadioButton[strings.length];
    ButtonGroup group = new ButtonGroup();
    JPanel buttons = new JPanel();
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.PAGE_AXIS));

    for (int i = 0; i < strings.length; i++) {
        rb[i] = new JRadioButton("Show component #" + (i + 1));
        rb[i].setActionCommand(String.valueOf(i));
        rb[i].addActionListener(this);
        group.add(rb[i]);/*from  www  . j av  a 2  s  . co  m*/
        buttons.add(rb[i]);
    }
    rb[0].setSelected(true);

    //Create the panel that contains the "cards".
    cards = new JPanel(new CardLayout());
    for (int i = 0; i < strings.length; i++) {
        cards.add(createComponent(strings[i]), String.valueOf(i));
    }

    pane.add(buttons, BorderLayout.NORTH);
    pane.add(cards, BorderLayout.CENTER);
}

From source file:QandE.Layout3.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.//from   www . j a v a 2  s  .c  om
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("Layout3");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Add the innards.
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
    p.add(createComponent("Component 1"));
    p.add(Box.createVerticalGlue());
    p.add(createComponent("Component 2"));
    p.add(createComponent("Component 3"));
    p.add(createComponent("Component 4"));
    frame.setContentPane(p);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:qic.ui.AboutPanel.java

public AboutPanel() {
    BoxLayout boxLayout = new BoxLayout(this, BoxLayout.PAGE_AXIS);
    setLayout(boxLayout);//from w  w  w  .  jav  a 2 s .  c  o  m

    JLabel aboutLbl = new JLabel("<html>" + "<p>Durian Copyright (C) 2015 thirdy</p>"
            + "<p>This program is free software: you can redistribute it and/or modify</p>"
            + "<p>it under the terms of the GNU General Public License as published by</p>"
            + "<p>the Free Software Foundation, either version 3 of the License, or</p>"
            + "<p>(at your option) any later version.</p>"
            + "<p>This program comes with ABSOLUTELY NO WARRANTY.</p>"
            + "<p>A copy of the GNU General Public License can be found at https://github.com/thirdy/durian/blob/master/LICENSE</p>"
            + "<br/>" + "<br/>"
            + "<p>Thank you for using Durian. Durian is a fan-made software and is not affiliated with Grinding Gear Games in any way.</p>"
            + "<p>This software is 100% free and open source.</p>"
            + "<p>Durian is a fan-made software and is not affiliated with Grinding Gear Games in any way.</p>"
            + "<br/>" + "<br/>" + "<p>IGN: ManicCompression</p>" + "<p>Reddit: /u/ProFalseIdol</p>"
            + "</html>");

    String websiteUrl = "http://thirdy.github.io/durian/";
    JButton website = new JButtonLink("Website: " + websiteUrl, websiteUrl);

    String forumUrl = "https://www.pathofexile.com/forum/view-thread/1507190";
    JButton forum = new JButtonLink("Forum Thread: " + forumUrl, forumUrl);

    String helpUrl = "http://thirdy.github.io/durian/help/help.htm";
    JButton help = new JButtonLink("Search Term Helper: " + helpUrl, helpUrl);

    add(Box.createRigidArea(new Dimension(5, 10)));
    add(aboutLbl);
    add(Box.createRigidArea(new Dimension(5, 10)));
    add(website);
    add(Box.createRigidArea(new Dimension(5, 10)));
    add(forum);
    add(Box.createRigidArea(new Dimension(5, 10)));
    add(help);

    JPanel helpPanel = new JPanel(new BorderLayout());
    helpPanel.setBorder(BorderFactory.createTitledBorder("Help"));
    JTextArea textArea = new JTextArea();
    textArea.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12));
    try {
        InputStream input = this.getClass().getResource("/help.txt").openStream();
        String str = IOUtils.toString(input);
        textArea.setText(str);
        textArea.setCaretPosition(0);
        input.close();
    } catch (Exception e) {
        logger.error("Error while reading help file", e);
    }
    helpPanel.add(new JScrollPane(textArea), BorderLayout.CENTER);
    add(Box.createRigidArea(new Dimension(5, 10)));
    add(helpPanel);
}

From source file:tk.elevenk.restfulrobot.gui.EditorWindow.java

public EditorWindow() {
    super();/* w ww. j av a 2 s. c om*/
    this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    fileOpen = false;
    editor = new JEditorPane();
    editor.setText("");
    editorScrollPane = new JScrollPane(editor);
    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    this.setMaximumSize(new Dimension(800, 600));
    this.setMinimumSize(new Dimension(320, 240));
    this.add(editorScrollPane);
}

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);/* w  ww  .j  a  v  a  2s  .  co  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();
            }
        }
    });

}