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:uk.nhs.cfh.dsp.srth.desktop.modules.querycreationtreepanel.QueryComponentExpressionPanel.java

/**
 * Creates the excluded terms panel./*from  w  ww.j av  a  2  s  .  c  o m*/
 */
private synchronized void createExcludedTermsPanel() {

    // create table for displaying excluded constraints
    excludedConstraintTableModel = new TerminologyConstraintTableModel();
    excludedConstraintsTable = new JTable(excludedConstraintTableModel);
    excludedConstraintsTable.setDefaultRenderer(TerminologyConstraint.class,
            new TerminologyConstraintTableCellRenderer(humanReadableRender));
    excludedConstraintsTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            // get row a click
            int row = excludedConstraintsTable.rowAtPoint(e.getPoint());
            if (row > -1 && e.getClickCount() == 2) {
                //                    addingNew = false;
                editingExisting = true;
                // get constraint at row
                activeTerminologyConstraint = excludedConstraintTableModel.getConstraintAtRow(row);
                // set constraint in activeConstraintPanel and display activeConstraintsDialog
                activeConstraintPanel.setConstraint(activeTerminologyConstraint);
                activeConstraintsDialog.setVisible(true);
            }
        }
    });

    // create a label and control buttons for editing excluded constraints
    JPanel p3 = new JPanel();
    p3.setLayout(new BoxLayout(p3, BoxLayout.LINE_AXIS));
    p3.add(new JLabel("Edit excluded constraints"));
    p3.add(Box.createHorizontalGlue());

    // add panel for editing excluded terms
    JideButton addExclusionTermButton = new JideButton(new AbstractAction("", addExclusionIcon) {

        public void actionPerformed(ActionEvent e) {
            // show activeConstraintsDialog
            //                addingNew = true;
            activeConstraintsDialog.setVisible(true);
        }
    });
    addExclusionTermButton.setName("addExclusionTermButton");

    JideButton deleteExclusionTermButton = new JideButton(new AbstractAction("", deleteExclusionIcon) {

        public void actionPerformed(ActionEvent e) {
            final int row = excludedConstraintsTable.getSelectedRow();
            if (row > -1) {
                QueryStatement oldValue = queryService.getActiveQuery();
                // get term at row
                TerminologyConstraint term = (TerminologyConstraint) excludedConstraintTableModel
                        .getValueAt(row, 1);
                // remove term from sub query
                componentExpression.removeExcludedConstraint(term);
                Runnable runnable = new Runnable() {
                    public void run() {
                        excludedConstraintTableModel.deleteRow(row);
                    }
                };
                SwingUtilities.invokeLater(runnable);
                // notify listeners
                propertyChangeTrackerService.firePropertyChanged(ACTIVE_QUERY_CHANGED, oldValue,
                        queryService.getActiveQuery(), QueryComponentExpressionPanel.this);
            }
        }
    });
    deleteExclusionTermButton.setName("deleteExclusionTermButton");

    // add buttons to p3
    p3.add(addExclusionTermButton);
    p3.add(deleteExclusionTermButton);

    // create panel that contains excluded constraints
    excludedConstraintsPanel = new JPanel(new BorderLayout());
    excludedConstraintsPanel.setBorder(BorderFactory.createTitledBorder("Excluded constraints"));
    excludedConstraintsPanel.add(p3, BorderLayout.NORTH);
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setViewportView(excludedConstraintsTable);
    excludedConstraintsPanel.add(scrollPane, BorderLayout.CENTER);
}

From source file:org.ut.biolab.medsavant.client.view.component.KeyValuePairPanel.java

public void setValue(String key, JComponent value) {
    JPanel p = keyValueComponentMap.get(key);
    p.removeAll();/*from  w w w .  j a v a  2s . c  o m*/
    p.add(value);
    p.add(Box.createHorizontalGlue());
    p.repaint();
    p.getParent().repaint();
}

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

