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:org.obiba.onyx.jade.instrument.ricelake.RiceLakeWeightInstrumentRunner.java

/**
 * Build action buttons sub panel/*  www . j av  a2 s . c  o m*/
 */
protected JPanel buildActionButtonSubPanel() {
    JPanel panel = new JPanel();

    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));

    panel.add(Box.createHorizontalGlue());
    panel.add(saveButton);

    JButton resetButton = new JButton(resourceBundle.getString("Reset"));
    resetButton.setMnemonic('R');
    resetButton.setToolTipText(resourceBundle.getString("ToolTip.Reset_measurement"));
    panel.add(Box.createRigidArea(new Dimension(10, 0)));
    panel.add(resetButton);

    JButton cancelButton = new JButton(resourceBundle.getString("Cancel"));
    cancelButton.setMnemonic('A');
    cancelButton.setToolTipText(resourceBundle.getString("ToolTip.Cancel_measurement"));
    panel.add(Box.createRigidArea(new Dimension(10, 0)));
    panel.add(cancelButton);

    JButton configureButton = new JButton(resourceBundle.getString("Configure"));
    configureButton.setMnemonic('C');
    configureButton.setToolTipText(resourceBundle.getString("ToolTip.Configure"));
    panel.add(Box.createRigidArea(new Dimension(10, 0)));
    panel.add(configureButton);

    // Configure button listener
    configureButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            configure();
        }
    });

    // Reset button listener
    resetButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            clearData();
        }
    });

    // Save button listener.
    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            sendOutputToServer();
        }
    });

    // Cancel button listener.
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            confirmOnExit();
        }
    });

    panel.setAlignmentX(Component.LEFT_ALIGNMENT);

    return (panel);
}

From source file:es.emergya.ui.gis.popups.GenericDialog.java

protected void addDate(Date fecha, String title, boolean editable) {
    rows++;//w  w w. j  a va2 s .c om
    // TODO editable
    mid.add(new JLabel(i18n.getString(title), JLabel.RIGHT));
    JPanel panel = new JPanel();
    panel.setOpaque(false);
    JCalendarCombo calendar = new JCalendarCombo();
    calendar.setEditable(editable);
    calendar.setPreferredSize(new Dimension(300, 30));
    calendar.setDate(fecha);
    calendar.setName(title);
    componentes.add(calendar);
    panel.add(calendar);
    JSpinner res = new JSpinner(new SpinnerDateModel());
    res.setName(title);
    res.setPreferredSize(new Dimension(60, 30));
    JSpinner.DateEditor startEditor = new JSpinner.DateEditor(res, "HH:mm:ss");
    startEditor.setEnabled(editable);
    res.setEditor(startEditor);
    componentes.add(res);
    if (fecha != null)
        res.setValue(fecha);
    panel.add(res);
    mid.add(panel);
    for (int i = 3; i < cols; i++)
        mid.add(Box.createHorizontalGlue());
}

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

private JPanel getCommentPanel(UserComment lc) {
    JTextArea commentText = new JTextArea();
    commentText.setText(lc.getCommentText());
    commentText.setEditable(false);//w  ww  . ja va 2  s . c  o  m
    commentText.setLineWrap(true);
    commentText.setPreferredSize(new Dimension(COMMENTTEXT_PREFERRED_WIDTH, COMMENTTEXT_PREFERRED_HEIGHT));
    JScrollPane jsp = new JScrollPane(commentText);

    JPanel outerCommentPanel = new JPanel();
    outerCommentPanel.setLayout(new BoxLayout(outerCommentPanel, BoxLayout.X_AXIS));
    outerCommentPanel.add(jsp);
    outerCommentPanel.add(Box.createHorizontalGlue());
    return outerCommentPanel;
}

From source file:org.pentaho.ui.xul.swing.tags.SwingDialog.java

