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

/**
 * Constructs a new RGBAColourChooser//w ww .j a  v a  2s.  c  o  m
 */
public RGBAColourChooser() {
    super(BoxLayout.X_AXIS);

    Box rb = new Box(BoxLayout.X_AXIS);
    rb.add(redLabel);
    rb.add(redSlider);
    Box gb = new Box(BoxLayout.X_AXIS);
    gb.add(greenLabel);
    gb.add(greenSlider);
    Box bb = new Box(BoxLayout.X_AXIS);
    bb.add(blueLabel);
    bb.add(blueSlider);
    Box ab = new Box(BoxLayout.X_AXIS);
    ab.add(alphaLabel);
    ab.add(alphaSlider);

    redSlider.setValue(oldValue.getRed());
    greenSlider.setValue(oldValue.getGreen());
    blueSlider.setValue(oldValue.getBlue());
    alphaSlider.setValue(oldValue.getAlpha());

    redSlider.addChangeListener(this);
    greenSlider.addChangeListener(this);
    blueSlider.addChangeListener(this);
    alphaSlider.addChangeListener(this);

    redSlider.setToolTipText(String.valueOf(redSlider.getValue()));
    greenSlider.setToolTipText(String.valueOf(greenSlider.getValue()));
    blueSlider.setToolTipText(String.valueOf(blueSlider.getValue()));
    alphaSlider.setToolTipText(String.valueOf(alphaSlider.getValue()));

    sliderBox = new Box(BoxLayout.Y_AXIS);
    sliderBox.add(rb);
    sliderBox.add(gb);
    sliderBox.add(bb);
    sliderBox.add(ab);

    add(previewer);
    add(Box.createHorizontalStrut(5));
    add(sliderBox);

}

From source file:BorderDemo.java