private void init() {

    this.setResizable(IS_RESIZABLE);
    mainPanel.setLayout(new BorderLayout());

    getContentPane().add(mainPanel);//from   w  w  w .jav a2s .  c o m

    tabPane.setBorder(BorderFactory.createEmptyBorder(JTABPANE_MARGINS, JTABPANE_MARGINS, 0, JTABPANE_MARGINS));
    mainPanel.add(tabPane, java.awt.BorderLayout.CENTER);
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, JTABPANE_MARGINS, 0, JTABPANE_MARGINS));
    WidgetFactory.setPrefMinSizes(buttonPanel, BUTTON_PANEL_DIMS);
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    mainPanel.add(buttonPanel, java.awt.BorderLayout.SOUTH);

    Color bgColor = StaticGUIResources.getColor("dialogs.mainPanel.bgcolor.r", "dialogs.mainPanel.bgcolor.g",
            "dialogs.mainPanel.bgcolor.b");
    if (bgColor != null) {
        mainPanel.setOpaque(true);
        mainPanel.setBackground(bgColor);
        buttonPanel.setOpaque(true);
        buttonPanel.setBackground(bgColor);
    }

    initButtons();
    buttonPanel.add(Box.createHorizontalGlue());
    buttonPanel.add(okButton);
    buttonPanel.add(WidgetFactory.getDefaultSpacer());
    buttonPanel.add(applyButton);
    buttonPanel.add(WidgetFactory.getDefaultSpacer());
    buttonPanel.add(cancelButton);
    buttonPanel.add(WidgetFactory.getDefaultSpacer());
    buttonPanel.add(helpButton);

}

From source file:com.diversityarrays.kdxplore.trials.TrialDetailsPanel.java

TrialDetailsPanel(WindowOpener<JFrame> windowOpener, MessagePrinter mp, BackgroundRunner backgroundRunner,
        OfflineData offlineData, Action editTrialAction, Action seedPrepAction, Action harvestAction,
        Action uploadTrialAction, Action refreshTrialInfoAction, ImageIcon barcodeIcon,
        Transformer<Trial, Boolean> checkIfEditorActive, Consumer<Trial> onTraitInstancesRemoved) {
    super(new BorderLayout());

    this.editTrialAction = editTrialAction;
    this.uploadTrialAction = uploadTrialAction;
    this.refreshTrialInfoAction = refreshTrialInfoAction;
    this.onTraitInstancesRemoved = onTraitInstancesRemoved;

    this.messagePrinter = mp;
    this.backgroundRunner = backgroundRunner;
    this.offlineData = offlineData;

    if (barcodeIcon == null) {
        barcodesMenuButton = new JLabel("Barcodes"); //$NON-NLS-1$
    } else {/*from w w w.  ja v a  2s.  c  o m*/
        barcodesMenuButton = new JLabel(barcodeIcon);
    }
    barcodesMenuButton.setBorder(BorderFactory.createRaisedSoftBevelBorder());

    barcodesMenuButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (trial != null) {
                barcodesMenuHandler.handleMouseClick(e.getPoint());
            }
        }
    });

    trialViewPanel = new TrialViewPanel(windowOpener, offlineData, checkIfEditorActive, onTraitInstancesRemoved,
            mp);

    Box buttons = Box.createHorizontalBox();
    buttons.add(new JButton(refreshTrialInfoAction));
    buttons.add(new JButton(seedPrepAction));
    buttons.add(new JButton(editTrialAction));
    buttons.add(new JButton(uploadTrialAction));
    buttons.add(new JButton(harvestAction));
    buttons.add(barcodesMenuButton);
    buttons.add(Box.createHorizontalGlue());

    //      JPanel trialPanel = new JPanel(new BorderLayout());
    //      trialPanel.add(buttons, BorderLayout.NORTH);
    //      trialPanel.add(fieldViewPanel, BorderLayout.CENTER);

    cardPanel.add(new JLabel(Msg.LABEL_NO_TRIAL_SELECTED()), CARD_NO_TRIAL);
    cardPanel.add(trialViewPanel, CARD_HAVE_TRIAL);

    setSelectedTrial(null);

    add(buttons, BorderLayout.NORTH);
    add(cardPanel, BorderLayout.CENTER);
}

From source file:es.emergya.ui.plugins.admin.aux1.RecursoDialog.java

