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:de.mpg.mpi_inf.bioinf.netanalyzer.ui.SaveChartDialog.java

/**
 * Creates and lays out the controls inside this dialog's content pane.
 * <p>//from   ww  w.ja va 2 s . com
 * This method is called upon initialization only.
 * </p>
 */
private void initControls() {
    JPanel sizePanel = new JPanel(new GridLayout(2, 3, 4, 4));
    sizePanel.setBorder(BorderFactory.createTitledBorder(Messages.DI_IMAGESIZE));

    // Add a spinner for choosing width
    sizePanel.add(new JLabel(Messages.DI_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(Messages.DI_PIXELS));

    // Add a spinner for choosing height
    sizePanel.add(new JLabel(Messages.DI_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(Messages.DI_PIXELS));

    // Add Save and Cancel buttons
    JPanel buttons = new JPanel(new GridLayout(1, 2, 4, 0));
    buttons.add(btnSave = Utils.createButton(Messages.DI_SAVE, null, this));
    buttons.add(btnCancel = Utils.createButton(Messages.DI_CANCEL, null, this));
    Box buttonsBox = Box.createHorizontalBox();
    buttonsBox.add(Box.createHorizontalGlue());
    buttonsBox.add(buttons);
    buttonsBox.add(Box.createHorizontalGlue());

    Container contentPane = getContentPane();
    contentPane.add(sizePanel, BorderLayout.NORTH);
    contentPane.add(Box.createVerticalStrut(Utils.BORDER_SIZE / 2));
    contentPane.add(buttonsBox, BorderLayout.PAGE_END);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    Utils.setStandardBorder(getRootPane());
}

From source file:visolate.Visolate.java

private Box getTopologyAndToolpathsBox() {
    Box topologyAndToolpathsBox = Box.createHorizontalBox();
    topologyAndToolpathsBox.add(getTopologyBox());
    topologyAndToolpathsBox.add(Box.createHorizontalGlue());
    topologyAndToolpathsBox.add(getToolpathBox());
    return topologyAndToolpathsBox;
}

From source file:org.obiba.onyx.jade.instrument.summitdoppler.VantageABIInstrumentRunner.java

/**
 * Build action buttons sub panel/*w w  w .ja  va2s .co m*/
 */
protected JPanel buildActionButtonSubPanel() {

    // Add the action buttons sub panel.
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));

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

    // 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:xtrememp.PlaylistManager.java

private void initComponents() {
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);//from  w w w. ja v a 2 s  . c  om
    openPlaylistButton = new JButton(Utilities.DOCUMENT_OPEN_ICON);
    openPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.OpenPlaylist"));
    openPlaylistButton.addActionListener(this);
    toolBar.add(openPlaylistButton);
    savePlaylistButton = new JButton(Utilities.DOCUMENT_SAVE_ICON);
    savePlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.SavePlaylist"));
    savePlaylistButton.addActionListener(this);
    toolBar.add(savePlaylistButton);
    toolBar.addSeparator();
    addToPlaylistButton = new JButton(Utilities.LIST_ADD_ICON);
    addToPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.AddToPlaylist"));
    addToPlaylistButton.addActionListener(this);
    toolBar.add(addToPlaylistButton);
    remFromPlaylistButton = new JButton(Utilities.LIST_REMOVE_ICON);
    remFromPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.RemoveFromPlaylist"));
    remFromPlaylistButton.addActionListener(this);
    remFromPlaylistButton.setEnabled(false);
    toolBar.add(remFromPlaylistButton);
    clearPlaylistButton = new JButton(Utilities.EDIT_CLEAR_ICON);
    clearPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.ClearPlaylist"));
    clearPlaylistButton.addActionListener(this);
    clearPlaylistButton.setEnabled(false);
    toolBar.add(clearPlaylistButton);
    toolBar.addSeparator();
    moveUpButton = new JButton(Utilities.GO_UP_ICON);
    moveUpButton.setToolTipText(tr("MainFrame.PlaylistManager.MoveUp"));
    moveUpButton.addActionListener(this);
    moveUpButton.setEnabled(false);
    toolBar.add(moveUpButton);
    moveDownButton = new JButton(Utilities.GO_DOWN_ICON);
    moveDownButton.setToolTipText(tr("MainFrame.PlaylistManager.MoveDown"));
    moveDownButton.addActionListener(this);
    moveDownButton.setEnabled(false);
    toolBar.add(moveDownButton);
    toolBar.addSeparator();
    mediaInfoButton = new JButton(Utilities.MEDIA_INFO_ICON);
    mediaInfoButton.setToolTipText(tr("MainFrame.PlaylistManager.MediaInfo"));
    mediaInfoButton.addActionListener(this);
    mediaInfoButton.setEnabled(false);
    toolBar.add(mediaInfoButton);
    toolBar.add(Box.createHorizontalGlue());
    searchTextField = new SearchTextField(15);
    searchTextField.setMaximumSize(new Dimension(120, searchTextField.getPreferredSize().height));
    searchTextField.getTextField().getDocument().addDocumentListener(new SearchFilterListener());
    toolBar.add(searchTextField);
    toolBar.add(Box.createHorizontalStrut(6));
    this.add(toolBar, BorderLayout.NORTH);

    playlistTable = new JTable(playlistTableModel, playlistTableColumnModel);
    playlistTable.setDefaultRenderer(String.class, new PlaylistCellRenderer());
    playlistTable.setActionMap(null);

    playlistTable.getTableHeader().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent ev) {
            if (SwingUtilities.isRightMouseButton(ev)
                    || (MouseInfo.getNumberOfButtons() == 1 && ev.isControlDown())) {
                playlistTableColumnModel.getPopupMenu().show(playlistTable.getTableHeader(), ev.getX(),
                        ev.getY());
                return;
            }

            int clickedColumn = playlistTableColumnModel.getColumnIndexAtX(ev.getX());
            PlaylistTableColumn playlistColumn = playlistTableColumnModel.getColumn(clickedColumn);
            playlistTableColumnModel.resetAll(playlistColumn.getModelIndex());
            playlistColumn.setSortOrderUp(!playlistColumn.isSortOrderUp());
            playlistTableModel.sort(playlistColumn.getComparator());

            colorizeRow();
        }
    });
    playlistTable.setFillsViewportHeight(true);
    playlistTable.setShowGrid(false);
    playlistTable.setRowSelectionAllowed(true);
    playlistTable.setColumnSelectionAllowed(false);
    playlistTable.setDragEnabled(false);
    playlistTable.setFont(playlistTable.getFont().deriveFont(Font.BOLD));
    playlistTable.setIntercellSpacing(new Dimension(0, 0));
    playlistTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    playlistTable.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent ev) {
            int selectedRow = playlistTable.rowAtPoint(ev.getPoint());
            if (SwingUtilities.isLeftMouseButton(ev) && ev.getClickCount() == 2) {
                if (selectedRow != -1) {
                    playlist.setCursorPosition(selectedRow);
                    controlListener.acOpenAndPlay();
                }
            }
        }
    });
    playlistTable.getSelectionModel().addListSelectionListener(this);
    playlistTable.getColumnModel().getSelectionModel().addListSelectionListener(this);
    playlistTable.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            // View Media Info
            if (e.getKeyCode() == KeyEvent.VK_I && e.getModifiers() == KeyEvent.CTRL_MASK) {
                viewMediaInfo();
            } // Select all
            else if (e.getKeyCode() == KeyEvent.VK_A && e.getModifiers() == KeyEvent.CTRL_MASK) {
                playlistTable.selectAll();
            } else if (e.getKeyCode() == KeyEvent.VK_UP) {
                // Move selected track(s) up
                if (e.getModifiers() == KeyEvent.ALT_MASK) {
                    moveUp();
                } // Select previous track
                else {
                    if (playlistTable.getSelectedRow() > 0) {
                        int previousRowIndex = playlistTable.getSelectedRow() - 1;
                        playlistTable.clearSelection();
                        playlistTable.addRowSelectionInterval(previousRowIndex, previousRowIndex);
                        makeRowVisible(previousRowIndex);
                    }
                }
            } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                // Move selected track(s) down
                if (e.getModifiers() == KeyEvent.ALT_MASK) {
                    moveDown();
                } // Select next track
                else {
                    if (playlistTable.getSelectedRow() < playlistTable.getRowCount() - 1) {
                        int nextRowIndex = playlistTable.getSelectedRow() + 1;
                        playlistTable.clearSelection();
                        playlistTable.addRowSelectionInterval(nextRowIndex, nextRowIndex);
                        makeRowVisible(nextRowIndex);
                    }
                }
            } // Play selected track
            else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                int selectedRow = playlistTable.getSelectedRow();
                if (selectedRow != -1) {
                    playlist.setCursorPosition(selectedRow);
                    controlListener.acOpenAndPlay();
                }
            } // Add new tracks
            else if (e.getKeyCode() == KeyEvent.VK_INSERT) {
                addFilesDialog(false);
            } // Delete selected tracks
            else if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                remove();
            }
        }
    });
    XtremeMP.getInstance().getMainFrame().setDropTarget(new DropTarget(playlistTable, this));
    JScrollPane ptScrollPane = new JScrollPane(playlistTable);
    ptScrollPane.setActionMap(null);
    this.add(ptScrollPane, BorderLayout.CENTER);
}

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