public BorderDemo() {
    super(new GridLayout(1, 0));

    // Keep references to the next few borders,
    // for use in titles and compound borders.
    Border blackline, raisedetched, loweredetched, raisedbevel, loweredbevel, empty;

    // A border that puts 10 extra pixels at the sides and
    // bottom of each pane.
    Border paneEdge = BorderFactory.createEmptyBorder(0, 10, 10, 10);

    blackline = BorderFactory.createLineBorder(Color.black);
    raisedetched = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    raisedbevel = BorderFactory.createRaisedBevelBorder();
    loweredbevel = BorderFactory.createLoweredBevelBorder();
    empty = BorderFactory.createEmptyBorder();

    // First pane: simple borders
    JPanel simpleBorders = new JPanel();
    simpleBorders.setBorder(paneEdge);/*from ww w  . j  a v  a2s  . c  o  m*/
    simpleBorders.setLayout(new BoxLayout(simpleBorders, BoxLayout.Y_AXIS));

    addCompForBorder(blackline, "line border", simpleBorders);
    addCompForBorder(raisedetched, "raised etched border", simpleBorders);
    addCompForBorder(loweredetched, "lowered etched border", simpleBorders);
    addCompForBorder(raisedbevel, "raised bevel border", simpleBorders);
    addCompForBorder(loweredbevel, "lowered bevel border", simpleBorders);
    addCompForBorder(empty, "empty border", simpleBorders);

    // Second pane: matte borders
    JPanel matteBorders = new JPanel();
    matteBorders.setBorder(paneEdge);
    matteBorders.setLayout(new BoxLayout(matteBorders, BoxLayout.Y_AXIS));

    ImageIcon icon = createImageIcon("images/wavy.gif", "wavy-line border icon"); // 20x22
    Border border = BorderFactory.createMatteBorder(-1, -1, -1, -1, icon);
    if (icon != null) {
        addCompForBorder(border, "matte border (-1,-1,-1,-1,icon)", matteBorders);
    } else {
        addCompForBorder(border, "matte border (-1,-1,-1,-1,<null-icon>)", matteBorders);
    }
    border = BorderFactory.createMatteBorder(1, 5, 1, 1, Color.red);
    addCompForBorder(border, "matte border (1,5,1,1,Color.red)", matteBorders);

    border = BorderFactory.createMatteBorder(0, 20, 0, 0, icon);
    if (icon != null) {
        addCompForBorder(border, "matte border (0,20,0,0,icon)", matteBorders);
    } else {
        addCompForBorder(border, "matte border (0,20,0,0,<null-icon>)", matteBorders);
    }

    // Third pane: titled borders
    JPanel titledBorders = new JPanel();
    titledBorders.setBorder(paneEdge);
    titledBorders.setLayout(new BoxLayout(titledBorders, BoxLayout.Y_AXIS));
    TitledBorder titled;

    titled = BorderFactory.createTitledBorder("title");
    addCompForBorder(titled, "default titled border" + " (default just., default pos.)", titledBorders);

    titled = BorderFactory.createTitledBorder(blackline, "title");
    addCompForTitledBorder(titled, "titled line border" + " (centered, default pos.)", TitledBorder.CENTER,
            TitledBorder.DEFAULT_POSITION, titledBorders);

    titled = BorderFactory.createTitledBorder(loweredetched, "title");
    addCompForTitledBorder(titled, "titled lowered etched border" + " (right just., default pos.)",
            TitledBorder.RIGHT, TitledBorder.DEFAULT_POSITION, titledBorders);

    titled = BorderFactory.createTitledBorder(loweredbevel, "title");
    addCompForTitledBorder(titled, "titled lowered bevel border" + " (default just., above top)",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.ABOVE_TOP, titledBorders);

    titled = BorderFactory.createTitledBorder(empty, "title");
    addCompForTitledBorder(titled, "titled empty border" + " (default just., bottom)",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.BOTTOM, titledBorders);

    // Fourth pane: compound borders
    JPanel compoundBorders = new JPanel();
    compoundBorders.setBorder(paneEdge);
    compoundBorders.setLayout(new BoxLayout(compoundBorders, BoxLayout.Y_AXIS));
    Border redline = BorderFactory.createLineBorder(Color.red);

    Border compound;
    compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel);
    addCompForBorder(compound, "compound border (two bevels)", compoundBorders);

    compound = BorderFactory.createCompoundBorder(redline, compound);
    addCompForBorder(compound, "compound border (add a red outline)", compoundBorders);

    titled = BorderFactory.createTitledBorder(compound, "title", TitledBorder.CENTER,
            TitledBorder.BELOW_BOTTOM);
    addCompForBorder(titled, "titled compound border" + " (centered, below bottom)", compoundBorders);

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Simple", null, simpleBorders, null);
    tabbedPane.addTab("Matte", null, matteBorders, null);
    tabbedPane.addTab("Titled", null, titledBorders, null);
    tabbedPane.addTab("Compound", null, compoundBorders, null);
    tabbedPane.setSelectedIndex(0);
    String toolTip = new String(
            "<html>Blue Wavy Line border art crew:<br>&nbsp;&nbsp;&nbsp;Bill Pauley<br>&nbsp;&nbsp;&nbsp;Cris St. Aubyn<br>&nbsp;&nbsp;&nbsp;Ben Wronsky<br>&nbsp;&nbsp;&nbsp;Nathan Walrath<br>&nbsp;&nbsp;&nbsp;Tommy Adams, special consultant</html>");
    tabbedPane.setToolTipTextAt(1, toolTip);

    add(tabbedPane);
}

From source file:net.sf.maltcms.chromaui.normalization.spi.actions.OpenPeakGroupRtBoxPlot.java

