Example usage for javax.swing BoxLayout LINE_AXIS

List of usage examples for javax.swing BoxLayout LINE_AXIS

Introduction

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

Prototype

int LINE_AXIS

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

Click Source Link

Document

Specifies that components should be laid out in the direction of a line of text as determined by the target container's ComponentOrientation property.

Usage

From source file:TextInputDemo.java

public TextInputDemo() {
    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));

    JPanel leftHalf = new JPanel() {
        //Don't allow us to stretch vertically.
        public Dimension getMaximumSize() {
            Dimension pref = getPreferredSize();
            return new Dimension(Integer.MAX_VALUE, pref.height);
        }//from  ww w  . j  a  va2 s  . co m
    };
    leftHalf.setLayout(new BoxLayout(leftHalf, BoxLayout.PAGE_AXIS));
    leftHalf.add(createEntryFields());
    leftHalf.add(createButtons());

    add(leftHalf);
    add(createAddressDisplay());
}

From source file:AnimatedTextField.java

public AnimatedTextField(String labelText, boolean useBgImage, Color defaultForeground, boolean allowAnimate) {
    this.setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    label.setText(labelText);/* w w w .j  a va  2 s  .co  m*/
    textField.addFocusListener(this);
    label.setBackground(colors[0]);
    textField.setBackground(colors[0]);
    this.foreground = defaultForeground;
    this.allowAnimate = allowAnimate;
    label.setForeground(foreground);
    textField.setForeground(foreground);
    add(label);
    add(textField);
    if (allowAnimate)
        runThread.start();
    if (allowFade) {
        fadeInThread.start();
        fadeOutThread.start();
    }
    setOpaque(false);
}

From source file:AnimatedPasswordField.java

public AnimatedPasswordField(String labelText, boolean useBgImage, Color defaultForeground,
        boolean allowAnimate) {
    this.setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    label.setText(labelText);//from w w w  .  j a v  a  2s. c o  m
    textField.addFocusListener(this);
    label.setBackground(colors[0]);
    textField.setBackground(colors[0]);
    this.foreground = defaultForeground;
    this.allowAnimate = allowAnimate;
    label.setForeground(foreground);
    textField.setForeground(foreground);
    add(label);
    add(textField);
    if (allowAnimate)
        runThread.start();
    if (allowFade) {
        fadeInThread.start();
        fadeOutThread.start();
    }
    setOpaque(false);
}

From source file:com.tascape.qa.th.android.tools.UiAutomatorViewer.java

private void start() throws Exception {
    SwingUtilities.invokeLater(() -> {
        jd = new ViewerParameterDialog("Launch Android App");

        JPanel jpParameters = new JPanel();
        jpParameters.setLayout(new BoxLayout(jpParameters, BoxLayout.PAGE_AXIS));
        jd.setParameterPanel(jpParameters);
        {/*w w  w.  j  a  v  a2 s.  co m*/
            JPanel jp = new JPanel();
            jpParameters.add(jp);
            jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS));
            jp.add(new JLabel("Devices"));
            jp.add(jcbDevices);
        }
        {
            JPanel jp = new JPanel();
            jpParameters.add(jp);
            jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS));
            jp.add(new JLabel("App Package Name"));
            jp.add(jtfApp);
            if (StringUtils.isNotEmpty(appPackageName)) {
                jtfApp.setText(appPackageName);
            }

            jtfApp.addKeyListener(new KeyAdapter() {
                @Override
                public void keyPressed(KeyEvent e) {
                    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                        jbLaunch.doClick();
                    }
                }
            });
        }
        {
            JPanel jp = new JPanel();
            jpParameters.add(jp);
            jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS));
            jp.add(new JLabel("Interaction time (minute)"));
            jsDebugMinutes.getEditor().setEnabled(false);
            jp.add(jsDebugMinutes);
        }
        {
            JPanel jp = new JPanel();
            jpParameters.add(jp);
            jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS));
            jp.add(Box.createRigidArea(new Dimension(518, 2)));
        }

        JPanel jpAction = new JPanel();
        jd.setActionPanel(jpAction);
        jpAction.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
        jpAction.setLayout(new BoxLayout(jpAction, BoxLayout.LINE_AXIS));
        jbLaunch.setFont(jbLaunch.getFont().deriveFont(Font.BOLD));
        jbLaunch.setBorder(BorderFactory.createEtchedBorder());
        jbLaunch.setEnabled(false);
        jpAction.add(jbLaunch);
        jbLaunch.addActionListener(event -> {
            new Thread() {
                @Override
                public void run() {
                    launchApp();
                }
            }.start();
        });

        jd.showDialog();

        new Thread() {
            @Override
            public void run() {
                try {
                    detectDevices();
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }
            }
        }.start();
    });
}