private void addCapa(final GpxLayer layer) {
    final JPanel capaP = new JPanel();
    capaP.setOpaque(false);//  w w  w  .ja  v a 2s.co m
    layer.visible = true;
    mapView.addLayer(layer, false, capasActuales.size());
    capasActuales.add(layer);
    capaP.setLayout(new BoxLayout(capaP, BoxLayout.X_AXIS));

    final JCheckBox capa = new JCheckBox(layer.getAssociatedFile().getAbsolutePath());
    capa.setSelected(layer.visible);
    capa.setBackground(Color.WHITE);
    capa.setToolTipText(i18n.getString("window.gpx.checkbox.show.tooltip"));
    capa.setActionCommand(layer.name);
    capa.addActionListener(this);
    capaP.add(capa);
    capaP.add(Box.createHorizontalGlue());
    JButton eliminar = new JButton(LogicConstants.getIcon("button_delone"));
    eliminar.setToolTipText(i18n.getString("window.gpx.button.delete.tooltip"));
    eliminar.setBorderPainted(false);
    eliminar.setContentAreaFilled(false);

    capaP.add(eliminar);
    eliminar.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            mapView.removeLayer(layer);
            mapView.repaint();
            capasGpx.remove(capaP);
            capasGpx.updateUI();
            capasActuales.remove(layer);
        }
    });

    capasGpx.add(capaP);
    capasGpx.updateUI();
}

