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:be.ac.ua.comp.scarletnebula.gui.windows.LinkUnlinkWindow.java

private JPanel getBottomPanel() {
    final JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS));
    bottomPanel.add(Box.createHorizontalGlue());
    final JButton cancelButton = ButtonFactory.createCancelButton();
    cancelButton.addActionListener(new ActionListener() {
        @Override//  www  .  j a va  2  s  .  c o  m
        public void actionPerformed(final ActionEvent e) {
            LinkUnlinkWindow.this.dispose();
        }
    });

    bottomPanel.add(cancelButton);
    bottomPanel.add(Box.createHorizontalStrut(10));
    final JButton okButton = ButtonFactory.createOkButton();
    okButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            actuallyLinkUnlink();
            LinkUnlinkWindow.this.dispose();
        }
    });

    bottomPanel.add(okButton);
    bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 20, 20));
    return bottomPanel;
}

From source file:sample.fa.ScriptRunnerApplication.java

void createGUI() {
    Box buttonBox = Box.createHorizontalBox();

    JButton loadButton = new JButton("Load");
    loadButton.addActionListener(this::loadScript);
    buttonBox.add(loadButton);//from w w w. j  av  a  2  s  .  c om

    JButton saveButton = new JButton("Save");
    saveButton.addActionListener(this::saveScript);
    buttonBox.add(saveButton);

    JButton executeButton = new JButton("Execute");
    executeButton.addActionListener(this::executeScript);
    buttonBox.add(executeButton);

    languagesModel = new DefaultComboBoxModel();

    ScriptEngineManager sem = new ScriptEngineManager();
    for (ScriptEngineFactory sef : sem.getEngineFactories()) {
        languagesModel.addElement(sef.getScriptEngine());
    }

    JComboBox<ScriptEngine> languagesCombo = new JComboBox<>(languagesModel);
    JLabel languageLabel = new JLabel();
    languagesCombo.setRenderer((JList<? extends ScriptEngine> list, ScriptEngine se, int index,
            boolean isSelected, boolean cellHasFocus) -> {
        ScriptEngineFactory sef = se.getFactory();
        languageLabel.setText(sef.getEngineName() + " - " + sef.getLanguageName() + " (*."
                + String.join(", *.", sef.getExtensions()) + ")");
        return languageLabel;
    });
    buttonBox.add(Box.createHorizontalGlue());
    buttonBox.add(languagesCombo);

    scriptContents = new JTextArea();
    scriptContents.setRows(8);
    scriptContents.setColumns(40);

    scriptResults = new JTextArea();
    scriptResults.setEditable(false);
    scriptResults.setRows(8);
    scriptResults.setColumns(40);

    JSplitPane jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scriptContents, scriptResults);

    JFrame frame = new JFrame("Script Runner");
    frame.add(buttonBox, BorderLayout.NORTH);
    frame.add(jsp, BorderLayout.CENTER);

    frame.pack();
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    frame.setVisible(true);
}

From source file:sanger.team16.gui.genevar.eqtl.query.SNPGeneAssocPlot.java

public SNPGeneAssocPlot(List<Tuple> tuples, double max, double min) throws ArrayIndexOutOfBoundsException {
    JPanel mainPanel = new JPanel(new GridLayout(0, 3));
    mainPanel.setBackground(Color.white);

    int size = tuples.size();
    for (int i = 0; i < size; i++) {
        Tuple tuple = tuples.get(i);/*from ww  w.ja  v a 2s .c om*/
        String populationName = tuple.populationName;

        // if (trait.expressionRanks != null) {   // BUG FIXED 02/02/10
        if (tuple.phenotypes != null && tuple.phenotypes.length != 0) {
            CategoryDataset dataset = this.createDataset(tuple);
            JFreeChart chart = createChart(populationName, dataset, max, min);
            chart.setBackgroundPaint(Color.white);

            TextTitle textTitle = new TextTitle(tuple.subtitle);
            textTitle.setFont(new Font("SansSerif", Font.PLAIN, 12));
            //subtitle1.setPosition(RectangleEdge.BOTTOM);
            textTitle.setHorizontalAlignment(HorizontalAlignment.CENTER);
            chart.addSubtitle(textTitle);

            ChartPanel chartPanel = new ChartPanel(chart);
            chartPanel.setPreferredSize(this.getAutoPreferredSize()); // Original Dimension(680, 420)
            mainPanel.add(chartPanel);

        } else {
            BaseJPane empty = new BaseJPane(2, 50, 0, 0);
            empty.setPreferredSize(this.getAutoPreferredSize());
            BaseJPane na = new BaseJPane();
            na.setLayout(new BorderLayout());

            JLabel name = new JLabel("      " + populationName);
            name.setFont(new Font("Arial", Font.BOLD, 12));
            name.setForeground(Color.gray);
            na.add(name, BorderLayout.PAGE_START);

            JLabel message = new JLabel("Not Available");
            message.setForeground(Color.lightGray);
            na.add(message, BorderLayout.CENTER);

            empty.add(Box.createHorizontalGlue());
            empty.add(na);
            empty.add(Box.createHorizontalGlue());
            empty.setBaseSpringBox();

            mainPanel.add(empty);
        }
    }

    this.add(mainPanel);
}