@Override
public void actionPerformed(ActionEvent ev) {
    IChromAUIProject project = Utilities.actionsGlobalContext().lookup(IChromAUIProject.class);
    if (project != null && !context.isEmpty()) {
        PeakGroupBoxPlotTopComponent pgbpt = new PeakGroupBoxPlotTopComponent();
        PeakGroupRtBoxPlot pgbp = new PeakGroupRtBoxPlot(project, context);
        JPanel bg = new JPanel();
        BoxLayout bl = new BoxLayout(bg, BoxLayout.Y_AXIS);
        bg.setLayout(bl);/*from w ww  . j a va2s .  co m*/
        for (JFreeChart chart : pgbp.createChart()) {
            ChartPanel cp = new ContextAwareChartPanel(chart);
            bg.add(cp);
        }

        JScrollPane jsp = new JScrollPane(bg);
        pgbpt.add(jsp, BorderLayout.CENTER);
        IRegistry registry = Lookup.getDefault().lookup(IRegistryFactory.class).getDefault();
        for (IPeakGroupDescriptor pgd : context) {
            registry.registerTopComponentFor(pgd, pgbpt);
        }
        pgbpt.open();
        pgbpt.requestActive();
    } else {
        Logger.getLogger(getClass().getName()).warning("No IChromAUI project is in lookup!");
    }
}

From source file:com.igormaznitsa.mindmap.plugins.exporters.PNGImageExporter.java

@Override
@Nullable//from   www  . j ava2 s  . c o  m
public JComponent makeOptions() {
    final JPanel panel = UI_FACTORY.makePanel();
    final JCheckBox checkBoxExpandAll = UI_FACTORY.makeCheckBox();
    checkBoxExpandAll.setSelected(flagExpandAllNodes);
    checkBoxExpandAll.setText(Texts.getString("PNGImageExporter.optionUnfoldAll"));
    checkBoxExpandAll.setActionCommand("unfold");

    final JCheckBox checkSaveBackground = UI_FACTORY.makeCheckBox();
    checkSaveBackground.setSelected(flagSaveBackground);
    checkSaveBackground.setText(Texts.getString("PNGImageExporter.optionDrawBackground"));
    checkSaveBackground.setActionCommand("back");

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

    panel.add(checkBoxExpandAll);
    panel.add(checkSaveBackground);

    panel.setBorder(BorderFactory.createEmptyBorder(16, 32, 16, 32));

    return panel;
}

From source file:net.sf.firemox.ui.wizard.Wizard.java

/**
 * Create a new instance of this class.//from   w  w  w  . j  a v a 2  s .c  o  m
 * 
 * @param ability
 *          ability to associate to this ability. If this ability has an
 *          associated picture, it will be used instead of given picture.
 *          Ability's name is also used to fill the title. This ability will
 *          be used to restart this wizard in case of Background button is
 *          used.
 * @param title
 *          the title of this wizard.
 * @param description
 *          the description appended to the title of this wizard. This content
 *          will be displayed as Html.
 * @param iconName
 *          the icon's name to display on the top right place.
 * @param width
 *          the preferred width.
 * @param height
 *          the preferred height.
 */
public Wizard(Ability ability, String title, String description, String iconName, int width, int height) {
    super(MagicUIComponents.magicForm, StringUtils.capitalize(title), true);
    getRootPane().setPreferredSize(new Dimension(width, 300));
    getRootPane().setMinimumSize(new Dimension(width, height));
    setSize(new Dimension(width, height));

    // center
    gameParamPanel = new JPanel(null);
    gameParamPanel.setLayout(new BoxLayout(gameParamPanel, BoxLayout.Y_AXIS));
    if (ability == null)
        getContentPane().add(new WizardTitle(new WizardImageIcon((Image) null, iconName), description),
                BorderLayout.NORTH);
    else
        getContentPane().add(new WizardTitle(new WizardImageIcon(ability.getCard(), iconName), description),
                BorderLayout.NORTH);
    getContentPane().add(gameParamPanel, BorderLayout.CENTER);
    getContentPane().add(new JPanel(), BorderLayout.EAST);

    // bottom
    final JPanel abstractButtonPanel = new JPanel(new BorderLayout());
    this.buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    this.ability = ability;
    abstractButtonPanel.setBorder(null);
    abstractButtonPanel.add(new JSeparator(), BorderLayout.NORTH);
    abstractButtonPanel.add(buttonPanel, BorderLayout.CENTER);
    abstractButtonPanel.add(wizardInfo, BorderLayout.SOUTH);
    getContentPane().add(abstractButtonPanel, BorderLayout.SOUTH);
    setLocationRelativeTo(null);
}