public RecursoDialog(final Recurso rec, final AdminResources adminResources) {
    super();//from ww  w.j a  va  2  s. c o m
    setAlwaysOnTop(true);
    setSize(600, 400);

    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            super.windowClosing(e);
            if (cambios) {
                int res = JOptionPane.showConfirmDialog(RecursoDialog.this,
                        "Existen cambios sin guardar. Seguro que desea cerrar la ventana?",
                        "Cambios sin guardar", JOptionPane.OK_CANCEL_OPTION);
                if (res != JOptionPane.CANCEL_OPTION) {
                    e.getWindow().dispose();
                }
            } else {
                e.getWindow().dispose();
            }
        }
    });
    final Recurso r = (rec == null) ? null : RecursoConsultas.get(rec.getId());
    if (r != null) {
        setTitle(i18n.getString("Resources.summary.titleWindow") + " " + r.getIdentificador());
    } else {
        setTitle(i18n.getString("Resources.summary.titleWindow.new"));
    }
    setIconImage(getBasicWindow().getFrame().getIconImage());
    JPanel base = new JPanel();
    base.setBackground(Color.WHITE);
    base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));

    // Icono del titulo
    JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING));
    title.setOpaque(false);
    JLabel labelTitulo = null;
    if (r != null) {
        labelTitulo = new JLabel(i18n.getString("Resources.summary"),
                LogicConstants.getIcon("tittleficha_icon_recurso"), JLabel.LEFT);

    } else {
        labelTitulo = new JLabel(i18n.getString("Resources.cabecera.nuevo"),
                LogicConstants.getIcon("tittleficha_icon_recurso"), JLabel.LEFT);

    }
    labelTitulo.setFont(LogicConstants.deriveBoldFont(12f));
    title.add(labelTitulo);
    base.add(title);

    // Nombre
    JPanel mid = new JPanel(new SpringLayout());
    mid.setOpaque(false);
    mid.add(new JLabel(i18n.getString("Resources.name"), JLabel.RIGHT));
    final JTextField name = new JTextField(25);
    if (r != null) {
        name.setText(r.getNombre());
    }

    name.getDocument().addDocumentListener(changeListener);
    name.setEditable(r == null);
    mid.add(name);

    // patrullas
    final JLabel labelSquads = new JLabel(i18n.getString("Resources.squad"), JLabel.RIGHT);
    mid.add(labelSquads);
    List<Patrulla> pl = PatrullaConsultas.getAll();
    pl.add(0, null);
    final JComboBox squads = new JComboBox(pl.toArray());
    squads.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXX");
    squads.addActionListener(changeSelectionListener);
    squads.setOpaque(false);
    labelSquads.setLabelFor(squads);
    if (r != null) {
        squads.setSelectedItem(r.getPatrullas());
    } else {
        squads.setSelectedItem(null);
    }
    squads.setEnabled((r != null && r.getHabilitado() != null) ? r.getHabilitado() : true);
    mid.add(squads);

    // // Identificador
    // mid.setOpaque(false);
    // mid.add(new JLabel(i18n.getString("Resources.identificador"),
    // JLabel.RIGHT));
    // final JTextField identificador = new JTextField("");
    // if (r != null) {
    // identificador.setText(r.getIdentificador());
    // }
    // identificador.getDocument().addDocumentListener(changeListener);
    // identificador.setEditable(r == null);
    // mid.add(identificador);
    // Espacio en blanco
    // mid.add(Box.createHorizontalGlue());
    // mid.add(Box.createHorizontalGlue());

    // Tipo
    final JLabel labelTipoRecursos = new JLabel(i18n.getString("Resources.type"), JLabel.RIGHT);
    mid.add(labelTipoRecursos);
    final JComboBox types = new JComboBox(RecursoConsultas.getTipos());
    labelTipoRecursos.setLabelFor(types);
    types.addActionListener(changeSelectionListener);
    if (r != null) {
        types.setSelectedItem(r.getTipo());
    } else {
        types.setSelectedItem(0);
    }
    // types.setEditable(true);
    types.setEnabled(true);
    mid.add(types);

    // Estado Eurocop
    mid.add(new JLabel(i18n.getString("Resources.status"), JLabel.RIGHT));
    final JTextField status = new JTextField();
    if (r != null && r.getEstadoEurocop() != null) {
        status.setText(r.getEstadoEurocop().getIdentificador());
    }
    status.setEditable(false);
    mid.add(status);

    // Subflota y patrulla
    mid.add(new JLabel(i18n.getString("Resources.subfleet"), JLabel.RIGHT));
    final JComboBox subfleets = new JComboBox(FlotaConsultas.getAllHabilitadas());
    subfleets.addActionListener(changeSelectionListener);
    if (r != null) {
        subfleets.setSelectedItem(r.getFlotas());
    } else {
        subfleets.setSelectedIndex(0);
    }
    subfleets.setEnabled(true);
    subfleets.setOpaque(false);
    mid.add(subfleets);

    // Referencia humana
    mid.add(new JLabel(i18n.getString("Resources.incidences"), JLabel.RIGHT));
    final JTextField rhumana = new JTextField();
    // if (r != null && r.getIncidencias() != null) {
    // rhumana.setText(r.getIncidencias().getReferenciaHumana());
    // }
    rhumana.setEditable(false);
    mid.add(rhumana);

    // dispositivo
    mid.add(new JLabel(i18n.getString("Resources.device"), JLabel.RIGHT));
    final PlainDocument plainDocument = new PlainDocument() {

        private static final long serialVersionUID = 4929271093724956016L;

        @Override
        public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
            if (this.getLength() + str.length() <= LogicConstants.LONGITUD_ISSI) {
                super.insertString(offs, str, a);
            }
        }
    };
    final JTextField issi = new JTextField(plainDocument, "", LogicConstants.LONGITUD_ISSI);
    plainDocument.addDocumentListener(changeListener);
    issi.setEditable(true);
    mid.add(issi);
    mid.add(new JLabel(i18n.getString("Resources.enabled"), JLabel.RIGHT));
    final JCheckBox enabled = new JCheckBox("", true);
    enabled.addActionListener(changeSelectionListener);
    enabled.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            if (enabled.isSelected()) {
                squads.setSelectedIndex(0);
            }
            squads.setEnabled(enabled.isSelected());
        }
    });
    enabled.setEnabled(true);
    enabled.setOpaque(false);
    if (r != null) {
        enabled.setSelected(r.getHabilitado());
    } else {
        enabled.setSelected(true);
    }
    if (r != null && r.getDispositivo() != null) {
        issi.setText(
                StringUtils.leftPad(String.valueOf(r.getDispositivo()), LogicConstants.LONGITUD_ISSI, '0'));
    }

    mid.add(enabled);

    // Fecha ultimo gps
    mid.add(new JLabel(i18n.getString("Resources.lastPosition"), JLabel.RIGHT));
    JTextField lastGPS = new JTextField();
    final Date lastGPSDateForRecurso = HistoricoGPSConsultas.lastGPSDateForRecurso(r);
    if (lastGPSDateForRecurso != null) {
        lastGPS.setText(SimpleDateFormat.getDateTimeInstance().format(lastGPSDateForRecurso));
    }
    lastGPS.setEditable(false);
    mid.add(lastGPS);

    // Espacio en blanco
    mid.add(Box.createHorizontalGlue());
    mid.add(Box.createHorizontalGlue());

    // informacion adicional
    JPanel infoPanel = new JPanel(new SpringLayout());
    final JTextField info = new JTextField(25);
    info.getDocument().addDocumentListener(changeListener);
    infoPanel.add(new JLabel(i18n.getString("Resources.info")));
    infoPanel.add(info);
    infoPanel.setOpaque(false);
    info.setOpaque(false);
    SpringUtilities.makeCompactGrid(infoPanel, 1, 2, 6, 6, 6, 18);

    if (r != null) {
        info.setText(r.getInfoAdicional());
    } else {
        info.setText("");
    }
    info.setEditable(true);

    // Espacio en blanco
    mid.add(Box.createHorizontalGlue());
    mid.add(Box.createHorizontalGlue());

    SpringUtilities.makeCompactGrid(mid, 5, 4, 6, 6, 6, 18);
    base.add(mid);
    base.add(infoPanel);

    JPanel buttons = new JPanel();
    buttons.setOpaque(false);
    JButton accept = null;
    if (r == null) {
        accept = new JButton("Crear", LogicConstants.getIcon("button_crear"));
    } else {
        accept = new JButton("Guardar", LogicConstants.getIcon("button_save"));
    }
    accept.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                if (cambios || r == null || r.getId() == null) {
                    boolean shithappens = true;
                    if ((r == null || r.getId() == null)) { // Estamos
                        // creando
                        // uno nuevo
                        if (RecursoConsultas.alreadyExists(name.getText())) {
                            shithappens = false;
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.nombreUnico"));
                        } else if (issi.getText() != null && issi.getText().length() > 0 && StringUtils
                                .trimToEmpty(issi.getText()).length() != LogicConstants.LONGITUD_ISSI) {
                            JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString(Locale.ROOT,
                                    "admin.recursos.popup.error.faltanCifras", LogicConstants.LONGITUD_ISSI));
                            shithappens = false;
                        } else if (issi.getText() != null && issi.getText().length() > 0
                                && LogicConstants.isNumeric(issi.getText())
                                && RecursoConsultas.alreadyExists(new Integer(issi.getText()))) {
                            shithappens = false;
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.dispositivoUnico"));
                        }
                    }
                    if (shithappens) {
                        if (name.getText().isEmpty()) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.nombreNulo"));
                        } else if (issi.getText() != null && issi.getText().length() > 0 && StringUtils
                                .trimToEmpty(issi.getText()).length() != LogicConstants.LONGITUD_ISSI) {
                            JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString(Locale.ROOT,
                                    "admin.recursos.popup.error.faltanCifras", LogicConstants.LONGITUD_ISSI));
                        } else if (issi.getText() != null && issi.getText().length() > 0
                                && LogicConstants.isNumeric(issi.getText()) && r != null && r.getId() != null
                                && RecursoConsultas.alreadyExists(new Integer(issi.getText()), r.getId())) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.issiUnico"));
                        } else if (issi.getText() != null && issi.getText().length() > 0
                                && !LogicConstants.isNumeric(issi.getText())) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.noNumerico"));
                            // } else if (identificador.getText().isEmpty())
                            // {
                            // JOptionPane
                            // .showMessageDialog(
                            // RecursoDialog.this,
                            // i18n.getString("admin.recursos.popup.error.identificadorNulo"));
                        } else if (subfleets.getSelectedIndex() == -1) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.noSubflota"));
                        } else if (types.getSelectedItem() == null
                                || types.getSelectedItem().toString().trim().isEmpty()) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.noTipo"));
                        } else {
                            int i = JOptionPane.showConfirmDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.dialogo.guardar.titulo"),
                                    i18n.getString("admin.recursos.popup.dialogo.guardar.guardar"),
                                    JOptionPane.YES_NO_CANCEL_OPTION);

                            if (i == JOptionPane.YES_OPTION) {

                                Recurso recurso = r;

                                if (r == null) {
                                    recurso = new Recurso();
                                }

                                recurso.setInfoAdicional(info.getText());
                                if (issi.getText() != null && issi.getText().length() > 0) {
                                    recurso.setDispositivo(new Integer(issi.getText()));
                                } else {
                                    recurso.setDispositivo(null);
                                }
                                recurso.setFlotas(FlotaConsultas.find(subfleets.getSelectedItem().toString()));
                                if (squads.getSelectedItem() != null && enabled.isSelected()) {
                                    recurso.setPatrullas(
                                            PatrullaConsultas.find(squads.getSelectedItem().toString()));
                                } else {
                                    recurso.setPatrullas(null);
                                }
                                recurso.setNombre(name.getText());
                                recurso.setHabilitado(enabled.isSelected());
                                // recurso.setIdentificador(identificador
                                // .getText());
                                recurso.setTipo(types.getSelectedItem().toString());
                                dispose();

                                RecursoAdmin.saveOrUpdate(recurso);
                                adminResources.refresh(null);

                                PluginEventHandler.fireChange(adminResources);
                            } else if (i == JOptionPane.NO_OPTION) {
                                dispose();
                            }
                        }
                    }
                } else {
                    log.debug("No hay cambios");
                    dispose();
                }

            } catch (Throwable t) {
                log.error("Error guardando un recurso", t);
            }
        }
    });
    buttons.add(accept);

    JButton cancelar = new JButton("Cancelar", LogicConstants.getIcon("button_cancel"));

    cancelar.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (cambios) {
                if (JOptionPane.showConfirmDialog(RecursoDialog.this,
                        "Existen cambios sin guardar. Seguro que desea cerrar la ventana?",
                        "Cambios sin guardar", JOptionPane.OK_CANCEL_OPTION) != JOptionPane.CANCEL_OPTION) {
                    dispose();
                }
            } else {
                dispose();
            }
        }
    });

    buttons.add(cancelar);

    base.add(buttons);

    getContentPane().add(base);
    setLocationRelativeTo(null);
    cambios = false;
    if (r == null) {
        cambios = true;
    }

    pack();

    int x;
    int y;

    Container myParent = getBasicWindow().getPluginContainer().getDetachedTab(0);
    Point topLeft = myParent.getLocationOnScreen();
    Dimension parentSize = myParent.getSize();

    Dimension mySize = getSize();

    if (parentSize.width > mySize.width) {
        x = ((parentSize.width - mySize.width) / 2) + topLeft.x;
    } else {
        x = topLeft.x;
    }

    if (parentSize.height > mySize.height) {
        y = ((parentSize.height - mySize.height) / 2) + topLeft.y;
    } else {
        y = topLeft.y;
    }

    setLocation(x, y);
    cambios = false;
}

