Example usage for javax.swing BoxLayout Y_AXIS

List of usage examples for javax.swing BoxLayout Y_AXIS

Introduction

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

Prototype

int Y_AXIS

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

Click Source Link

Document

Specifies that components should be laid out top to bottom.

Usage

From source file:OptionDialogTest.java

/**
 * Constructs a button panel.//from  ww  w  . ja va 2 s  .  c o m
 * @param title the title shown in the border
 * @param options an array of radio button labels
 */
public ButtonPanel(String title, String... options) {
    setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), title));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    group = new ButtonGroup();

    // make one radio button for each option
    for (String option : options) {
        JRadioButton b = new JRadioButton(option);
        b.setActionCommand(option);
        add(b);
        group.add(b);
        b.setSelected(option == options[0]);
    }
}

From source file:dnd.ChooseDropActionDemo.java

public ChooseDropActionDemo() {
    super("ChooseDropActionDemo");

    for (int i = 15; i >= 0; i--) {
        from.add(0, "Source item " + i);
    }//from  w  w w .ja v a 2 s .  com

    for (int i = 2; i >= 0; i--) {
        copy.add(0, "Target item " + i);
        move.add(0, "Target item " + i);
    }

    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    dragFrom = new JList(from);
    dragFrom.setTransferHandler(new FromTransferHandler());
    dragFrom.setPrototypeCellValue("List Item WWWWWW");
    dragFrom.setDragEnabled(true);
    dragFrom.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JLabel label = new JLabel("Drag from here:");
    label.setAlignmentX(0f);
    p.add(label);
    JScrollPane sp = new JScrollPane(dragFrom);
    sp.setAlignmentX(0f);
    p.add(sp);
    add(p, BorderLayout.WEST);

    JList moveTo = new JList(move);
    moveTo.setTransferHandler(new ToTransferHandler(TransferHandler.COPY));
    moveTo.setDropMode(DropMode.INSERT);
    JList copyTo = new JList(copy);
    copyTo.setTransferHandler(new ToTransferHandler(TransferHandler.MOVE));
    copyTo.setDropMode(DropMode.INSERT);

    p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    label = new JLabel("Drop to COPY to here:");
    label.setAlignmentX(0f);
    p.add(label);
    sp = new JScrollPane(moveTo);
    sp.setAlignmentX(0f);
    p.add(sp);
    label = new JLabel("Drop to MOVE to here:");
    label.setAlignmentX(0f);
    p.add(label);
    sp = new JScrollPane(copyTo);
    sp.setAlignmentX(0f);
    p.add(sp);
    p.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
    add(p, BorderLayout.CENTER);

    ((JPanel) getContentPane()).setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

    getContentPane().setPreferredSize(new Dimension(320, 315));
}

From source file:components.TableSelectionDemo.java

public TableSelectionDemo() {
    super();//  w  w  w . j ava  2s .  com
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    table = new JTable(new MyTableModel());
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);
    table.getSelectionModel().addListSelectionListener(new RowListener());
    table.getColumnModel().getSelectionModel().addListSelectionListener(new ColumnListener());
    add(new JScrollPane(table));

    add(new JLabel("Selection Mode"));
    buttonGroup = new ButtonGroup();
    addRadio("Multiple Interval Selection").setSelected(true);
    addRadio("Single Selection");
    addRadio("Single Interval Selection");

    add(new JLabel("Selection Options"));
    rowCheck = addCheckBox("Row Selection");
    rowCheck.setSelected(true);
    columnCheck = addCheckBox("Column Selection");
    cellCheck = addCheckBox("Cell Selection");
    cellCheck.setEnabled(false);

    output = new JTextArea(5, 40);
    output.setEditable(false);
    add(new JScrollPane(output));
}

From source file:com.l2jfree.config.gui.Configurator.java