private void populateButtonPanel() {

    buttonPanel.removeAll();/*  www.j  a v a  2 s .  c o m*/
    if (this.buttonAlignment == BUTTON_ALIGN.RIGHT || this.buttonAlignment == BUTTON_ALIGN.END
            || this.buttonAlignment == BUTTON_ALIGN.MIDDLE || this.buttonAlignment == BUTTON_ALIGN.CENTER
            || this.buttonAlignment == null) {
        buttonPanel.add(Box.createHorizontalGlue());
    }

    ArrayList<BUTTONS> buttonKeyList = new ArrayList<BUTTONS>(buttons.keySet());
    for (int i = 0; i < buttonKeyList.size(); i++) {
        buttonPanel.add(Box.createHorizontalStrut(5));
        buttonPanel.add((JButton) this.buttons.get(buttonKeyList.get(i)).getManagedObject());
        this.addChild(this.buttons.get(buttonKeyList.get(i)));
    }

    buttonPanel.add(Box.createHorizontalStrut(5));

    if (this.buttonAlignment == BUTTON_ALIGN.START || this.buttonAlignment == BUTTON_ALIGN.LEFT
            || this.buttonAlignment == BUTTON_ALIGN.MIDDLE || this.buttonAlignment == BUTTON_ALIGN.CENTER) {
        buttonPanel.add(Box.createHorizontalGlue());
    }

    if (buttons.containsKey(SwingDialog.BUTTONS.ACCEPT)) {
        this.buttons.get(SwingDialog.BUTTONS.ACCEPT).setLabel(this.getButtonlabelaccept());
        this.buttons.get(SwingDialog.BUTTONS.ACCEPT).setOnclick(this.getOndialogaccept());
    }
    if (buttons.containsKey(SwingDialog.BUTTONS.CANCEL)) {
        this.buttons.get(SwingDialog.BUTTONS.CANCEL).setLabel(this.getButtonlabelcancel());
        this.buttons.get(SwingDialog.BUTTONS.CANCEL).setOnclick(this.getOndialogcancel());
    }

    // FIXME
    if (buttons.containsKey(SwingDialog.BUTTONS.EXTRA1)) {
        this.buttons.get(SwingDialog.BUTTONS.EXTRA1).setLabel(this.getButtonlabelextra1());
        this.buttons.get(SwingDialog.BUTTONS.EXTRA1).setOnclick(this.getOndialogextra1());
    }
    if (buttons.containsKey(SwingDialog.BUTTONS.EXTRA2)) {
        this.buttons.get(SwingDialog.BUTTONS.EXTRA2).setLabel(this.getButtonlabelextra2());
        this.buttons.get(SwingDialog.BUTTONS.EXTRA2).setOnclick(this.getOndialogextra2());
    }
}

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;//w  w w  .j a v  a2  s  . 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:edu.virginia.speclab.juxta.author.view.export.WebServiceExportDialog.java

private Component createButtonBar() {
    JPanel p = new JPanel();
    p.setBackground(Color.white);
    p.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

    this.exportBtn = new JButton("Export");
    this.exportBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (exportBtn.getText().equals("View")) {
                viewWebServiceData();//from   w  w w  .  j  av a2  s.c  o  m
            } else {
                onExportClicked();
            }
        }
    });

    this.closeBtn = new JButton("Cancel");
    getRootPane().setDefaultButton(this.exportBtn);
    this.closeBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            onCancelClicked();
        }
    });

    p.add(Box.createHorizontalGlue());
    p.add(this.closeBtn);
    p.add(this.exportBtn);

    return p;
}