From source file:com.antelink.sourcesquare.gui.view.ExitSourceSquareView.java

/**
 * Create the frame./*from   www.  jav  a2 s .  co m*/
 */
public ExitSourceSquareView() {
    setIconImage(Toolkit.getDefaultToolkit().getImage(SourceSquareView.class.getResource("/antelink.png")));
    setTitle("SourceSquare");
    setResizable(false);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 500, 170);
    this.contentPane = new JPanel();
    this.contentPane.setBackground(Color.WHITE);
    this.contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(this.contentPane);

    this.mainPanel = new JPanel();
    this.mainPanel.setBackground(Color.WHITE);
    GroupLayout gl_contentPane = new GroupLayout(this.contentPane);
    gl_contentPane.setHorizontalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
            .addComponent(this.mainPanel, GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE));
    gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
            .addComponent(this.mainPanel, GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE));
    this.mainPanel.setLayout(new BoxLayout(this.mainPanel, BoxLayout.Y_AXIS));

    JPanel panel_1 = new JPanel();
    panel_1.setBackground(Color.WHITE);
    this.mainPanel.add(panel_1);
    panel_1.setLayout(new BorderLayout(0, 0));

    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout(FlowLayout.CENTER, 50, 20));
    panel.setBackground(Color.WHITE);
    panel_1.add(panel, BorderLayout.SOUTH);

    Image openButtonImage = Toolkit.getDefaultToolkit()
            .getImage(SourceSquareView.class.getResource("/OpenButton.png"));
    this.openButtonLabel = new JLabel(new ImageIcon(openButtonImage));
    this.openButtonLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    panel.add(this.openButtonLabel);

    JLabel exitLabel = new JLabel("<html><b>Closing this window will quit the application</b></html>");
    exitLabel.setFont(new Font("Helvetica", Font.PLAIN, 13));

    JLabel explainLabel = new JLabel("<html>(You won't be able to see or publish your results anymore)</html>");
    explainLabel.setFont(new Font("Helvetica", Font.PLAIN, 13));

    JPanel textPanel = new JPanel();
    textPanel.setBackground(Color.WHITE);
    textPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 0));

    textPanel.add(exitLabel, BorderLayout.CENTER);
    textPanel.add(explainLabel, BorderLayout.CENTER);

    panel_1.add(textPanel, BorderLayout.CENTER);

    CopyrightPanel copyrightPanel = new CopyrightPanel();
    copyrightPanel.setBackground(Color.WHITE);
    this.mainPanel.add(copyrightPanel);
    this.contentPane.setLayout(gl_contentPane);

    setLocationRelativeTo(null);
}

From source file:jchrest.gui.VisualSearchPane.java

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

    panel.add(constructTrainingOptions());
    panel.add(runTrainingButtons());//from   www .ja  va  2 s.  c o  m
    if (freeChartLoaded()) {
        panel.add(createPanel());
    }

    return panel;
}

From source file:mergedoc.ui.MergeDocFrame.java

/**
 * ??????/* www  . ja va  2s .  c  o  m*/
 * @throws MergeDocException ?????
 */
private void initComponent() throws MergeDocException {

    // ????
    preferencePanel = new PreferencePanel();
    mergeManager = new MergeManager();

    // ???
    mainPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.X_AXIS));
    mainPanel.add(preferencePanel);

    // ??????
    JPanel outerPanel = new JPanel();
    outerPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.Y_AXIS));
    outerPanel.add(mainPanel);
    outerPanel.add(ComponentFactory.createSpacer(0, 7));
    outerPanel.add(buttonBar);
    getContentPane().add(outerPanel);

    // ?
    initListener();
    buttonBar.setState(buttonBar.INIT_STATE);

    // 
    ConfigManager config = ConfigManager.getInstance();
    String iconPath = config.getFile("icon.png").toString();
    Image icon = Toolkit.getDefaultToolkit().createImage(iconPath);
    setIconImage(icon);

    // 
    setTitle(SETTING_TITLE);
    Persister psst = Persister.getInstance();
    setLocation(psst.getInt(Persister.WINDOW_X, 0), psst.getInt(Persister.WINDOW_Y, 0));
    setSize(psst.getInt(Persister.WINDOW_WIDTH, 700), psst.getInt(Persister.WINDOW_HEIGHT, 570));
    int state = psst.getInt(Persister.WINDOW_STATE, NORMAL);
    if ((state & Frame.ICONIFIED) != ICONIFIED) {
        setExtendedState(state);
    }
    setVisible(true);
}

