Example usage for javax.swing Box createHorizontalGlue

List of usage examples for javax.swing Box createHorizontalGlue

Introduction

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

Prototype

public static Component createHorizontalGlue() 

Source Link

Document

Creates a horizontal glue component.

Usage

From source file:com.diversityarrays.kdxplore.field.CollectionPathSetupDialog.java

public CollectionPathSetupDialog(Window owner, String title, boolean wantPlotsPerGroup) {
    super(owner, title, ModalityType.APPLICATION_MODAL);

    Box buttons = Box.createHorizontalBox();
    buttons.add(Box.createHorizontalGlue());
    buttons.add(new JButton(cancelAction));
    buttons.add(new JButton(useAction));

    Container cp = getContentPane();
    if (wantPlotsPerGroup) {
        plotsPerGroupChoice.addItemListener(new ItemListener() {
            @Override/*from  w w  w  . ja  v  a 2  s  .  com*/
            public void itemStateChanged(ItemEvent e) {
                plotsPerGroup = (PlotsPerGroup) plotsPerGroupChoice.getSelectedItem();
            }
        });

        JPanel ppgPanel = new JPanel();
        GBH gbh = new GBH(ppgPanel);
        int y = 0;
        gbh.add(0, y, 1, 1, GBH.NONE, 1, 1, GBH.EAST, "Plots Per Group:");
        gbh.add(1, y, 1, 1, GBH.HORZ, 1, 1, GBH.WEST, plotsPerGroupChoice);
        ++y;
        cp.add(ppgPanel, BorderLayout.NORTH);
    }

    cp.add(odtChoicePanel, BorderLayout.CENTER);
    cp.add(buttons, BorderLayout.SOUTH);

    pack();
}

From source file:be.fedict.eid.tsl.tool.TslTool.java

private void initMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    initFileMenu(menuBar);//from   www . j ava2 s  . c  om
    menuBar.add(Box.createHorizontalGlue());
    initHelpMenu(menuBar);
    this.setJMenuBar(menuBar);
}

From source file:com.diversityarrays.kdxplore.field.CollectionPathPanel.java

public CollectionPathPanel(boolean wantPlotsPerGroup, BiConsumer<VisitOrder2D, PlotsPerGroup> onChoiceChanged,
        List<? extends OrOrTr> onlyThese) {
    super(new BorderLayout());

    plotsPerGroupChoice.setSelectedItem(plotsPerGroup);
    odtChoicePanel.setOrOrTr(visitOrder);

    this.onChoiceChanged = onChoiceChanged;

    if (wantPlotsPerGroup) {
        plotsPerGroupChoice.addItemListener(new ItemListener() {
            @Override//from   ww w  .  j  av  a 2 s .  com
            public void itemStateChanged(ItemEvent e) {
                plotsPerGroup = (PlotsPerGroup) plotsPerGroupChoice.getSelectedItem();
                onChoiceChanged.accept(visitOrder, plotsPerGroup);
            }
        });

        Box top = Box.createHorizontalBox();
        top.add(new JLabel("Plots Per Group:"));
        top.add(plotsPerGroupChoice);
        top.add(Box.createHorizontalGlue());

        add(top, BorderLayout.NORTH);
    }

    if (!Check.isEmpty(onlyThese)) {
        OrOrTr first = onlyThese.get(0);

        odtChoicePanel.setOnlyAllow(onlyThese.toArray(new OrOrTr[onlyThese.size()]));

        String msg;
        if (onlyThese.size() == 1) {
            msg = "<HTML>For now, only supporting:<BR>" + onlyThese.get(0).toString();
        } else {
            msg = onlyThese.stream().map(oot -> oot.toString())
                    .collect(Collectors.joining("<BR>", "<HTML>For now, only supporting:<BR>", ""));
        }

        JLabel label = new JLabel(msg, JLabel.CENTER);
        label.setForeground(Color.RED);
        add(label, BorderLayout.SOUTH);
    }

    add(odtChoicePanel, BorderLayout.CENTER);
}

From source file:medsavant.uhn.cancer.SetCommentStatusDialog.java

private JPanel getMainPanel() {
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

    //Status box.
    mainPanel.add(getStatusEditorPanel());

    //Comment box.
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
    p.add(Box.createHorizontalGlue());
    comment = new JTextArea();
    p.add(comment);//from   ww w  .  ja  v a  2  s  .co  m
    p.add(Box.createHorizontalGlue());
    mainPanel.add(p);

    //Button box.        
    p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
    p.add(Box.createHorizontalGlue());
    JButton OKButton = new JButton("Update status");
    OKButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                updateStatus();
                dispose();
            } catch (Exception ex) {
                LOG.error(ex.getMessage(), ex);
                DialogUtils.displayException("Error", ex.getMessage(), ex);
            }
        }
    });

    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
    p.add(OKButton);
    p.add(cancelButton);
    p.add(Box.createHorizontalGlue());
    mainPanel.add(p);

    return mainPanel;
}

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);//from w ww  .  ja va 2  s.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:org.ut.biolab.medsavant.client.query.view.NumberSearchConditionEditorView.java

