Example usage for javax.swing Box createHorizontalBox

List of usage examples for javax.swing Box createHorizontalBox

Introduction

In this page you can find the example usage for javax.swing Box createHorizontalBox.

Prototype

public static Box createHorizontalBox() 

Source Link

Document

Creates a Box that displays its components from left to right.

Usage

From source file:org.kepler.gui.DialogGeneralTab.java

/**
 * getCenterPanel//from  www  .ja va 2 s. c  o  m
 * 
 * @return Component
 */
protected Component getCenterPanel() {
    Box centerPanel = Box.createHorizontalBox();

    final Border middlePanelPaddingBorder = BorderFactory.createEmptyBorder( // top, left, bottom, right
            StaticResources.getSize("dialogs.tabPanels.padding.top", 0), 0, 0, 0);

    centerPanel.setBorder(middlePanelPaddingBorder);

    JLabel noteLbl = WidgetFactory.makeJLabel(
            StaticResources.getDisplayString("dialogs." + _targetType + ".general.note", "Note"),
            TabbedDialog.jLabelDims);
    centerPanel.add(noteLbl);

    noteTxtArea = WidgetFactory.makeJTextArea(_target != null ? _target.getName() : "");
    JScrollPane scrollPane = new JScrollPane(noteTxtArea);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(scrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setWheelScrollingEnabled(true);
    centerPanel.add(scrollPane);

    return centerPanel;
}

From source file:org.rdv.datapanel.DigitalTabularDataPanel.java

/**
 * Initialize the container and add the header.
 * /* ww  w  .j a va 2s.  c o m*/
 * @since 1.2
 */
private void initComponents() {
    mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());

    panelBox = Box.createHorizontalBox();

    dataCellRenderer = new DataTableCellRenderer();
    doubleCellRenderer = new DoubleTableCellRenderer();

    showMinMaxCheckBoxGroup = new CheckBoxGroup();
    showThresholdCheckBoxGroup = new CheckBoxGroup();

    addColumn();

    mainPanel.add(panelBox, BorderLayout.CENTER);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BorderLayout());

    JPanel offsetsPanel = new JPanel();

    useOffsetsCheckBox = new JCheckBox("Use Offsets");
    useOffsetsCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            boolean checked = ((JCheckBox) ae.getSource()).isSelected();

            useOffsetRenderer(checked);
        }
    });
    offsetsPanel.add(useOffsetsCheckBox);

    JButton takeOffsetsButton = new JButton("Take Offsets");
    takeOffsetsButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            useOffsetsCheckBox.setSelected(true); // this moved from above
            // repaint
            for (int i = 0; i < columnGroupCount; i++) {
                ((DataTableModel) tableModels.get(i)).takeOffsets();
                ((DataTableModel) tableModels.get(i)).useOffsets(true);
                ((JTable) tables.get(i)).repaint();
            } // for
        } // actionPerformed ()
    }); // actionlistener
    offsetsPanel.add(takeOffsetsButton);

    buttonPanel.add(offsetsPanel, BorderLayout.WEST);

    JPanel formatPanel = new JPanel();

    decimalButton = new JToggleButton("Decimal", true);
    decimalButton.setSelected(true);
    decimalButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            useEngineeringRenderer(false);
        }
    });
    formatPanel.add(decimalButton);

    engineeringButton = new JToggleButton("Engineering");
    engineeringButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            useEngineeringRenderer(true);
        }
    });
    formatPanel.add(engineeringButton);

    ButtonGroup formatButtonGroup = new ButtonGroup();
    formatButtonGroup.add(decimalButton);
    formatButtonGroup.add(engineeringButton);

    buttonPanel.add(formatPanel, BorderLayout.EAST);

    mainPanel.add(buttonPanel, BorderLayout.SOUTH);

    mainPanel.addMouseListener(new MouseInputAdapter() {
    });

}

From source file:org.stanwood.swing.AboutDialog.java

public void init() {
    Box box = Box.createVerticalBox();
    if (icon == null) {
        createTitleArea(box, title, version);
    } else {/*from   www.j av  a 2  s  .  c om*/
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(40));
        hbox.add(new JLabel(icon));
        hbox.add(Box.createHorizontalStrut(10));
        box.add(hbox);
        Box vbox = Box.createVerticalBox();
        createTitleArea(vbox, title, version);
        hbox.add(vbox);
        hbox.add(Box.createHorizontalGlue());
    }

    JTabbedPane infoTabbedPane = new JTabbedPane();
    infoTabbedPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JComponent tabAbout = createAboutTab();
    infoTabbedPane.addTab("About", tabAbout);
    JComponent tabAuthors = createAuthorsTab();
    infoTabbedPane.addTab("Authors", tabAuthors);
    box.add(infoTabbedPane);
    createButtonPane(box);

    setContentPane(box);
    setSize(450, 280);
    setLocationRelativeTo(getParent());
}