From source file:org.piraso.ui.base.RequestTreeTopComponent.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.//from   w w  w. jav a  2 s . c o  m
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jScrollPane1 = new javax.swing.JScrollPane();
    jTree = new javax.swing.JTree();
    toolbar = new javax.swing.JToolBar();
    btnCollapse = new javax.swing.JButton();
    btnColorLatest = new javax.swing.JToggleButton();
    jSeparator1 = new javax.swing.JToolBar.Separator();
    btnTarget = new javax.swing.JButton();

    setLayout(new java.awt.BorderLayout());

    jTree.setModel(model);
    jTree.setCellRenderer(new TreeCellRenderer());
    jTree.setRootVisible(false);
    jTree.setShowsRootHandles(true);
    jScrollPane1.setViewportView(jTree);

    add(jScrollPane1, java.awt.BorderLayout.CENTER);

    toolbar.setBackground(new java.awt.Color(226, 226, 226));
    toolbar.setFloatable(false);
    toolbar.setRollover(true);
    toolbar.setOpaque(false);

    btnCollapse.setIcon(new javax.swing.ImageIcon(
            getClass().getResource("/org/piraso/ui/base/icons/gh-icon-collapse.png"))); // NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(btnCollapse, org.openide.util.NbBundle
            .getMessage(RequestTreeTopComponent.class, "RequestTreeTopComponent.btnCollapse.text")); // NOI18N
    btnCollapse.setToolTipText(org.openide.util.NbBundle.getMessage(RequestTreeTopComponent.class,
            "RequestTreeTopComponent.btnCollapse.toolTipText")); // NOI18N
    btnCollapse.setBorder(javax.swing.BorderFactory.createEmptyBorder(7, 7, 7, 7));
    btnCollapse.setFocusable(false);
    btnCollapse.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnCollapse.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnCollapse.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnCollapseActionPerformed(evt);
        }
    });
    toolbar.add(btnCollapse);

    btnColorLatest
            .setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/piraso/ui/base/icons/time.png"))); // NOI18N
    btnColorLatest.setSelected(true);
    org.openide.awt.Mnemonics.setLocalizedText(btnColorLatest, org.openide.util.NbBundle
            .getMessage(RequestTreeTopComponent.class, "RequestTreeTopComponent.btnColorLatest.text")); // NOI18N
    btnColorLatest.setToolTipText(org.openide.util.NbBundle.getMessage(RequestTreeTopComponent.class,
            "RequestTreeTopComponent.btnColorLatest.toolTipText")); // NOI18N
    btnColorLatest.setFocusable(false);
    btnColorLatest.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnColorLatest.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnColorLatest.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnColorLatestActionPerformed(evt);
        }
    });
    toolbar.add(btnColorLatest);
    toolbar.add(jSeparator1);

    btnTarget.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/org/piraso/ui/base/icons/target_arrow.png"))); // NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(btnTarget, org.openide.util.NbBundle
            .getMessage(RequestTreeTopComponent.class, "RequestTreeTopComponent.btnTarget.text")); // NOI18N
    btnTarget.setToolTipText(org.openide.util.NbBundle.getMessage(RequestTreeTopComponent.class,
            "RequestTreeTopComponent.btnTarget.toolTipText")); // NOI18N
    btnTarget.setBorder(javax.swing.BorderFactory.createEmptyBorder(7, 7, 7, 7));
    btnTarget.setFocusable(false);
    btnTarget.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnTarget.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnTarget.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnTargetActionPerformed(evt);
        }
    });
    toolbar.add(Box.createHorizontalGlue());
    toolbar.add(btnTarget);

    add(toolbar, java.awt.BorderLayout.NORTH);
}

From source file:org.nuclos.client.genericobject.logbook.LogbookController.java