From source file:uk.nhs.cfh.dsp.srth.desktop.modules.resultexplanationpanel.QueryStatisticsCollectionPanel.java

/**
 * Inits the components.//from  w w w .j a va 2  s.  c  om
 */
public synchronized void initComponents() {

    resultCountLabel = new JXLabel(
            "<html><b>Number of patients satisfying criteria in the query : </b></html>");
    resultCountLabel.setHorizontalTextPosition(SwingConstants.LEFT);
    queryTimeLabel = new JXLabel("<html><b>Time taken to return results for query : </b></html>");
    queryTimeLabel.setHorizontalTextPosition(SwingConstants.LEFT);

    // create panels and add labels
    JPanel countPanel = new JPanel();
    countPanel.setLayout(new BoxLayout(countPanel, BoxLayout.LINE_AXIS));
    countPanel.add(resultCountLabel);
    countPanel.add(Box.createHorizontalGlue());
    JPanel timePanel = new JPanel();
    timePanel.setLayout(new BoxLayout(timePanel, BoxLayout.LINE_AXIS));
    timePanel.add(Box.createHorizontalGlue());
    timePanel.add(queryTimeLabel);
    JPanel labelsPanel = new JPanel();
    labelsPanel.setLayout(new BoxLayout(labelsPanel, BoxLayout.PAGE_AXIS));
    labelsPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    labelsPanel.add(countPanel);
    labelsPanel.add(timePanel);
    // add empty panel for spacing
    labelsPanel.add(new JXLabel(" "));

    JPanel humanReadableLabelPanel = new JPanel(new BorderLayout());
    humanReadableLabelPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(),
            BorderFactory.createTitledBorder("Query Text")));
    humanReadableLabel = new JXLabel();
    humanReadableLabel.setLineWrap(true);
    humanReadableLabelPanel.add(humanReadableLabel, BorderLayout.CENTER);

    JPanel upperPanel = new JPanel(new BorderLayout());
    upperPanel.add(humanReadableLabelPanel, BorderLayout.CENTER);
    upperPanel.add(labelsPanel, BorderLayout.SOUTH);

    commentedStepsTextArea = new JTextArea();
    commentedStepsTextArea.setLineWrap(true);
    commentedStepsTextArea.setEditable(false);
    commentedStepsTextArea.setWrapStyleWord(true);
    // create panel for comments text area
    JPanel commentsPanel = createStatementsPanel(commentedStepsTextArea, "SQL Steps");

    sqlStatementsTextArea = new JTextArea();
    sqlStatementsTextArea.setLineWrap(true);
    sqlStatementsTextArea.setEditable(false);
    sqlStatementsTextArea.setWrapStyleWord(true);
    // create panel for sql statements
    JPanel sqlPanel = createStatementsPanel(sqlStatementsTextArea, "SQL Statements");

    // create a tabbed pane to contain the statements panels
    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.addTab("Steps", null, commentsPanel, "Commented steps executed in generating the result");
    tabbedPane.addTab("SQL", null, sqlPanel, "SQL Statements used in generating the result");

    // add components to this panel
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder());
    setPreferredSize(new Dimension(550, 450));
    add(upperPanel, BorderLayout.NORTH);
    add(tabbedPane, BorderLayout.CENTER);
}

From source file:medsavant.enrichment.app.RegionListAggregatePanel.java

public RegionListAggregatePanel(String page) {
    super(page);//  w w  w.  ja  v a2  s .  c o  m
    setLayout(new BorderLayout());

    variantCounts = new TreeMap<GenomicRegion, Integer>();
    patientCounts = new TreeMap<GenomicRegion, Integer>();

    regionSetCombo = new JComboBox();

    mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());

    progress = new JProgressBar();
    progress.setStringPainted(true);

    JPanel banner = new JPanel();
    banner.setLayout(new BoxLayout(banner, BoxLayout.X_AXIS));

    banner.setBackground(new Color(245, 245, 245));
    banner.setBorder(BorderFactory.createTitledBorder("Region List"));

    banner.add(regionSetCombo);
    banner.add(ViewUtil.getMediumSeparator());
    banner.add(Box.createHorizontalGlue());
    banner.add(progress);

    add(banner, BorderLayout.NORTH);
    add(mainPanel, BorderLayout.CENTER);

    createSearchableTable();

    regionSetCombo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            fetchRegions((RegionSet) regionSetCombo.getSelectedItem());
        }
    });

    new MedSavantWorker<List<RegionSet>>(pageName) {
        @Override
        protected List<RegionSet> doInBackground() throws Exception {
            return RegionController.getInstance().getRegionSets();
        }

        @Override
        protected void showProgress(double fraction) {
        }

        @Override
        protected void showSuccess(List<RegionSet> result) {
            if (!result.isEmpty()) {
                updateRegionSetCombo(result);
            }
        }
    }.execute();
}