From source file:be.ac.ua.comp.scarletnebula.gui.TaggingPanel.java

public TaggingPanel(final Collection<String> initialTags) {
    super(new BorderLayout());

    for (final String tag : initialTags) {
        taglist.addTag(new TagItem(tag));
    }/*ww w .ja v a  2  s .com*/
    final BetterTextField inputField = new BetterTextField();
    addTagActionListener = new AddTagActionListener(inputField);
    inputField.addActionListener(addTagActionListener);
    final String hint = "Type a tag and press enter";
    inputField.setPlaceHolder(hint);
    inputField.setToolTipText(hint);
    inputField.setInputVerifier(new TagInputVerifier(inputField));
    inputField.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0),
            BorderFactory.createBevelBorder(BevelBorder.LOWERED)));

    taglist.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

    final JScrollPane tagScrollPane = new JScrollPane(taglist);
    tagScrollPane.setBorder(null);

    final JPanel centerPanel = new JPanel(new BorderLayout());
    centerPanel.add(inputField, BorderLayout.NORTH);
    centerPanel.add(tagScrollPane, BorderLayout.CENTER);
    centerPanel.setMaximumSize(new Dimension(250, 500));
    centerPanel.setPreferredSize(new Dimension(200, 200));

    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    add(Box.createHorizontalGlue());
    add(centerPanel);
    add(Box.createHorizontalGlue());

}

From source file:be.ac.ua.comp.scarletnebula.gui.DecoratedCommunicationPanel.java

final public void clearAndFill(final Collection<Server> selectedServers) {

    // Remove all components on there
    invalidate();/*from   ww w  .j  a  va 2s . co  m*/
    removeAll();

    setLayout(new BorderLayout());

    // If there are no servers, or none of the servers are running, do not
    // display the ssh console
    final Collection<Server> connectableServers = new ArrayList<Server>();
    for (final Server s : selectedServers) {
        if (s.getStatus() == VmState.RUNNING && s.getPublicDnsAddress() != null) {
            connectableServers.add(s);
        }
    }

    // If there are no servers to connect to, don't draw the ssh console
    if (connectableServers.size() == 0) {
        log.info("Connection tab clicked and no servers selected to connect to.");
        final BetterTextLabel txt = new BetterTextLabel(
                "Please select at least one running server to connect to.");
        txt.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 20));
        add(txt, BorderLayout.CENTER);
        validate();
        repaint();
    } else {
        final Server connectServer = selectedServers.iterator().next();

        final JPanel propertiesPanel = new JPanel();
        propertiesPanel.setLayout(new BoxLayout(propertiesPanel, BoxLayout.LINE_AXIS));
        propertiesPanel.add(Box.createHorizontalGlue());
        final JButton propertiesButton = new JButton("Properties", Utils.icon("modify16.png"));
        propertiesButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                final ChangeServerSshLoginMethodWindow win = new ChangeServerSshLoginMethodWindow(parent,
                        connectServer);
                win.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        clearAndFill(selectedServers);
                    }
                });
                win.setVisible(true);
            }
        });

        final JButton restartButton = new JButton("Restart connection", Utils.icon("undo16.png"));
        restartButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                clearAndFill(selectedServers);
            }
        });
        propertiesPanel.add(restartButton);
        propertiesPanel.add(Box.createHorizontalStrut(10));
        propertiesPanel.add(propertiesButton);
        propertiesPanel.add(Box.createHorizontalStrut(20));
        propertiesPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
        add(propertiesPanel, BorderLayout.NORTH);

        final SSHPanel sshPanel = new SSHPanel(connectServer);
        sshPanel.setBorder(BorderFactory.createEmptyBorder(5, 20, 10, 20));
        add(sshPanel, BorderLayout.CENTER);

        validate();
        repaint();
    }
}