From source file:de.atomfrede.tools.evalutation.ui.ExceptionDialog.java

@SuppressWarnings("serial")
@Override// w  w  w  .  j  av a2s  .c om
protected StandardDialogPane createStandardDialogPane() {
    DefaultStandardDialogPane dialogPane = new DefaultStandardDialogPane() {
        @Override
        protected void layoutComponents(Component bannerPanel, Component contentPanel,
                ButtonPanel buttonPanel) {
            setLayout(new JideBoxLayout(this, BoxLayout.Y_AXIS));
            if (bannerPanel != null) {
                add(bannerPanel);
            }
            if (contentPanel != null) {
                add(contentPanel);
            }
            add(buttonPanel, JideBoxLayout.FIX);
            _detailsPanel = createDetailsPanel();
            add(_detailsPanel, JideBoxLayout.VARY);
            _detailsPanel.setVisible(false);
        }
    };
    return dialogPane;
}

From source file:com.stefanbrenner.droplet.ui.DevicePanel.java

/**
 * Create the panel.//from  w  w w.ja  v a  2s  .  co  m
 */
public DevicePanel(final JComponent parent, final IDroplet droplet, final T device) {

    this.parent = parent;

    setDevice(device);

    setLayout(new BorderLayout(0, 5));
    setBorder(BorderFactory.createLineBorder(Color.BLACK));
    setBackground(DropletColors.getBackgroundColor(device));

    BeanAdapter<T> adapter = new BeanAdapter<T>(device, true);

    // device name textfield
    txtName = BasicComponentFactory.createTextField(adapter.getValueModel(IDevice.PROPERTY_NAME));
    txtName.setHorizontalAlignment(SwingConstants.CENTER);
    txtName.setColumns(1);
    txtName.setToolTipText(device.getName());
    adapter.addBeanPropertyChangeListener(IDevice.PROPERTY_NAME, new PropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            txtName.setToolTipText(device.getName());
        }
    });
    add(txtName, BorderLayout.NORTH);

    // actions panel with scroll pane
    actionsPanel = new JPanel();
    actionsPanel.setLayout(new BoxLayout(actionsPanel, BoxLayout.Y_AXIS));
    actionsPanel.setBackground(getBackground());

    JScrollPane scrollPane = new JScrollPane(actionsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    // resize vertical scrollbar
    scrollPane.getVerticalScrollBar().putClientProperty("JComponent.sizeVariant", "mini"); //$NON-NLS-1$ //$NON-NLS-2$
    SwingUtilities.updateComponentTreeUI(scrollPane);
    // we need no border
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    add(scrollPane, BorderLayout.CENTER);

    {
        JPanel panel = new JPanel();
        panel.setLayout(new GridLayout(0, 1));

        createAddButton(panel);

        // remove button
        JButton btnRemove = new JButton(Messages.getString("ActionDevicePanel.removeDevice")); //$NON-NLS-1$
        btnRemove.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent action) {
                int retVal = JOptionPane.showConfirmDialog(DevicePanel.this,
                        Messages.getString("ActionDevicePanel.removeDevice") + " '" + device.getName() + "'?", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                        StringUtils.EMPTY, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (retVal == JOptionPane.YES_OPTION) {
                    droplet.removeDevice(device);
                }
            }
        });
        btnRemove.setFocusable(false);
        panel.add(btnRemove);

        add(panel, BorderLayout.SOUTH);
    }

}