From source file:pcgen.gui2.tabs.SummaryInfoTab.java

private void initMiddlePanel(JPanel middlePanel) {
    middlePanel.setLayout(new GridLayout(2, 1));

    JPanel statsPanel = new JPanel();
    setPanelTitle(statsPanel, LanguageBundle.getString("in_sumAbilityScores")); //$NON-NLS-1$
    statsPanel.setLayout(new BoxLayout(statsPanel, BoxLayout.Y_AXIS));

    StatTableModel.initializeTable(statsTable);
    JScrollPane pane = new JScrollPane(statsTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER) {

        @Override/*from  w w w  . j a  v  a 2s  .  c  o  m*/
        public Dimension getMaximumSize() {
            //This prevents the scroll pane from taking up more space than it needs.
            return super.getPreferredSize();
        }

    };
    pane.setBorder(BorderFactory.createEmptyBorder());
    JPanel statsBox = new JPanel();
    statsBox.setLayout(new BoxLayout(statsBox, BoxLayout.X_AXIS));
    statsBox.add(Box.createHorizontalGlue());
    statsBox.add(pane);
    statsBox.add(Box.createHorizontalGlue());
    statsPanel.add(statsBox);

    JPanel statTotalPanel = new JPanel();
    statTotalPanel.setLayout(new BoxLayout(statTotalPanel, BoxLayout.X_AXIS));
    //this makes box layout use the statTotalPanel to distribute extra space
    statTotalPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    statTotalPanel.add(Box.createHorizontalGlue());
    FontManipulation.title(statTotalLabel);
    statTotalPanel.add(statTotalLabel);
    statTotalPanel.add(statTotal);
    FontManipulation.title(modTotalLabel);
    statTotalPanel.add(modTotalLabel);
    statTotalPanel.add(modTotal);
    statTotalPanel.add(Box.createHorizontalGlue());
    generateRollsButton.setText(LanguageBundle.getString("in_sumGenerate_Rolls")); //$NON-NLS-1$
    statTotalPanel.add(generateRollsButton);
    rollMethodButton.setText(LanguageBundle.getString("in_sumRoll_Method")); //$NON-NLS-1$
    statTotalPanel.add(Box.createRigidArea(new Dimension(5, 0)));
    statTotalPanel.add(rollMethodButton);
    statTotalPanel.add(Box.createHorizontalGlue());
    statsPanel.add(statTotalPanel);

    middlePanel.add(statsPanel);

    InfoPaneHandler.initializeEditorPane(infoPane);

    pane = new JScrollPane(infoPane);
    setPanelTitle(pane, LanguageBundle.getString("in_sumStats")); //$NON-NLS-1$
    middlePanel.add(pane);
}

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