From source file:components.ListDemo.java

public ListDemo() {
    super(new BorderLayout());

    listModel = new DefaultListModel();
    listModel.addElement("Jane Doe");
    listModel.addElement("John Smith");
    listModel.addElement("Kathy Green");

    //Create the list and put it in a scroll pane.
    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);// w  w w .  j  a  v a2s.co m
    list.addListSelectionListener(this);
    list.setVisibleRowCount(5);
    JScrollPane listScrollPane = new JScrollPane(list);

    JButton hireButton = new JButton(hireString);
    HireListener hireListener = new HireListener(hireButton);
    hireButton.setActionCommand(hireString);
    hireButton.addActionListener(hireListener);
    hireButton.setEnabled(false);

    fireButton = new JButton(fireString);
    fireButton.setActionCommand(fireString);
    fireButton.addActionListener(new FireListener());

    employeeName = new JTextField(10);
    employeeName.addActionListener(hireListener);
    employeeName.getDocument().addDocumentListener(hireListener);
    String name = listModel.getElementAt(list.getSelectedIndex()).toString();

    //Create a panel that uses BoxLayout.
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.add(fireButton);
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(new JSeparator(SwingConstants.VERTICAL));
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(employeeName);
    buttonPane.add(hireButton);
    buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    add(listScrollPane, BorderLayout.CENTER);
    add(buttonPane, BorderLayout.PAGE_END);
}

From source file:fungus.MycoNodeFrame.java