From source file:pcgen.gui2.tabs.bio.CampaignHistoryInfoPane.java

private void initComponents() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    addButton.setText("Add Next Chronicle");
    addButton.setActionCommand(ADD_COMMAND);
    allButton.setText("All");
    allButton.setActionCommand(ALL_COMMAND);
    noneButton.setText("None");
    noneButton.setActionCommand(NONE_COMMAND);

    Box hbox = Box.createHorizontalBox();
    hbox.add(Box.createRigidArea(new Dimension(5, 0)));
    hbox.add(new JLabel("Check an item to include on your Character Sheet"));
    hbox.add(Box.createRigidArea(new Dimension(5, 0)));
    hbox.add(allButton);// w  w w . j a  v  a 2 s  . c om
    hbox.add(Box.createRigidArea(new Dimension(3, 0)));
    hbox.add(noneButton);
    hbox.add(Box.createHorizontalGlue());

    add(Box.createVerticalStrut(5));
    add(hbox);
    add(Box.createVerticalStrut(10));
    JScrollPane pane = new JScrollPane(chroniclesPane) {

        @Override
        public Dimension getMaximumSize() {
            Dimension size = getPreferredSize();
            size.width = Integer.MAX_VALUE;
            return size;
        }

        @Override
        public boolean isValidateRoot() {
            return false;
        }

    };
    pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    add(pane);
    add(Box.createVerticalStrut(10));
    addButton.setAlignmentX(0.5f);
    add(addButton);
    add(Box.createVerticalStrut(5));
    add(Box.createVerticalGlue());
}

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

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

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

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

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

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

}

From source file:org.ciscavate.cjwizard.WizardContainer.java

/**
 * /*  w w  w  .ja  va 2  s.co m*/
 */
private void initComponents() {
    final JButton prevBtn = new JButton(_prevAction);
    final JButton nextBtn = new JButton(_nextAction);
    final JButton finishBtn = new JButton(_finishAction);
    final JButton cancelBtn = new JButton(_cancelAction);

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
    buttonPanel.add(Box.createHorizontalGlue());
    buttonPanel.add(prevBtn);
    buttonPanel.add(Box.createHorizontalStrut(5));
    buttonPanel.add(nextBtn);
    buttonPanel.add(Box.createHorizontalStrut(10));
    buttonPanel.add(finishBtn);
    buttonPanel.add(Box.createHorizontalStrut(10));
    buttonPanel.add(cancelBtn);

    buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15));
    this.setLayout(new BorderLayout());

    this.add(_template, BorderLayout.CENTER);
    this.add(buttonPanel, BorderLayout.SOUTH);
}

From source file:org.ut.biolab.medsavant.client.view.app.builtin.settings.ServerLogPage.java

@Override
public JPanel getView() {
    if (view == null) {
        view = new JPanel();
        view.setLayout(new BorderLayout());

        menuPanel = new JPanel();
        ViewUtil.applyHorizontalBoxLayout(menuPanel);

        listPanel = new JPanel();
        listPanel.setLayout(new CardLayout());

        listPanel.add(getWaitPanel(), CARDNAME_WAIT);
        listPanel.add(getClientCard(), CARDNAME_SERVER);

        view.add(menuPanel, BorderLayout.NORTH);
        view.add(listPanel, BorderLayout.CENTER);

        changeToCard(CARDNAME_SERVER);/*from w w  w  . j  a  v  a 2  s . c o m*/

        JButton refreshButton = new JButton("Refresh");
        refreshButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                refreshCurrentCard();
            }
        });

        menuPanel.add(Box.createHorizontalGlue());
        menuPanel.add(refreshButton);
        menuPanel.add(Box.createHorizontalGlue());
    }
    return view;
}

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

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

    this.backgroundRunner = br;
    this.onChoice = onSheetChosen;
    sheetComboBox.addActionListener(new ActionListener() {
        @Override//from  w  w  w.j av  a2s.  c om
        public void actionPerformed(ActionEvent e) {
            Object item = sheetComboBox.getSelectedItem();
            if (item == null) {
                selectedSheetName = null;
            } else {
                selectedSheetName = sheetComboBox.getSelectedItem().toString();
            }
            updateUsingSelected();
        }
    });
    spinnerModel.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            updateUsingSelected();
        }
    });

    GuiUtil.setVisibleRowCount(dataPreviewTable, DEFAULT_VISIBLE_ROWCOUNT);

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

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

    useAction.setEnabled(false);
}