public final void clearMenu() {

    while (primaryMenuButtons.getButtonCount() > 0) {
        primaryMenuButtons.remove(primaryMenuButtons.getElements().nextElement());
    }//from   w  w w .j  av a2 s.  c  o  m

    primaryMenuSectionButtonContainer.removeAll();
    secondaryMenu.removeAll();

    tertiaryMenu.removeAll();
    tertiaryMenuPanelVisibilityContainer.removeAll();
    tertiaryMenuPanelAccessoryContainer.removeAll();

    tertiaryMenu.add(tertiaryMenuPanelVisibilityContainer);
    tertiaryMenu.add(Box.createHorizontalGlue());
    tertiaryMenu.add(tertiaryMenuPanelAccessoryContainer);
}

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

private JPanel getCommentBlock(UserCommentGroup lcg, UserComment lc/*, UserComment oldComment*/) {

    JPanel innerPanel = new JPanel();
    innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.Y_AXIS));

    JPanel headerPanel = getHeaderPanel(lc);
    JPanel commentPanel = getCommentPanel(lc);

    if (lc.getOriginalComment() == null) { //root level comment.
        innerPanel.add(headerPanel);/*from w w w . j a v a  2  s . co  m*/
        innerPanel.add(getStatusIconPanel(lcg, lc));
        innerPanel.add(commentPanel);
        innerPanel.add(getCommentSeparator());

        return innerPanel;
    } else { //status comment.
        JPanel outerPanel = new JPanel();
        outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.X_AXIS));
        JSeparator js = new JSeparator();
        js.setPreferredSize(new Dimension(STATUS_COMMENT_INDENT_WIDTH, 1));
        outerPanel.add(js);

        innerPanel.add(headerPanel);

        //System.out.println("Constructing statusIconPanel with "+lc.isApproved()+","+lc.isIncluded()+","+lc.isPendingReview());
        JPanel statusIconPanel = new StatusIconPanel(ICON_WIDTH, ICON_HEIGHT, false, lc.isApproved(),
                lc.isIncluded(), lc.isDeleted());

        JPanel centeredLabel = new JPanel();
        centeredLabel.setLayout(new BoxLayout(centeredLabel, BoxLayout.X_AXIS));
        centeredLabel.add(Box.createHorizontalGlue());
        centeredLabel.add(new JLabel("Status Change:"));
        centeredLabel.add(Box.createHorizontalGlue());
        innerPanel.add(centeredLabel);
        oldStatusPanel = new JPanel();
        oldStatusPanel.setLayout(new BoxLayout(oldStatusPanel, BoxLayout.X_AXIS));
        oldStatusPanel.add(Box.createHorizontalGlue());
        oldStatusPanel.add(statusIconPanel);
        innerPanel.add(oldStatusPanel);
        innerPanel.add(commentPanel);
        innerPanel.add(getCommentSeparator());
        outerPanel.add(innerPanel);
        return outerPanel;
    }
}