public MycoNodeFrame(MycoNode node) {
    this.node = node;
    this.setTitle("Node " + node.getID());

    graph = JungGraphObserver.getGraph();

    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
    JPanel labelPane = new JPanel();
    labelPane.setLayout(new GridLayout(7, 2));
    JPanel neighborPane = new JPanel();
    neighborPane.setLayout(new BoxLayout(neighborPane, BoxLayout.PAGE_AXIS));
    JPanel logPane = new JPanel();
    logPane.setLayout(new BoxLayout(logPane, BoxLayout.PAGE_AXIS));
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));

    loggingTextArea = new JTextArea("", 25, 100);
    loggingTextArea.setLineWrap(true);/*from  ww  w  . j ava  2  s  . com*/
    loggingTextArea.setEditable(false);
    handler = new MycoNodeLogHandler(node, loggingTextArea);
    handler.addChangeListener(this);
    JScrollPane logScrollPane = new JScrollPane(loggingTextArea);
    logScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    logPane.add(logScrollPane);

    contentPane.add(labelPane);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    contentPane.add(neighborPane);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    contentPane.add(logPane);
    contentPane.add(buttonPane);

    data = node.getHyphaData();
    link = node.getHyphaLink();
    mycocast = node.getMycoCast();

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    stateLabel = new JLabel();
    typeLabel = new JLabel();
    queueLengthLabel = new JLabel();
    sameLabel = new JLabel();
    differentLabel = new JLabel();
    maxCapacityLabel = new JLabel();
    idealImmobileLabel = new JLabel();
    idealHyphaeLabel = new JLabel();
    idealBiomassLabel = new JLabel();
    degreeLabel = new JLabel();
    hyphaDegreeLabel = new JLabel();
    biomassDegreeLabel = new JLabel();
    hyphaUtilizationLabel = new JLabel();
    biomassUtilizationLabel = new JLabel();
    capacityUtilizationLabel = new JLabel();

    labelPane.add(new JLabel("state"));
    labelPane.add(stateLabel);
    labelPane.add(new JLabel("type"));
    labelPane.add(typeLabel);
    labelPane.add(new JLabel("queue"));
    labelPane.add(queueLengthLabel);
    labelPane.add(new JLabel(""));
    labelPane.add(new JLabel(""));
    labelPane.add(new JLabel("same"));
    labelPane.add(sameLabel);
    labelPane.add(new JLabel("different"));
    labelPane.add(differentLabel);
    //labelPane.add(new JLabel("immobile"));
    //labelPane.add(idealImmobileLabel);
    labelPane.add(new JLabel(""));
    labelPane.add(new JLabel("actual"));
    labelPane.add(new JLabel("ideal"));
    labelPane.add(new JLabel("utilization"));
    labelPane.add(new JLabel("hyphae"));
    labelPane.add(hyphaDegreeLabel);
    labelPane.add(idealHyphaeLabel);
    labelPane.add(hyphaUtilizationLabel);
    labelPane.add(new JLabel("biomass"));
    labelPane.add(biomassDegreeLabel);
    labelPane.add(idealBiomassLabel);
    labelPane.add(biomassUtilizationLabel);
    labelPane.add(new JLabel("capacity"));
    labelPane.add(degreeLabel);
    labelPane.add(maxCapacityLabel);
    labelPane.add(capacityUtilizationLabel);

    neighborListControl = new JList();
    neighborListControl.setLayoutOrientation(JList.VERTICAL_WRAP);
    neighborListControl.setVisibleRowCount(-1);

    neighborListScroller = new JScrollPane(neighborListControl);
    neighborListScroller.setPreferredSize(new Dimension(250, 150));
    neighborListScroller.setMinimumSize(new Dimension(250, 150));

    neighborPane.add(neighborListScroller);

    JButton updateButton = new JButton("Refresh");
    ActionListener updater = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            refreshData();
        }
    };
    updateButton.addActionListener(updater);

    JButton closeButton = new JButton("Close");
    ActionListener closer = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            closeFrame();
        }
    };
    closeButton.addActionListener(closer);

    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(updateButton);
    buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(closeButton);

    refreshData();

    JungGraphObserver.addChangeListener(this);

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

From source file:AnimatedTextField.java

public AnimatedTextField(String labelText, boolean useBgImage, Color defaultForeground, boolean allowAnimate,
        boolean allowFade) {
    this.setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    label.setText(labelText);/*from   ww  w  .  j  a v a 2  s .c o  m*/
    textField.addFocusListener(this);
    label.setBackground(colors[0]);
    textField.setBackground(colors[0]);
    this.foreground = defaultForeground;
    this.allowAnimate = allowAnimate;
    this.allowFade = allowFade;
    label.setForeground(foreground);
    textField.setForeground(foreground);
    add(label);
    add(textField);
    if (allowAnimate)
        runThread.start();
    if (allowFade) {
        fadeInThread.start();
        fadeOutThread.start();
    }
    setOpaque(false);
}

From source file:AnimatedPasswordField.java

public AnimatedPasswordField(String labelText, boolean useBgImage, Color defaultForeground,
        boolean allowAnimate, boolean allowFade) {
    this.setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    label.setText(labelText);/*from  w  w  w . ja  v a 2  s.  co m*/
    textField.addFocusListener(this);
    label.setBackground(colors[0]);
    textField.setBackground(colors[0]);
    this.foreground = defaultForeground;
    this.allowAnimate = allowAnimate;
    this.allowFade = allowFade;
    label.setForeground(foreground);
    textField.setForeground(foreground);
    add(label);
    add(textField);
    if (allowAnimate)
        runThread.start();
    if (allowFade) {
        fadeInThread.start();
        fadeOutThread.start();
    }
    setOpaque(false);
}