@Override
public void loadViewFromSearchConditionParameters(String encoding) throws ConditionRestorationException {

    double[] selectedValues;
    if (encoding == null) {
        selectedValues = null;//from   www  .ja  v a 2  s.c  om
    } else {
        selectedValues = NumericConditionEncoder.unencodeConditions(encoding);
    }

    final double[] extremeValues = generator.getExtremeNumericValues();
    this.removeAll();

    if (extremeValues == null || (extremeValues[0] == 0 && extremeValues[1] == 0)) {
        JPanel p = new JPanel();
        p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
        p.add(Box.createHorizontalGlue());
        p.add(new JLabel("<html>All values are blank for this condition.</html>"));
        p.add(Box.createHorizontalGlue());
        this.add(p);
        return;
    }

    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    JPanel p = ViewUtil.getClearPanel();
    ViewUtil.applyVerticalBoxLayout(p);

    JPanel labelPanel = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(labelPanel);
    labelPanel.add(Box.createHorizontalGlue());
    labelPanel.add(new JLabel("Filtering variants where " + item.getName() + ": "));
    labelPanel.add(Box.createHorizontalGlue());
    ButtonGroup group = new ButtonGroup();
    //JRadioButton isButton = new JRadioButton("is within the following range:");
    //JRadioButton nullButton = new JRadioButton("is missing");
    //group.add(isButton);
    //group.add(nullButton);

    final JCheckBox nullButton = new JCheckBox("include missing values");

    JPanel bp = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(bp);
    p.add(labelPanel);
    p.add(bp);
    add(p);
    final DecimalRangeSlider slider = new DecimalRangeSlider();

    slider.setMajorTickSpacing(5);
    slider.setMinorTickSpacing(1);

    final JTextField fromBox = new JTextField();
    final JTextField toBox = new JTextField();

    nullButton.setSelected(NumericConditionEncoder.encodesNull(encoding));

    nullButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            encodeValue(ViewUtil.parseDoubleFromFormattedString(fromBox.getText()),
                    ViewUtil.parseDoubleFromFormattedString(toBox.getText()), extremeValues[0],
                    extremeValues[1], nullButton.isSelected());
        }
    });

    fromBox.setMaximumSize(new Dimension(10000, 24));
    toBox.setMaximumSize(new Dimension(10000, 24));
    fromBox.setPreferredSize(new Dimension(FROM_TO_WIDTH, 24));
    toBox.setPreferredSize(new Dimension(FROM_TO_WIDTH, 24));
    fromBox.setMinimumSize(new Dimension(FROM_TO_WIDTH, 24));
    toBox.setMinimumSize(new Dimension(FROM_TO_WIDTH, 24));
    fromBox.setHorizontalAlignment(JTextField.RIGHT);
    toBox.setHorizontalAlignment(JTextField.RIGHT);

    final JLabel fromLabel = new JLabel();
    final JLabel toLabel = new JLabel();

    ViewUtil.makeMini(fromLabel);
    ViewUtil.makeMini(toLabel);

    JPanel fromToContainer = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(fromToContainer);
    fromToContainer.add(Box.createHorizontalGlue());
    fromToContainer.add(fromBox);
    fromToContainer.add(new JLabel(" - "));
    fromToContainer.add(toBox);
    fromToContainer.add(Box.createHorizontalGlue());

    JPanel minMaxContainer = ViewUtil.getClearPanel();
    minMaxContainer.setLayout(new BoxLayout(minMaxContainer, BoxLayout.X_AXIS));

    JPanel sliderContainer = ViewUtil.getClearPanel();
    sliderContainer.setLayout(new BoxLayout(sliderContainer, BoxLayout.Y_AXIS));
    sliderContainer.add(slider);

    JPanel nullValueContainer = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(nullValueContainer);
    nullValueContainer.add(Box.createHorizontalGlue());
    nullValueContainer.add(nullButton);
    nullButton.setBackground(nullValueContainer.getBackground()); //fixes a windows issue.
    nullValueContainer.add(Box.createHorizontalGlue());

    JPanel labelContainer = ViewUtil.getClearPanel();
    labelContainer.setLayout(new BoxLayout(labelContainer, BoxLayout.X_AXIS));
    labelContainer.add(fromLabel);
    labelContainer.add(Box.createHorizontalGlue());
    labelContainer.add(toLabel);
    sliderContainer.add(labelContainer);
    minMaxContainer.add(Box.createHorizontalGlue());
    minMaxContainer.add(sliderContainer);
    minMaxContainer.add(Box.createHorizontalGlue());

    add(fromToContainer);
    add(minMaxContainer);
    add(nullValueContainer);
    add(Box.createVerticalBox());

    slider.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            if (slider.isEnabled()) {
                fromBox.setText(ViewUtil.numToString(slider.getLow()));
                toBox.setText(ViewUtil.numToString(slider.getHigh()));
                encodeValue(ViewUtil.parseDoubleFromFormattedString(fromBox.getText()),
                        ViewUtil.parseDoubleFromFormattedString(toBox.getText()), extremeValues[0],
                        extremeValues[1], nullButton.isSelected());
            }
        }
    });

    final KeyListener keyListener = new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            int key = e.getKeyCode();
            if (key == KeyEvent.VK_ENTER) {
                Range selectedRage = new Range(getNumber(fromBox.getText()), getNumber(toBox.getText()));
                setSelectedValues(slider, fromBox, toBox, selectedRage);
            }
        }

        private double getNumber(String s) {
            try {
                return Double.parseDouble(s.replaceAll(",", ""));
            } catch (NumberFormatException ignored) {
                return 0;
            }
        }
    };

    CaretListener caretListener = new CaretListener() {
        @Override
        public void caretUpdate(CaretEvent ce) {
            if (!isAdjustingSlider) {
                try {
                    encodeValue(ViewUtil.parseDoubleFromFormattedString(fromBox.getText()),
                            ViewUtil.parseDoubleFromFormattedString(toBox.getText()), extremeValues[0],
                            extremeValues[1], nullButton.isSelected());
                } catch (Exception e) {
                }
            }
        }
    };

    fromBox.addKeyListener(keyListener);

    toBox.addKeyListener(keyListener);

    fromBox.addCaretListener(caretListener);

    toBox.addCaretListener(caretListener);

    slider.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            isAdjustingSlider = true;
            fromBox.setText(ViewUtil.numToString(slider.getLow()));
            toBox.setText(ViewUtil.numToString(slider.getHigh()));
            isAdjustingSlider = false;
        }
    });

    JPanel bottomContainer = new JPanel();

    bottomContainer.setLayout(new BoxLayout(bottomContainer, BoxLayout.X_AXIS));

    bottomContainer.add(Box.createHorizontalGlue());

    add(bottomContainer);

    setExtremeValues(slider, fromLabel, toLabel, fromBox, toBox, 0,
            new Range(extremeValues[0], extremeValues[1]));

    if (encoding != null) {
        double[] d = NumericConditionEncoder.unencodeConditions(encoding);
        setSelectedValues(slider, fromBox, toBox, new Range(d[0], d[1]));
    }
}