private void setupToolbar(final LogbookPanel pnlLogbook) {
    this.btnRefresh.setName("btnRefresh");
    this.btnRefresh.setAction(actRefresh);
    this.btnRefresh.setText(null);
    pnlLogbook.getToolbar().add(this.btnRefresh);

    pnlFilter.setBorder(BorderFactory
            .createTitledBorder(getSpringLocaleDelegate().getMessage("LogbookController.4", "Filter nach")));
    pnlFilter.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets.right = 5;//w  ww . j av a2 s.c om
    gbc.fill = GridBagConstraints.NONE;

    gbc.gridx = 0;
    gbc.gridy = 0;
    pnlFilter.add(new JLabel(getSpringLocaleDelegate().getMessage("LogbookController.5", "Ge\u00e4ndert am")),
            gbc);

    gbc.gridx = 1;
    gbc.insets.right = 10;
    this.pnlFilter.add(this.tfCOLUMN_CHANGEDAT, gbc);
    this.tfCOLUMN_CHANGEDAT.setColumns(15);
    this.tfCOLUMN_CHANGEDAT.setToolTipText(
            getSpringLocaleDelegate().getMessage("LogbookController.6", "Filter nach Spalte") + " '"
                    + getSpringLocaleDelegate().getMessage("LogbookController.5", "Ge\u00e4ndert am") + "'");

    ++gbc.gridy;
    gbc.gridx = 0;
    gbc.insets.right = 5;
    pnlFilter.add(new JLabel(getSpringLocaleDelegate().getMessage("LogbookController.7", "Ge\u00e4ndert von")),
            gbc);

    gbc.gridx = 1;
    gbc.insets.right = 10;
    this.pnlFilter.add(this.tfCOLUMN_CHANGEDBY, gbc);
    this.tfCOLUMN_CHANGEDBY.setColumns(15);
    this.tfCOLUMN_CHANGEDBY.setToolTipText(
            getSpringLocaleDelegate().getMessage("LogbookController.6", "Filter nach Spalte") + " '"
                    + getSpringLocaleDelegate().getMessage("LogbookController.7", "Ge\u00e4ndert von") + "'");

    ++gbc.gridy;
    gbc.gridx = 0;
    gbc.insets.right = 5;
    pnlFilter.add(new JLabel(getSpringLocaleDelegate().getMessage("LogbookController.8", "Feld")), gbc);

    gbc.gridx = 1;
    gbc.insets.right = 10;
    this.pnlFilter.add(this.tfCOLUMN_LABEL, gbc);
    this.tfCOLUMN_LABEL.setColumns(15);
    this.tfCOLUMN_LABEL
            .setToolTipText(getSpringLocaleDelegate().getMessage("LogbookController.6", "Filter nach Spalte")
                    + " '" + getSpringLocaleDelegate().getMessage("LogbookController.8", "Feld") + "'");

    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.insets.right = 5;
    pnlFilter.add(new JLabel(getSpringLocaleDelegate().getMessage("LogbookController.9", "Alter Wert")), gbc);

    gbc.gridx = 3;
    this.pnlFilter.add(this.tfCOLUMN_OLDVALUE, gbc);
    this.tfCOLUMN_OLDVALUE.setColumns(15);
    this.tfCOLUMN_OLDVALUE
            .setToolTipText(getSpringLocaleDelegate().getMessage("LogbookController.6", "Filter nach Spalte")
                    + " '" + getSpringLocaleDelegate().getMessage("LogbookController.9", "Alter Wert") + "'");

    ++gbc.gridy;
    gbc.gridx = 2;
    pnlFilter.add(new JLabel(getSpringLocaleDelegate().getMessage("LogbookController.10", "Neuer Wert")), gbc);

    gbc.gridx = 3;
    this.pnlFilter.add(this.tfCOLUMN_NEWVALUE, gbc);
    this.tfCOLUMN_NEWVALUE.setColumns(15);
    this.tfCOLUMN_NEWVALUE
            .setToolTipText(getSpringLocaleDelegate().getMessage("LogbookController.6", "Filter nach Spalte")
                    + " '" + getSpringLocaleDelegate().getMessage("LogbookController.10", "Neuer Wert") + "'");

    ++gbc.gridy;
    gbc.gridx = 2;
    pnlFilter.add(new JLabel(getSpringLocaleDelegate().getMessage("LogbookController.11", "ID")), gbc);

    gbc.gridx = 3;
    this.pnlFilter.add(this.tfCOLUMN_ID, gbc);
    this.tfCOLUMN_ID.setColumns(15);
    this.tfCOLUMN_ID
            .setToolTipText(getSpringLocaleDelegate().getMessage("LogbookController.6", "Filter nach Spalte")
                    + " '" + getSpringLocaleDelegate().getMessage("LogbookController.11", "ID") + "'");

    gbc.gridx = 4;
    gbc.gridy = 0;
    gbc.weightx = 0.1;
    this.btnFilter.setAction(actFilter);
    this.btnFilter.setText(null);
    this.pnlFilter.add(this.btnFilter, gbc);

    gbc.gridx = 4;
    gbc.gridy = 1;
    this.btnClearFilter.setAction(actClearFilter);
    this.btnClearFilter.setText(null);
    this.pnlFilter.add(this.btnClearFilter, gbc);

    pnlLogbook.getToolbar().add(this.pnlFilter);
    pnlLogbook.getToolbar().add(Box.createHorizontalGlue());

    /**
     * action: Refresh
     */
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.REFRESH, actRefresh, pnlLogbook);
}

