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:com.diversityarrays.util.DatePickerDialog.java

public DatePickerDialog(Window owner, String title, Closure<Date> onComplete) {
    super(owner, title, ModalityType.APPLICATION_MODAL);

    this.onComplete = onComplete;

    datePicker.getMonthView().setZoomable(true);
    datePicker.setLinkPanel(null);/*  ww  w.j a v a  2s . c  o m*/
    datePicker.setFormats(getDefaultDateFormats());

    Box buttons = Box.createHorizontalBox();
    buttons.add(Box.createHorizontalStrut(10));
    buttons.add(new JButton(cancel));
    buttons.add(Box.createHorizontalStrut(10));
    buttons.add(new JButton(save));
    buttons.add(Box.createHorizontalGlue());

    Container cp = getContentPane();
    cp.add(datePicker.getMonthView(), BorderLayout.CENTER);
    cp.add(buttons, BorderLayout.SOUTH);

    pack();
}

From source file:net.sf.jhylafax.AbstractFaxDialog.java

protected void addNumberTextField() {
    Box box = Box.createHorizontalBox();

    addressBookAction = new AddressBookAction();

    numberTextField = new JTextField();
    numberTextField.setMaximumSize(new Dimension(Integer.MAX_VALUE, numberTextField.getPreferredSize().height));
    numberTextField.setTransferHandler(new ContactTransferHandler());
    //numberTextField.setDragEnabled(true);
    box.add(numberTextField);//from  w  ww. ja  v a  2  s .  com
    box.add(Box.createHorizontalStrut(4));
    box.add(Builder.createIconButton(addressBookAction));
    numberLabel = builder.append("", box, 4);
    builder.nextLine();

    numberCompletionModel = new DefaultCompletionModel();
    numberCompletion = Builder.addCompletion(numberTextField, numberCompletionModel);

    new CompletionSettingDirector(Settings.backstore, "number").restore(numberCompletion);
}

From source file:org.jdal.swing.table.TablePanel.java

/**
 * Creates a new Component that holds the ReportListView
 * @return ReportListView Component/*from ww w  . ja va 2s. co  m*/
 */
@SuppressWarnings("unused")
private Component createReportListBox() {
    Box tableBox = Box.createHorizontalBox();
    tableBox.add(reportListView.getPanel());
    reportListView.setReportProvider(this);
    return tableBox;
}

From source file:com.diversityarrays.kdxplore.design.SheetChooserPanel.java

public SheetChooserPanel(BackgroundRunner br, Consumer<String> onSheetChosen /*, Component ... more */) {
    super(new BorderLayout());

    this.backgroundRunner = br;
    this.onChoice = onSheetChosen;
    sheetComboBox.addActionListener(new ActionListener() {
        @Override/*ww w .  j  a v  a 2 s . co  m*/
        public void actionPerformed(ActionEvent e) {
            Object item = sheetComboBox.getSelectedItem();
            if (item == null) {
                selectedSheetName = null;
            } else {
                selectedSheetName = sheetComboBox.getSelectedItem().toString();
            }
            updateUsingSelected();
        }
    });
    spinnerModel.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            updateUsingSelected();
        }
    });

    GuiUtil.setVisibleRowCount(dataPreviewTable, DEFAULT_VISIBLE_ROWCOUNT);

    Box top = Box.createHorizontalBox();
    top.add(new JLabel("Select Sheet: "));
    top.add(sheetComboBox);
    top.add(Box.createHorizontalGlue());
    top.add(new JLabel("Preview:"));
    top.add(new JSpinner(spinnerModel));
    top.add(Box.createHorizontalGlue());
    top.add(new JButton(useAction));
    //        if (more != null) {
    //            for (Component c : more) {
    //                top.add(c);
    //            }
    //        }

    add(top, BorderLayout.NORTH);
    add(dataPreviewScrollPane, BorderLayout.CENTER);

    useAction.setEnabled(false);
}

From source file:org.cytoscape.dyn.internal.graphMetrics.SaveChartDialog.java