From source file:org.stanwood.swing.AboutDialog.java

private void createButtonPane(Box box) {
    Box hBox = Box.createHorizontalBox();
    hBox.add(Box.createHorizontalGlue());
    JButton cmdClose = new JButton(StandardActions.getDialogCloseAction(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            cancel();/*from  w  ww .j  a  v  a  2s . c  o  m*/
        }
    }));
    hBox.add(cmdClose);
    box.add(hBox);

    hBox.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5));

    cmdClose.requestFocusInWindow();
}

From source file:pcgen.gui2.dialog.CharacterHPDialog.java

private void initComponents() {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    JTable table = new JTable(tableModel) {

        @Override/*w  w  w. ja va 2  s .c  o  m*/
        public TableCellEditor getCellEditor(int row, int column) {
            if (column == 5) {//TODO: the max roll should be calculated in a different manner
                String hd = levels.getClassTaken(levels.getElementAt(row)).getHD();
                int max = NumberUtils.toInt(hd);
                return new IntegerEditor(1, max);
            } else {
                return super.getCellEditor(row, column);
            }
        }

    };
    table.setDefaultRenderer(JButton.class, new Renderer());
    table.setDefaultEditor(JButton.class, new Editor());
    table.setCellSelectionEnabled(false);
    table.setRowHeight(new IntegerEditor(1, 10).getPreferredSize().height);
    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);

    JScrollPane scrollPane = new JScrollPane(table);
    pane.add(scrollPane, BorderLayout.CENTER);

    Box box = Box.createHorizontalBox();
    box.add(new JLabel("Total Hp:"));
    box.add(Box.createHorizontalStrut(3));

    final ReferenceListener<Integer> hpListener = new ReferenceListener<Integer>() {

        @Override
        public void referenceChanged(ReferenceEvent<Integer> e) {
            totalHp.setText(e.getNewReference().toString());
        }

    };
    ReferenceFacade<Integer> hpRef = character.getTotalHPRef();
    totalHp.setText(hpRef.get().toString());
    hpRef.addReferenceListener(hpListener);
    box.add(totalHp);
    box.add(Box.createHorizontalStrut(5));

    JButton button = new JButton("Reroll All");
    button.setActionCommand("Reroll");
    button.addActionListener(this);
    box.add(button);

    box.add(Box.createHorizontalGlue());
    button = new JButton("Close");
    button.setActionCommand("Close");
    button.addActionListener(this);
    box.add(button);
    pane.add(box, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            //Make sure to remove the listeners so that the garbage collector can
            //dispose of this dialog and prevent a memory leak
            levels.removeHitPointListener(tableModel);
            character.getTotalHPRef().removeReferenceListener(hpListener);
        }

    });

    Utility.installEscapeCloseOperation(this);
}

From source file:pcgen.gui2.dialog.ExportDialog.java

private void initLayout() {
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    Box topPanel = Box.createHorizontalBox();
    topPanel.add(new JLabel("Select Character:"));
    topPanel.add(Box.createHorizontalStrut(5));
    topPanel.add(characterBox);//www  .  j a  v  a 2 s.c o  m
    topPanel.add(Box.createHorizontalStrut(5));
    topPanel.add(partyBox);
    topPanel.add(Box.createHorizontalGlue());
    topPanel.add(Box.createHorizontalStrut(50));
    topPanel.add(new JLabel("Export to:"));
    topPanel.add(Box.createHorizontalStrut(5));
    topPanel.add(exportBox);
    contentPane.add(topPanel, BorderLayout.NORTH);

    JScrollPane scrollPane = new JScrollPane(fileList);
    scrollPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Templates"),
            scrollPane.getBorder()));
    contentPane.add(scrollPane, BorderLayout.CENTER);

    Box bottomPanel = Box.createHorizontalBox();
    bottomPanel.add(progressBar);
    bottomPanel.add(Box.createHorizontalGlue());
    bottomPanel.add(Box.createHorizontalStrut(5));
    bottomPanel.add(exportButton);
    bottomPanel.add(Box.createHorizontalStrut(5));
    bottomPanel.add(closeButton);
    contentPane.add(bottomPanel, BorderLayout.SOUTH);

    topPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    bottomPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    pack();
}