From source file:org.ut.biolab.medsavant.client.view.util.PeekingPanel.java

public PeekingPanel(String label, String borderLayoutPosition, JComponent panel, boolean isExpanded, int size) {

    final boolean isVertical = borderLayoutPosition.equals(BorderLayout.EAST)
            || borderLayoutPosition.equals(BorderLayout.WEST);

    this.setAnimated(false);

    if (borderLayoutPosition.equals(BorderLayout.NORTH)) {
        dockedSide = DockedSide.NORTH;//  w ww  .  j a v a 2  s.  com
        this.setDirection(JXCollapsiblePane.Direction.UP);
    } else if (borderLayoutPosition.equals(BorderLayout.SOUTH)) {
        dockedSide = DockedSide.SOUTH;
        this.setDirection(JXCollapsiblePane.Direction.DOWN);
    } else if (borderLayoutPosition.equals(BorderLayout.EAST)) {
        dockedSide = DockedSide.EAST;
        this.setDirection(JXCollapsiblePane.Direction.RIGHT);
    } else {
        dockedSide = DockedSide.WEST;
        this.setDirection(JXCollapsiblePane.Direction.LEFT);
    }

    this.setLayout(new BorderLayout());
    this.panel = panel;

    if (isVertical) {
        panel.setPreferredSize(new Dimension(size, 999));
    } else {
        panel.setPreferredSize(new Dimension(999, size));
    }
    titlePanel = new JPanel();

    titlePanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    titlePanel.setBorder(ViewUtil.getTinyBorder());
    if (isVertical) {
        titlePanel.setLayout(new BoxLayout(titlePanel, BoxLayout.Y_AXIS));
    } else {
        titlePanel.setLayout(new BoxLayout(titlePanel, BoxLayout.X_AXIS));
    }
    titlePanel.add(Box.createHorizontalGlue());

    this.titleString = label.toUpperCase();
    title = new JLabel(" ");//titleString);

    title.setForeground(Color.darkGray);
    if (borderLayoutPosition.equals(BorderLayout.EAST)) {
        title.setUI(new VerticalLabelUI(true));
    } else if (borderLayoutPosition.equals(BorderLayout.WEST)) {
        title.setUI(new VerticalLabelUI(false));
    }
    titlePanel.add(title);

    if (!isVertical) {
        titlePanel.add(Box.createHorizontalGlue());
    }

    titlePanel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            toggleExpanded();
        }
    });

    this.add(titlePanel, borderLayoutPosition);
    this.add(panel, BorderLayout.CENTER);

    setExpanded(isExpanded);
}