public SaveChartDialog(JFrame frame, JFreeChart chart) {
    super(frame, "Save Chart to File", false);
    this.chart = chart;
    JPanel sizePanel = new JPanel(new GridLayout(2, 3, 4, 4));
    sizePanel.setBorder(BorderFactory.createTitledBorder("Image Size"));

    // Add a spinner for choosing width
    sizePanel.add(new JLabel("Width:", SwingConstants.RIGHT));
    int width = ChartPanel.DEFAULT_WIDTH;
    int minWidth = ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH;
    int maxWidth = ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH;
    SpinnerModel widthSettings = new SpinnerNumberModel(width, minWidth, maxWidth, 1);
    sizePanel.add(widthSpinner = new JSpinner(widthSettings));
    sizePanel.add(new JLabel("pixels"));

    // Add a spinner for choosing height
    sizePanel.add(new JLabel("Height:", SwingConstants.RIGHT));
    int height = ChartPanel.DEFAULT_HEIGHT;
    int minHeight = ChartPanel.DEFAULT_MINIMUM_DRAW_HEIGHT;
    int maxHeight = ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT;
    SpinnerModel heightSettings = new SpinnerNumberModel(height, minHeight, maxHeight, 1);
    sizePanel.add(heightSpinner = new JSpinner(heightSettings));
    sizePanel.add(new JLabel("pixels"));

    JPanel buttonsPanel = new JPanel(new GridLayout(1, 2, 4, 0));
    saveChartButton = new JButton("Save");
    saveChartButton.setMaximumSize(new Dimension(Short.MAX_VALUE, saveChartButton.getHeight()));
    saveChartButton.addActionListener(this);
    cancelButton = new JButton("Cancel");
    cancelButton.setMaximumSize(new Dimension(Short.MAX_VALUE, cancelButton.getHeight()));
    cancelButton.addActionListener(this);
    buttonsPanel.add(saveChartButton);/*from   www .j a  v  a2 s . c o m*/
    buttonsPanel.add(cancelButton);
    Box buttonsBox = Box.createHorizontalBox();
    buttonsBox.add(Box.createHorizontalGlue());
    buttonsBox.add(buttonsPanel);
    buttonsBox.add(Box.createHorizontalGlue());

    Container contentPane = getContentPane();
    contentPane.add(sizePanel, BorderLayout.NORTH);
    contentPane.add(Box.createVerticalStrut(3));
    contentPane.add(buttonsBox, BorderLayout.PAGE_END);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    getRootPane().setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
    pack();
    setModal(true);
    setResizable(false);
    setLocationRelativeTo(frame);

}

From source file:org.jdal.swing.TableEditor.java

/**
 * Creates a new Box with table and actions buttons
 * @return a new Box/*ww  w. ja  v  a2  s  . co  m*/
 */
protected Container createTablePanel() {
    table = new JTable(tableModel, tableModel.getTableColumnModel());
    table.setRowHeight(22);
    table.setAutoCreateRowSorter(true);
    tableModel.addTableModelListener(this);
    JScrollPane scroll = new JScrollPane(table);
    scroll.setAlignmentX(Container.LEFT_ALIGNMENT);
    Box box = Box.createVerticalBox();
    JButton addButton = new JButton(new AddAction());
    JButton deleteButton = new JButton(new DeleteAction());
    JButton saveButton = new JButton(new SaveAction());
    JButton refreshButton = new JButton(new RefreshAction());
    Box buttonBox = Box.createHorizontalBox();
    buttonBox.add(addButton);
    buttonBox.add(Box.createHorizontalStrut(5));
    buttonBox.add(deleteButton);
    buttonBox.add(Box.createHorizontalStrut(5));
    buttonBox.add(saveButton);
    buttonBox.add(Box.createHorizontalStrut(5));
    buttonBox.add(refreshButton);
    buttonBox.setAlignmentX(Container.LEFT_ALIGNMENT);
    buttonBox.setMaximumSize(new Dimension(Short.MAX_VALUE, 25));
    box.add(buttonBox);
    box.add(Box.createVerticalStrut(5));
    box.add(scroll);
    return box;
}

From source file:common.AbstractGUI.java

protected void createLogPanel() {
    logPanel = new JPanel();
    logPanel.setLayout(new BoxLayout(logPanel, BoxLayout.Y_AXIS));

    logTextArea = new JTextArea(33, 30);
    logTextArea.setEditable(false);// w ww  .java  2s  .  c o m
    logTextArea.setAutoscrolls(true);
    logTextArea.setFont(new Font("Courier New", Font.PLAIN, 11));
    logTextArea.setBackground(Color.DARK_GRAY);
    logTextArea.setForeground(Color.GREEN);
    logTextArea.addMouseListener(logTextAreaMouseListener);

    scrollPane = new JScrollPane(logTextArea);

    Box horizontalLayout = Box.createHorizontalBox();
    filterTxt = new JTextField();
    filterBtn = new JButton("Filter");
    filterBtn.addActionListener(filterActionListner);
    filterTxt.setMaximumSize(new Dimension(250, 30));
    horizontalLayout.add(filterTxt);
    horizontalLayout.add(filterBtn);
    logPanel.add(horizontalLayout);
    logPanel.add(scrollPane);
    tabbedPane.addTab("Log", logPanel);
}