From source file:diet.gridr.g5k.gui.ClusterInfoPanel.java

/**
 * This method initializes jPanel1/*from   w  ww.  ja  va2  s . c  o  m*/
 *
 * @return javax.swing.JPanel
 */
private JPanel getJPanel1() {
    if (jPanel1 == null) {
        jPanel1 = new JPanel();
        jPanel1.setLayout(new BoxLayout(jPanel1, BoxLayout.X_AXIS));
        jPanel1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        JPanel intermediaryPanel = new JPanel();
        intermediaryPanel.setLayout(new BoxLayout(intermediaryPanel, BoxLayout.Y_AXIS));
        nodesTable = new JTable();
        nodesModel = new ClusterNodesSummaryModel();
        nodesTable.setModel(nodesModel);
        JLabel nodesTableTitle = new JLabel("Nodes status");
        nodesTableTitle.setAlignmentX(JLabel.CENTER_ALIGNMENT);
        nodesTableTitle.setFont(new Font("Dialog", Font.BOLD, 14));
        intermediaryPanel.add(Box.createVerticalStrut(5));
        intermediaryPanel.add(nodesTableTitle);
        intermediaryPanel.add(Box.createVerticalStrut(10));
        intermediaryPanel.add(nodesTable.getTableHeader());
        intermediaryPanel.add(nodesTable);
        intermediaryPanel.add(Box.createVerticalStrut(10));
        intermediaryPanel.add(new JSeparator(JSeparator.HORIZONTAL));
        jPanel1.add(Box.createHorizontalGlue());
        jPanel1.add(intermediaryPanel);
        jPanel1.add(Box.createHorizontalGlue());
        LoggingManager.log(Level.FINER, LoggingManager.RESOURCESTOOL, this.getClass().getName(), "getJPanel1",
                "Cluster nodes summary table added");
    }
    return jPanel1;
}