From source file:com.apatar.ui.JHelpDialog.java

private void createDialog() {
    setLayout(new BorderLayout(5, 5));
    setSize(500, 500);// w w w  . j  a  v  a2  s. c  o m
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(Box.createHorizontalGlue());
    buttonPanel.add(sendButton);

    getContentPane().add(text, BorderLayout.CENTER);
    getContentPane().add(buttonPanel, BorderLayout.SOUTH);
}

From source file:com.idealista.solrmeter.view.statistic.OperationTimeLineChartPanel.java

private Component createCheckBoxPanel() {
    JPanel panelCheckBox = new JPanel();
    panelCheckBox.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panelCheckBox.setLayout(new BoxLayout(panelCheckBox, BoxLayout.X_AXIS));
    checkBoxShowCommit = new JCheckBox(I18n.get("statistic.operationTimeLineChartPanel.checkbox.commit"));
    checkBoxShowCommit.addActionListener(this);
    checkBoxShowOptimize = new JCheckBox(I18n.get("statistic.operationTimeLineChartPanel.checkbox.optimize"));
    checkBoxShowOptimize.addActionListener(this);
    checkBoxShowAdd = new JCheckBox(I18n.get("statistic.operationTimeLineChartPanel.checkbox.add"));
    checkBoxShowAdd.addActionListener(this);
    checkBoxShowQueries = new JCheckBox(I18n.get("statistic.operationTimeLineChartPanel.checkbox.query"));
    checkBoxShowQueries.addActionListener(this);
    panelCheckBox.add(Box.createHorizontalGlue());
    panelCheckBox.add(checkBoxShowCommit);
    panelCheckBox.add(Box.createHorizontalGlue());
    panelCheckBox.add(checkBoxShowOptimize);
    panelCheckBox.add(Box.createHorizontalGlue());
    panelCheckBox.add(checkBoxShowQueries);
    panelCheckBox.add(Box.createHorizontalGlue());
    panelCheckBox.add(checkBoxShowAdd);// w  w w  .  jav a2  s  . c om
    panelCheckBox.add(Box.createHorizontalGlue());
    panelCheckBox.setMaximumSize(new Dimension(800, 25));
    checkAll();
    return panelCheckBox;
}

From source file:com.jdom.util.patterns.mvp.swing.RadioButtonGroupDialog.java

private RadioButtonGroupDialog(Frame frame, Component locationComp, String labelText, String title,
        Collection<String> data, String initialValue, String longValue) {
    super(frame, title, true);

    final JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(this);

    final JButton setButton = new JButton("OK");
    setButton.setActionCommand("OK");
    setButton.addActionListener(this);
    getRootPane().setDefaultButton(setButton);

    ButtonGroup radioButtonGroup = new ButtonGroup();
    for (String option : data) {
        JRadioButton button = new JRadioButton(option);
        if (option.equals(initialValue)) {
            button.setSelected(true);/*w w  w. ja  v a2s.  c  o  m*/
        }
        radioButtonGroup.add(button);
        panel.add(button);
    }

    JScrollPane listScroller = new JScrollPane(panel);
    listScroller.setPreferredSize(new Dimension(250, 80));
    listScroller.setAlignmentX(LEFT_ALIGNMENT);

    JPanel listPane = new JPanel();
    listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));

    if (!StringUtils.isEmpty(labelText)) {
        JLabel label = new JLabel(labelText);
        label.setText(labelText);
        listPane.add(label);
    }
    listPane.add(Box.createRigidArea(new Dimension(0, 5)));
    listPane.add(listScroller);
    listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(cancelButton);
    buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
    buttonPane.add(setButton);

    Container contentPane = getContentPane();
    contentPane.add(listPane, BorderLayout.CENTER);
    contentPane.add(buttonPane, BorderLayout.PAGE_END);

    pack();
    setLocationRelativeTo(locationComp);
}