From source file:ch.zhaw.ias.dito.ui.AnalysisPanel.java

private JPanel createDecompositionPanel(String title, double[][] mdsValues) {
    JFreeChart chart = ChartFactory.createScatterPlot(title, null, null, new MdsXYDataset(mdsValues),
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.getRenderer().setBaseToolTipGenerator(new XYToolTipGenerator() {
        @Override/*from   www. j  a v  a2 s  . co m*/
        public String generateToolTip(XYDataset dataset, int series, int item) {
            return "item #" + (item + 1);
        }
    });

    JPanel mdsPanel = new JPanel(new BorderLayout(0, 10));
    mdsPanel.add(new ChartPanel(chart), BorderLayout.CENTER);
    dimensionsCombo = new JComboBox(new Integer[] { 2, 3 });
    JButton exportButton = new JButton(Translation.INSTANCE.get("s4.bu.exportDecomposition"));
    exportButton.addActionListener(this);
    JPanel mdsInputPanel = new JPanel();
    mdsInputPanel.setLayout(new BoxLayout(mdsInputPanel, BoxLayout.LINE_AXIS));
    mdsInputPanel.add(Box.createHorizontalGlue());
    mdsInputPanel.add(Box.createHorizontalGlue());
    mdsInputPanel.add(new JLabel(Translation.INSTANCE.get("s4.lb.dimension")));
    mdsInputPanel.add(Box.createHorizontalStrut(10));
    mdsInputPanel.add(dimensionsCombo);
    mdsInputPanel.add(Box.createHorizontalStrut(10));
    mdsInputPanel.add(exportButton);
    mdsPanel.add(mdsInputPanel, BorderLayout.SOUTH);

    return mdsPanel;
}

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

private JPanel getHeaderPanel(UserComment lc) {
    JPanel headerPanel = new JPanel();
    headerPanel.setLayout(new BoxLayout(headerPanel, BoxLayout.Y_AXIS));
    JPanel leftJustPanel = new JPanel();
    leftJustPanel.setLayout(new BoxLayout(leftJustPanel, BoxLayout.X_AXIS));
    leftJustPanel.add(new JLabel("Posted " + lc.getModificationDate().toString() + " by: "));
    leftJustPanel.add(Box.createHorizontalGlue());
    headerPanel.add(leftJustPanel);//from   w  ww . j  av  a 2s .co m

    leftJustPanel = new JPanel();
    leftJustPanel.setLayout(new BoxLayout(leftJustPanel, BoxLayout.X_AXIS));
    leftJustPanel.add(new JLabel(lc.getUser()));
    leftJustPanel.add(Box.createHorizontalGlue());
    headerPanel.add(leftJustPanel);
    headerPanel.add(Box.createHorizontalGlue());
    return headerPanel;
}

From source file:org.jdal.swing.form.FormUtils.java

/**
 * Create a box with an aligned component using Component constants for right, center and left.
 * @param c component/*from ww  w.j a v a 2  s  .c o m*/
 * @param alignment aligment.
 * @return Box with compoenent
 */
public static Component newBoxForComponent(Component c, float alignment) {
    Box box = Box.createHorizontalBox();
    if (Component.RIGHT_ALIGNMENT == alignment) {
        box.add(Box.createHorizontalGlue());
        box.add(c);
    } else if (Component.CENTER_ALIGNMENT == alignment) {
        box.add(Box.createHorizontalGlue());
        box.add(c);
        box.add(Box.createHorizontalGlue());
    } else {
        // default to left
        box.add(c);
        box.add(Box.createHorizontalGlue());
    }

    return box;
}

From source file:uk.nhs.cfh.dsp.yasb.expression.builder.RefinedExpressionBuilderPanel.java

/**
 * Inits the components.//  ww w  .  j av  a2  s  .  c  o  m
 */
public synchronized void initComponents() {

    // generate and store concept corresponding to Side |182353008|
    if (terminologyConceptDAO != null) {
        lateralityParentConcept = TerminologyConceptUtils.getConceptForID(terminologyConceptDAO, "182353008");
    }

    // add a collapsible panel in NORTH position with a concept search panel
    searchPanel = new SearchPanel(terminologySearchService, selectionService, applicationService,
            terminologyConceptDAO);
    searchPanel.initComponents();
    searchPanel.setPreferredSize(new Dimension(350, 450));
    collapsiblePane = new JXCollapsiblePane(new BorderLayout());
    collapsiblePane.add(searchPanel, BorderLayout.CENTER);
    collapsiblePane.setCollapsed(true);

    // create panel for rendering label
    renderingLabel = new ExpressionRenderingLabel(humanReadableRender);
    renderingLabel.initComponents();

    focusConceptPanel = new ConceptPanel(humanReadableRender);
    focusConceptPanel.initComponents();

    // create top panel with some instructions
    JPanel p1 = new JPanel();
    p1.setLayout(new BoxLayout(p1, BoxLayout.LINE_AXIS));
    p1.add(focusConceptPanel);

    // add button for editing focus concept
    JideButton editFocusConceptButton = new JideButton(new AbstractAction("Edit") {
        public void actionPerformed(ActionEvent e) {
            if (collapsiblePane.isCollapsed()) {
                collapsiblePane.setCollapsed(false);
            } else {
                collapsiblePane.setCollapsed(true);
            }
        }
    });
    p1.add(Box.createHorizontalGlue());
    p1.add(editFocusConceptButton);

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.PAGE_AXIS));
    topPanel.add(renderingLabel);
    topPanel.add(p1);

    // create scrollPane that contains the properties
    propertyExpressionListModel = new PropertyExpressionListModel(normalFormGenerator);
    propertiesList = new JXList(propertyExpressionListModel);
    //        propertiesList.setCellRenderer(new PropertyExpressionListCellRenderer(selectionService,
    //                terminologyConceptDAO, applicationService, humanReadableRender));
    propertiesList.setCellRenderer(new ExpressionListCellRenderer(selectionService, terminologyConceptDAO,
            applicationService, humanReadableRender));
    propertiesScrollPane = new JScrollPane();
    propertiesScrollPane.setViewportView(propertiesList);

    //        // add mouse listeners to tree
    //        propertiesList.addMouseListener(new MouseAdapter() {
    //
    //            @Override
    //            public void mouseClicked(MouseEvent e) {
    //                int row = propertiesList.getSelectedIndex();
    //                if(row > -1 && e.getClickCount() == 2)
    //                {
    //                    // get selection
    //                    Object selection = propertiesList.getSelectedValue();
    //
    //                    // evaluate selection and set behaviour
    //                    if(selection instanceof SnomedRelationshipPropertyExpression)
    //                    {
    //                        SnomedRelationshipPropertyExpression propertyExpression =
    //                                (SnomedRelationshipPropertyExpression) selection;
    //                        // get contained relationship
    //                        SnomedRelationship relationship = propertyExpression.getRelationship();
    //                        if(relationship != null)
    //                        {
    //                            // set as selected propertyExpression
    //                            selectedPropertyExpression = propertyExpression;
    //                            // set as active relationship
    //                            activeRelationship = relationship;
    //                        }
    //                    }
    //                }
    //            }
    //        });

    // create laterality hierarchy panel
    createLateralityConceptHierarchyDialog();

    // add panel for adding laterality directly
    JPanel bottomPanel = new JPanel(new BorderLayout());
    // add label and button for laterilty value
    lateralityLabel = new JLabel();
    JButton editLateralityButton = new JButton(new AbstractAction("Edit") {
        public void actionPerformed(ActionEvent e) {
            /*
             get lateralityHierarchyPanel and set parent to
             Side |182353008|
            */

            lateralityHierarchyPanel.setConcept(lateralityParentConcept);
            // show conceptHierarchyDialog
            conceptHierarchyDialog.setLocationRelativeTo(activeFrame);
            conceptHierarchyDialog.setVisible(true);
        }
    });
    bottomPanel.add(new JLabel("<html><b>Laterality of concept </b></html>"), BorderLayout.WEST);
    bottomPanel.add(lateralityLabel, BorderLayout.CENTER);
    bottomPanel.add(editLateralityButton, BorderLayout.EAST);

    // add panels to this panel and main panel
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(topPanel, BorderLayout.NORTH);
    mainPanel.add(propertiesScrollPane, BorderLayout.CENTER);

    // add to this panel
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(borderOffset, borderOffset, borderOffset, borderOffset));
    add(collapsiblePane, BorderLayout.NORTH);
    add(mainPanel, BorderLayout.CENTER);
    add(bottomPanel, BorderLayout.SOUTH);
}

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

protected void addString(String texto, String label) {
    rows++;//from   w w  w  .  j  av  a  2s  . c o  m
    mid.add(new JLabel(i18n.getString(label), JLabel.RIGHT));
    JTextField jtextField = new JTextField(texto);
    jtextField.setEditable(true);
    jtextField.setName(label);
    mid.add(jtextField);
    componentes.add(jtextField);
    for (int i = 2; i < cols; i++)
        mid.add(Box.createHorizontalGlue());
}