From source file:pcgen.gui2.dialog.PostLevelUpDialog.java

private void initComponents() {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    JTable table = new JTable(tableModel) {

        @Override//  www. ja va2s.  c  o  m
        public TableCellEditor getCellEditor(int row, int column) {
            if (column == LevelTableModel.COL_ROLLED_HP && row < numLevels) {//TODO: the max roll should be calculated in a different manner
                String hd = levels.getClassTaken(levels.getElementAt(row + oldLevel)).getHD();
                int max = NumberUtils.toInt(hd);
                return new SpinnerEditor(new SpinnerNumberModel(1, 1, max, 1));
            }
            return super.getCellEditor(row, column);
        }

        @Override
        public TableCellRenderer getCellRenderer(int row, int column) {
            if (column == LevelTableModel.COL_ROLLED_HP && row < numLevels) {
                return new SpinnerRenderer();
            }
            return super.getCellRenderer(row, column);
        }

    };
    table.setCellSelectionEnabled(false);
    table.setRowHeight(new JSpinner().getPreferredSize().height);
    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);

    JScrollPane scrollPane = new JScrollPane(table);
    pane.add(scrollPane, BorderLayout.CENTER);

    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    JButton button = new JButton(LanguageBundle.getString("in_close")); //$NON-NLS-1$
    button.setMnemonic(LanguageBundle.getMnemonic("in_mn_close")); //$NON-NLS-1$
    button.setActionCommand("Close"); //$NON-NLS-1$
    button.addActionListener(this);
    box.add(button);
    pane.add(box, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            //Make sure to remove the listeners so that the garbage collector can
            //dispose of this dialog and prevent a memory leak
            levels.removeHitPointListener(tableModel);
        }

    });

    Utility.installEscapeCloseOperation(this);
}

From source file:pcgen.gui2.dialog.PrintPreviewDialog.java

private void initLayout() {
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    {//layout top bar
        JPanel bar = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.anchor = GridBagConstraints.BASELINE;
        gbc.insets = new Insets(8, 6, 8, 2);
        bar.add(new JLabel("Select Template:"), gbc);
        gbc.insets = new Insets(8, 2, 8, 6);
        gbc.weightx = 1;/*from  ww  w  .ja v  a 2s.c o  m*/
        bar.add(sheetBox, gbc);
        pane.add(bar, BorderLayout.NORTH);
    }
    {
        Box vbox = Box.createVerticalBox();
        previewPanelParent.setPreferredSize(new Dimension(600, 800));
        vbox.add(previewPanelParent);
        vbox.add(progressBar);
        pane.add(vbox, BorderLayout.CENTER);
    }
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(new JLabel("Page:"));
        hbox.add(Box.createHorizontalStrut(4));
        hbox.add(pageBox);
        hbox.add(Box.createHorizontalStrut(10));
        hbox.add(new JLabel("Zoom:"));
        hbox.add(Box.createHorizontalStrut(4));
        hbox.add(zoomBox);
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(zoomInButton);
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(zoomOutButton);
        hbox.add(Box.createHorizontalGlue());
        hbox.add(printButton);
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(cancelButton);
        hbox.setBorder(BorderFactory.createEmptyBorder(8, 5, 8, 5));
        pane.add(hbox, BorderLayout.SOUTH);
    }
}

From source file:pcgen.gui2.sources.AdvancedSourceSelectionPanel.java