From source file:net.sf.vfsjfilechooser.accessories.bookmarks.BookmarksManagerPanel.java

public BookmarksManagerPanel(BookmarksDialog parentDialog, VFSJFileChooser chooser) {
    this.parentDialog = parentDialog;
    this.chooser = chooser;

    model = new Bookmarks();

    table = new JTable(model);
    scrollPane = new JScrollPane(table);

    table.setPreferredScrollableViewportSize(tableSize);
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    bCancel = new JButton(VFSResources.getMessage("VFSJFileChooser.closeButtonText"));

    bOpen = new JButton(VFSResources.getMessage("VFSJFileChooser.openButtonText"));
    bOpen.setIcon(/*  www  .  ja  v  a2s.  c om*/
            new ImageIcon(getClass().getResource("/net/sf/vfsjfilechooser/plaf/icons/document-open.png")));
    bOpen.setHorizontalAlignment(SwingConstants.LEFT);

    bAdd = new JButton(VFSResources.getMessage("VFSJFileChooser.addButtonText"));
    bAdd.setIcon(new ImageIcon(getClass().getResource("/net/sf/vfsjfilechooser/plaf/icons/list-add.png")));
    bAdd.setHorizontalAlignment(SwingConstants.LEFT);

    bEdit = new JButton(VFSResources.getMessage("VFSJFileChooser.editButtonText"));
    bEdit.setIcon(new ImageIcon(getClass().getResource("/net/sf/vfsjfilechooser/plaf/icons/book_edit.png")));
    bEdit.setHorizontalAlignment(SwingConstants.LEFT);

    bDelete = new JButton(VFSResources.getMessage("VFSJFileChooser.deleteButtonText"));
    bDelete.setIcon(
            new ImageIcon(getClass().getResource("/net/sf/vfsjfilechooser/plaf/icons/list-remove.png")));
    bDelete.setHorizontalAlignment(SwingConstants.LEFT);

    bMoveUp = new JButton(VFSResources.getMessage("VFSJFileChooser.moveUpButtonText"));
    bMoveUp.setIcon(new ImageIcon(getClass().getResource("/net/sf/vfsjfilechooser/plaf/icons/go-up.png")));
    bMoveUp.setHorizontalAlignment(SwingConstants.LEFT);

    bMoveDown = new JButton(VFSResources.getMessage("VFSJFileChooser.moveDownButtonText"));
    bMoveDown.setIcon(new ImageIcon(getClass().getResource("/net/sf/vfsjfilechooser/plaf/icons/go-down.png")));
    bMoveDown.setHorizontalAlignment(SwingConstants.LEFT);

    final ActionHandler ah = new ActionHandler();

    bOpen.addActionListener(ah);
    bCancel.addActionListener(ah);
    bEdit.addActionListener(ah);
    bAdd.addActionListener(ah);
    bDelete.addActionListener(ah);
    bMoveUp.addActionListener(ah);
    bMoveDown.addActionListener(ah);

    final Box south = Box.createHorizontalBox();
    south.add(Box.createHorizontalGlue());
    south.add(bCancel);
    south.add(Box.createHorizontalGlue());

    final JPanel buttons = new JPanel(new GridLayout(0, 1, 5, 5));

    buttons.add(bAdd);
    buttons.add(bEdit);
    buttons.add(bDelete);
    buttons.add(bOpen);
    buttons.add(Box.createVerticalStrut(10));
    buttons.add(bMoveUp);
    buttons.add(bMoveDown);

    JPanel east = new JPanel();
    east.add(buttons, BorderLayout.NORTH);
    east.add(new JPanel(), BorderLayout.CENTER); // don't ask

    setLayout(new BorderLayout(10, 10));

    add(scrollPane, BorderLayout.CENTER);
    add(south, BorderLayout.SOUTH);
    add(east, BorderLayout.EAST);

    setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, UIManager.getColor("Panel.background")));
}