public Configurator(ConfigClassInfo configClassInfo) {
    _configClassInfo = configClassInfo;/* ww w.j  a va2s  . c o m*/

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    {
        final JMenuBar jMenuBar = new JMenuBar();

        {
            jMenuBar.add(getLoadJButton());
        }
        {
            jMenuBar.add(getRefreshJButton());
        }
        {
            jMenuBar.add(Box.createHorizontalGlue());
        }
        {
            jMenuBar.add(getSaveJButton());
        }
        {
            jMenuBar.add(getStoreJButton());
        }

        setJMenuBar(jMenuBar);
    }

    {
        final JPanel jPanel = new JPanel();

        jPanel.setLayout(new BoxLayout(jPanel, BoxLayout.Y_AXIS));

        {
            for (ConfigFieldInfo info : _configClassInfo.getConfigFieldInfos()) {
                final ConfigFieldInfoView view = new ConfigFieldInfoView(info);

                // LOW implement

                jPanel.add(view);
            }
        }

        add(new JScrollPane(jPanel));
    }

    pack();
    setSize(600, 400);
    setLocationByPlatform(true);
    setVisible(true);
}

From source file:gdt.jgui.tool.JIconSelector.java

/**
 * The default constructor.//from   www. j a  va 2  s.com
 */
public JIconSelector() {
    FlowLayout flowLayout = new FlowLayout(FlowLayout.LEFT, 5, 5);
    flowLayout.setAlignOnBaseline(true);
    WrapLayout wrapLayout = new WrapLayout(FlowLayout.LEFT, 5, 5);
    wrapLayout.setAlignOnBaseline(true);
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    panel = new JPanel();
    panel.setLayout(wrapLayout);
    scrollPane = new JScrollPane(panel);
    add(scrollPane);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
}

From source file:mergedoc.ui.PreferencePanel.java

/**
 * ??/*w  ww.  j a  v  a2 s  . c  o  m*/
 * @throws MergeDocException ????????
 */
public PreferencePanel() throws MergeDocException {

    // 
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setMaximumSize(ComponentFactory.createMaxDimension());

    // ????
    add(createUpperPanel());
    add(ComponentFactory.createSpacer(0, 7));
    add(createLowerPanel());
}

From source file:fuel.gui.stats.MotorStatsPanel.java

public MotorStatsPanel(Database database) throws SQLException {
    this.database = database;
    controller = new Controller();
    JPanel container = new JPanel(new BorderLayout());
    //container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
    JPanel motorSelectionPanel = new JPanel();
    motorSelectionPanel.setLayout(new BoxLayout(motorSelectionPanel, BoxLayout.X_AXIS));
    motorSpecsPanel = new JPanel(new GridLayout(2, 3));
    motorSpecsPanel.setBorder(BorderFactory.createTitledBorder("Specs"));
    graphContainer = new JPanel();
    graphContainer.setLayout(new BoxLayout(graphContainer, BoxLayout.Y_AXIS));
    JComboBox motorSelector = new JComboBox(database.getMotorcycles().toArray());
    motorSelector.setActionCommand("SELECTMOTOR");
    motorSelector.addActionListener(controller);
    motorSelectionPanel.add(motorSelector);

    //motorSelector.setSelectedIndex(0);

    motorSelectionPanel.add(motorSpecsPanel);
    refreshMotorSpecs((Motorcycle) motorSelector.getSelectedItem());

    container.add(motorSelectionPanel, BorderLayout.NORTH);
    JScrollPane scroll = new JScrollPane(graphContainer);
    scroll.getHorizontalScrollBar().setUnitIncrement(10);
    scroll.getVerticalScrollBar().setUnitIncrement(10);
    container.add(scroll, BorderLayout.CENTER);

    refreshGraphs((Motorcycle) motorSelector.getSelectedItem());
    setLayout(new BorderLayout());
    add(container);/*from w ww  . j a  va  2 s.c  o m*/

    setVisible(true);
}

From source file:com.game.ui.views.ItemPanel.java

public void doGui() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JLabel noteLbl = new JLabel(
            "<html><div style='width : 500px;'>Pls select a value from the dropdown or you can create a new "
                    + "entity below. Once selected an Item, its' details will be available below</div></html>");
    noteLbl.setAlignmentX(0);/*  ww w .j a v a 2 s .c  o  m*/
    add(noteLbl);
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    if (ringPanel) {
        for (Item item : GameBean.ringDetails) {
            model.addElement(((Ring) item).getName());
        }
    } else if (armourPanel) {
        for (Item item : GameBean.armourDetails) {
            model.addElement(((Armour) item).getName());
        }
    } else if (potionPanel) {
        for (Item item : GameBean.potionDetails) {
            model.addElement(((Potion) item).getName());
        }
    } else if (treasurePanel) {
        for (Item item : GameBean.treasureDetails) {
            model.addElement(((Treasure) item).getName());
        }
    }
    doCommonStuffForDropDown(model);
    doCommonStuffForContent();
}