private void initComponents() {
    FlippingSplitPane mainPane = new FlippingSplitPane(JSplitPane.VERTICAL_SPLIT, "advSrcMain");
    FlippingSplitPane topPane = new FlippingSplitPane("advSrcTop");
    topPane.setResizeWeight(0.6);/*www .j  a  v  a2 s.c o  m*/
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(new JLabel(LanguageBundle.getString("in_src_gameLabel")), BorderLayout.WEST); //$NON-NLS-1$

    FacadeComboBoxModel<GameModeDisplayFacade> gameModes = new FacadeComboBoxModel<>();
    gameModes.setListFacade(FacadeFactory.getGameModeDisplays());
    gameModeList.setModel(gameModes);
    gameModeList.addActionListener(this);
    panel.add(gameModeList, BorderLayout.CENTER);

    FilterBar<Object, CampaignFacade> bar = new FilterBar<>(false);
    bar.add(panel, BorderLayout.WEST);
    bar.addDisplayableFilter(new SearchFilterPanel());
    panel = new JPanel(new BorderLayout());
    panel.add(bar, BorderLayout.NORTH);

    availableTable.setDisplayableFilter(bar);
    availableTable.setTreeViewModel(availTreeViewModel);
    availableTable.getSelectionModel().addListSelectionListener(this);
    availableTable.setTreeCellRenderer(new CampaignRenderer());
    ((DynamicTableColumnModel) availableTable.getColumnModel()).getAvailableColumns().get(2)
            .setCellRenderer(new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));

    JScrollPane pane = new JScrollPane(availableTable);
    pane.setPreferredSize(new Dimension(600, 310));
    panel.add(pane, BorderLayout.CENTER);

    Box box = Box.createHorizontalBox();
    unloadAllButton.setAction(new UnloadAllAction());
    box.add(unloadAllButton);
    box.add(Box.createHorizontalGlue());
    addButton.setHorizontalTextPosition(SwingConstants.LEADING);
    addButton.setAction(new AddAction());
    box.add(addButton);
    box.add(Box.createHorizontalStrut(5));
    box.setBorder(new EmptyBorder(0, 0, 5, 0));
    panel.add(box, BorderLayout.SOUTH);

    topPane.setLeftComponent(panel);

    JPanel selPanel = new JPanel(new BorderLayout());
    FilterBar<Object, CampaignFacade> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    selectedTable.setDisplayableFilter(filterBar);

    selectedTable.setTreeViewModel(selTreeViewModel);
    selectedTable.getSelectionModel().addListSelectionListener(this);
    selectedTable.setTreeCellRenderer(new CampaignRenderer());
    ((DynamicTableColumnModel) selectedTable.getColumnModel()).getAvailableColumns().get(2)
            .setCellRenderer(new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
    JScrollPane scrollPane = new JScrollPane(selectedTable);
    scrollPane.setPreferredSize(new Dimension(300, 350));
    selPanel.add(scrollPane, BorderLayout.CENTER);
    box = Box.createHorizontalBox();
    box.add(Box.createHorizontalStrut(5));
    removeButton.setAction(new RemoveAction());
    box.add(removeButton);
    box.add(Box.createHorizontalGlue());
    box.setBorder(new EmptyBorder(0, 0, 5, 0));
    selPanel.add(box, BorderLayout.SOUTH);

    topPane.setRightComponent(selPanel);
    mainPane.setTopComponent(topPane);

    linkAction.install();
    infoPane.setPreferredSize(new Dimension(800, 150));
    mainPane.setBottomComponent(infoPane);
    mainPane.setResizeWeight(0.7);
    setLayout(new BorderLayout());
    add(mainPane, BorderLayout.CENTER);
}

From source file:pcgen.gui2.tabs.bio.BiographyInfoPane.java

private void initComponents() {
    setLayout(new GridBagLayout());
    Box vbox = Box.createVerticalBox();

    allButton.setText(LanguageBundle.getString("in_all")); //$NON-NLS-1$
    allButton.setActionCommand(ALL_COMMAND);
    noneButton.setText(LanguageBundle.getString("in_none")); //$NON-NLS-1$
    noneButton.setActionCommand(NONE_COMMAND);

    Box hbox = Box.createHorizontalBox();
    hbox.add(new JLabel(LanguageBundle.getString("in_descCheckItem"))); //$NON-NLS-1$
    hbox.add(Box.createRigidArea(new Dimension(5, 0)));
    hbox.add(allButton);//from www.  j av a2s .com
    hbox.add(Box.createRigidArea(new Dimension(3, 0)));
    hbox.add(noneButton);
    vbox.add(hbox);

    itemsPanel.setLayout(new GridBagLayout());
    itemsPanel.setBorder(new EmptyBorder(8, 5, 8, 5));

    vbox.add(Box.createVerticalStrut(10));
    detailsScroll = new JScrollPane(itemsPanel);
    detailsScroll.setPreferredSize(detailsScroll.getMaximumSize());
    detailsScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    detailsScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    detailsScroll.setMinimumSize(new Dimension(600, 0));
    vbox.add(detailsScroll);
    vbox.add(Box.createVerticalStrut(10));

    hbox = Box.createHorizontalBox();
    hbox.add(Box.createHorizontalGlue());
    addCustomItemButton = new JButton();
    hbox.add(addCustomItemButton);
    hbox.add(Box.createHorizontalGlue());
    vbox.add(hbox);
    vbox.add(Box.createVerticalGlue());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.weightx = 1;
    gbc.fill = GridBagConstraints.VERTICAL;
    gbc.weighty = 1;
    gbc.insets = new Insets(5, 5, 5, 5);
    add(vbox, gbc);
}