From source file:com.googlecode.vfsjfilechooser2.accessories.bookmarks.BookmarksManagerPanel.java

public BookmarksManagerPanel(BookmarksDialog parentDialog, VFSJFileChooser chooser) {
    this.parentDialog = parentDialog;
    this.chooser = chooser;

    model = new Bookmarks();

    table = new JTable(model);
    scrollPane = new JScrollPane(table);

    table.setPreferredScrollableViewportSize(tableSize);
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    bCancel = new JButton(VFSResources.getMessage("VFSJFileChooser.closeButtonText"));

    bOpen = new JButton(VFSResources.getMessage("VFSJFileChooser.openButtonText"));
    bOpen.setIcon(new ImageIcon(
            getClass().getResource("/com/googlecode/vfsjfilechooser2/plaf/icons/document-open.png")));
    bOpen.setHorizontalAlignment(SwingConstants.LEFT);

    bAdd = new JButton(VFSResources.getMessage("VFSJFileChooser.addButtonText"));
    bAdd.setIcon(/*from  w ww .j a va 2s .c  o  m*/
            new ImageIcon(getClass().getResource("/com/googlecode/vfsjfilechooser2/plaf/icons/list-add.png")));
    bAdd.setHorizontalAlignment(SwingConstants.LEFT);

    bEdit = new JButton(VFSResources.getMessage("VFSJFileChooser.editButtonText"));
    bEdit.setIcon(
            new ImageIcon(getClass().getResource("/com/googlecode/vfsjfilechooser2/plaf/icons/book_edit.png")));
    bEdit.setHorizontalAlignment(SwingConstants.LEFT);

    bDelete = new JButton(VFSResources.getMessage("VFSJFileChooser.deleteButtonText"));
    bDelete.setIcon(new ImageIcon(
            getClass().getResource("/com/googlecode/vfsjfilechooser2/plaf/icons/list-remove.png")));
    bDelete.setHorizontalAlignment(SwingConstants.LEFT);

    bMoveUp = new JButton(VFSResources.getMessage("VFSJFileChooser.moveUpButtonText"));
    bMoveUp.setIcon(
            new ImageIcon(getClass().getResource("/com/googlecode/vfsjfilechooser2/plaf/icons/go-up.png")));
    bMoveUp.setHorizontalAlignment(SwingConstants.LEFT);

    bMoveDown = new JButton(VFSResources.getMessage("VFSJFileChooser.moveDownButtonText"));
    bMoveDown.setIcon(
            new ImageIcon(getClass().getResource("/com/googlecode/vfsjfilechooser2/plaf/icons/go-down.png")));
    bMoveDown.setHorizontalAlignment(SwingConstants.LEFT);

    final ActionHandler ah = new ActionHandler();

    bOpen.addActionListener(ah);
    bCancel.addActionListener(ah);
    bEdit.addActionListener(ah);
    bAdd.addActionListener(ah);
    bDelete.addActionListener(ah);
    bMoveUp.addActionListener(ah);
    bMoveDown.addActionListener(ah);

    final Box south = Box.createHorizontalBox();
    south.add(Box.createHorizontalGlue());
    south.add(bCancel);
    south.add(Box.createHorizontalGlue());

    final JPanel buttons = new JPanel(new GridLayout(0, 1, 5, 5));

    buttons.add(bAdd);
    buttons.add(bEdit);
    buttons.add(bDelete);
    buttons.add(bOpen);
    buttons.add(Box.createVerticalStrut(10));
    buttons.add(bMoveUp);
    buttons.add(bMoveDown);

    JPanel east = new JPanel();
    east.add(buttons, BorderLayout.NORTH);
    east.add(new JPanel(), BorderLayout.CENTER); // don't ask

    setLayout(new BorderLayout(10, 10));

    add(scrollPane, BorderLayout.CENTER);
    add(south, BorderLayout.SOUTH);
    add(east, BorderLayout.EAST);

    setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, UIManager.getColor("Panel.background")));
}

From source file:org.jdal.swing.table.TablePanel.java

/**
 * Create the control button Box from action list.
 * @return Box with buttons from actions
 *///from   ww w .  ja  v  a2 s  .  c om
protected Box createControlBox() {
    controlBox = Box.createHorizontalBox();
    populateControlBox();

    return controlBox;
}