From source file:view.ResultsPanel.java

public void displayFrame(final List<ElementaryMode> modes, final List<Integer> indices) {

    this.removeAll();

    DefaultTableModel model = (DefaultTableModel) modeTable.getModel();

    while (model.getRowCount() > 0) {
        model.removeRow(0);/*from  w ww .java 2 s.c o  m*/
    }

    if (modes.size() > 0) {
        setTable(0, modes);
    }
    JLabel nbMod = new JLabel(modes.size() + " mode(s) found");

    toolbar = new JToolBar();
    // set elements in the toolbar
    toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.LINE_AXIS));
    toolbar.add(nbMod);
    toolbar.setFloatable(false);

    Object[] comboElements = new Object[modes.size()];

    for (int i = 0; i < modes.size(); i++) {

        comboElements[i] = "mode " + indices.get(i);
    }

    modesCombo = new JComboBox(comboElements);

    if (modesCombo.getActionListeners().length > 0) {
        modesCombo.removeActionListener(modesCombo.getActionListeners()[0]);
    }
    modesCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setTable(modesCombo.getSelectedIndex(), modes);
        }
    });

    if (modes.size() > 0) {
        toolbar.add(modesCombo);
    }
    modesCombo.setMaximumSize(new Dimension(100, 30));

    //we put the right size for le comboBox
    int sizeMax = String.valueOf(modes.size()).length();

    String stringMax = "mode ";
    for (int i = 0; i < sizeMax; i++) {
        stringMax += "X";
    }

    modesCombo.setPrototypeDisplayValue(stringMax);

    if (download.getActionListeners().length > 0) {
        download.removeActionListener(download.getActionListeners()[0]);
    }
    download.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            Thread thread = new DownloadContentThread(modes, controler, command, log.getText());
            thread.start();

        }
    });

    if (histoButton.getActionListeners().length > 0) {
        histoButton.removeActionListener(histoButton.getActionListeners()[0]);
    }
    histoButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            showHistogram(modes);

        }

    });

    toolbar.add(histoButton);
    toolbar.add(filterButton);
    toolbar.add(download);
    toolbar.add(scriptButton);
    if (!isAttached) {
        toolbar.add(addToProject);
    } else {
        toolbar.add(removeFromProject);
    }

    toolbar.add(Box.createHorizontalGlue());
    toolbar.add(searchField);
    toolbar.add(new JLabel(Var.iconsearch));

    JPanel logPanel = new JPanel(new BorderLayout());

    logPanel.add(new JLabel("Generetad log", JLabel.CENTER), BorderLayout.PAGE_START);
    logPanel.add(new JScrollPane(log), BorderLayout.CENTER);

    this.setLayout(new BorderLayout());

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(modeTable), logPanel);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(500);

    add(toolbar, BorderLayout.PAGE_START);
    this.add(splitPane, BorderLayout.CENTER);

    this.revalidate();
    this.repaint();
}