From source file:view.tabtables.EmulationTablesDrawer.java

/**
 * @param data//from w  w  w  . ja v a 2  s  .c  o m
 */
public EmulationTablesDrawer(Data data, EmulationManager emulator, JFrame mainFrame) {
    BoxLayout boxY = new BoxLayout(this, BoxLayout.Y_AXIS);
    setLayout(boxY);
    setAlignmentX(CENTER_ALIGNMENT);

    this.data = data;
    this.emulator = emulator;
    this.curStep = 0;

    tablesInitialize();
    graphsInitialize();
}

From source file:EditorPaneExample7.java

public EditorPaneExample7() {
    super("JEditorPane Example 7");

    pane = new JEditorPane();
    pane.setEditable(false); // Start read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;/*from  ww w .j  a v a  2  s  .com*/
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("File name: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);

    c.gridx = 1;
    c.gridy = 0;
    c.gridwidth = 1;
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;

    textField = new JTextField(32);
    panel.add(textField, c);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    c.gridwidth = 2;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);

    getContentPane().add(panel, "South");

    panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    saveButton = new JButton("Save");
    plain = new JCheckBox("Plain Text");
    html = new JCheckBox("HTML");
    rtf = new JCheckBox("RTF");
    panel.add(plain);
    panel.add(html);
    panel.add(rtf);

    ButtonGroup group = new ButtonGroup();
    group.add(plain);
    group.add(html);
    group.add(rtf);
    plain.setSelected(true);

    panel.add(Box.createVerticalStrut(10));
    panel.add(saveButton);
    panel.add(Box.createVerticalGlue());
    panel.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4));

    getContentPane().add(panel, "East");

    // Change page based on text field
    textField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            String fileName = textField.getText().trim();
            file = new File(fileName);
            absolutePath = file.getAbsolutePath();
            String url = "file:///" + absolutePath;

            try {
                // Check if the new page and the old
                // page are the same.
                URL newURL = new URL(url);
                URL loadedURL = pane.getPage();
                if (loadedURL != null && loadedURL.sameFile(newURL)) {
                    return;
                }

                // Try to display the page
                textField.setEnabled(false); // Disable input
                textField.paintImmediately(0, 0, textField.getSize().width, textField.getSize().height);

                saveButton.setEnabled(false);
                saveButton.paintImmediately(0, 0, saveButton.getSize().width, saveButton.getSize().height);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // Busy cursor
                loadingState.setText("Loading...");
                loadingState.paintImmediately(0, 0, loadingState.getSize().width,
                        loadingState.getSize().height);
                loadedType.setText("");
                loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);
                pane.setEditable(false);
                pane.setPage(url);

                loadedType.setText(pane.getContentType());
            } catch (Exception e) {
                JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url },
                        "File Open Error", JOptionPane.ERROR_MESSAGE);
                loadingState.setText("Failed");
                textField.setEnabled(true);
                setCursor(Cursor.getDefaultCursor());
            }
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadingState.setText("Page loaded.");

                textField.setEnabled(true); // Allow entry of new file name
                textField.requestFocus();
                setCursor(Cursor.getDefaultCursor());

                // Allow editing and saving if appropriate
                pane.setEditable(file.canWrite());
                saveButton.setEnabled(file.canWrite());
            }
        }
    });

    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            Writer w = null;
            OutputStream os = System.out;
            String contentType;
            if (plain.isSelected()) {
                contentType = "text/plain";
                w = new OutputStreamWriter(os);
            } else if (html.isSelected()) {
                contentType = "text/html";
                w = new OutputStreamWriter(os);
            } else {
                contentType = "text/rtf";
            }

            EditorKit kit = pane.getEditorKitForContentType(contentType);
            try {
                if (w != null) {
                    kit.write(w, pane.getDocument(), 0, pane.getDocument().getLength());
                    w.flush();
                } else {
                    kit.write(os, pane.getDocument(), 0, pane.getDocument().getLength());
                    os.flush();
                }
            } catch (Exception e) {
                System.out.println("Write failed");
            }
        }
    });
}