From source file:es.emergya.ui.gis.popups.GenericDialog.java

protected void addList(Object[] lista, String label) {
    rows++;/* w  ww.  j  ava2  s  .  c o  m*/
    mid.add(new JLabel(i18n.getString(label), JLabel.RIGHT));
    if (lista != null) {
        JList jlist = new JList(lista);
        final JScrollPane jScrollPane = new JScrollPane(jlist);
        jScrollPane.getViewport().setPreferredSize(new Dimension(100, 100));
        mid.add(jScrollPane);
    }
    for (int i = 2; i < cols; i++)
        mid.add(Box.createHorizontalGlue());
}

From source file:ro.nextreports.designer.NextReports.java

public static void showStartDialog(boolean test) {

    JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS));
    final JCheckBox chk = new JCheckBox(I18NSupport.getString("start.panel.show.startup"), true);
    bottomPanel.add(chk);/*ww w .  j  av  a  2 s. co m*/
    bottomPanel.add(Box.createHorizontalGlue());
    String start = ReporterPreferencesManager.getInstance()
            .loadParameter(ReporterPreferencesManager.SHOW_AT_STARTUP + "_" + ReleaseInfo.getVersion());
    if (test && "false".equals(start)) {
        return;
    }

    HelpMovieAction helpAction = new HelpMovieAction();
    VistaButton buttonHelp = new VistaButton(helpAction, I18NSupport.getString("start.panel.help"));
    ImportAction importAction = new ImportAction();
    VistaButton buttonImport = new VistaButton(importAction, I18NSupport.getString("start.panel.import"));
    AddDataSourceAction dataSourceAction = new AddDataSourceAction();
    VistaButton buttonDataSource = new VistaButton(dataSourceAction,
            I18NSupport.getString("start.panel.datasource"));
    WizardAction wizardAction = new WizardAction(Globals.getMainFrame().getQueryBuilderPanel().getTree());
    VistaButton buttonWizard = new VistaButton(wizardAction, I18NSupport.getString("start.panel.wizard"));

    List<VistaButton> list = new ArrayList<VistaButton>();
    list.add(buttonHelp);
    list.add(buttonImport);
    list.add(buttonDataSource);
    list.add(buttonWizard);

    VistaDialogContent content = new VistaDialogContent(list, I18NSupport.getString("start.panel.title"),
            I18NSupport.getString("start.panel.subtitle"));
    VistaDialog dialog = new VistaDialog(content, bottomPanel, Globals.getMainFrame(), true) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void beforeDispose() {
            String show = chk.isSelected() ? "true" : "false";
            ReporterPreferencesManager.getInstance().storeParameter(
                    ReporterPreferencesManager.SHOW_AT_STARTUP + "_" + ReleaseInfo.getVersion(), show);
        }

    };
    dialog.setTitle(I18NSupport.getString("menu.startup"));
    dialog.selectButton(buttonHelp);

    dialog.setDispose(true);
    dialog.setEscapeOption(true);

    dialog.pack();
    dialog.setResizable(false);
    Show.centrateComponent(Globals.getMainFrame(), dialog);
    dialog.setVisible(true);
}