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.ServerPropertiesWindow.java

private JPanel getBottomPanel() {
    final JPanel bottomPanel = new JPanel();
    final JButton okButton = ButtonFactory.createOkButton();
    okButton.addActionListener(new ActionListener() {
        @Override/*w ww  . ja v  a2  s .  c  om*/
        public void actionPerformed(final ActionEvent e) {
            ServerPropertiesWindow.this.dispose();
        }
    });

    getRootPane().setDefaultButton(okButton);

    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.LINE_AXIS));
    bottomPanel.add(Box.createHorizontalGlue());
    bottomPanel.add(okButton);
    bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 20, 20));
    return bottomPanel;
}

From source file:fll.scheduler.ChooseChallengeDescriptor.java

private void initComponents() {
    getContentPane().setLayout(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1;//from w ww  . ja va 2 s .  c o m
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.BOTH;
    final JTextArea instructions = new JTextArea(
            "Choose a challenge description from the drop down list OR choose a file containing your custom challenge description.",
            3, 40);
    instructions.setEditable(false);
    instructions.setWrapStyleWord(true);
    instructions.setLineWrap(true);
    getContentPane().add(instructions, gbc);

    gbc = new GridBagConstraints();
    mCombo = new JComboBox<DescriptionInfo>();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    getContentPane().add(mCombo, gbc);
    mCombo.setRenderer(new DescriptionInfoRenderer());
    mCombo.setEditable(false);
    final List<DescriptionInfo> descriptions = DescriptionInfo.getAllKnownChallengeDescriptionInfo();
    for (final DescriptionInfo info : descriptions) {
        mCombo.addItem(info);
    }

    mFileField = new JLabel();
    gbc = new GridBagConstraints();
    gbc.weightx = 1;
    getContentPane().add(mFileField, gbc);

    final JButton chooseButton = new JButton("Choose File");
    gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    getContentPane().add(chooseButton, gbc);
    chooseButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent ae) {
            mFileField.setText(null);

            final JFileChooser fileChooser = new JFileChooser();
            final FileFilter filter = new BasicFileFilter("FLL Description (xml)", new String[] { "xml" });
            fileChooser.setFileFilter(filter);

            final int returnVal = fileChooser.showOpenDialog(ChooseChallengeDescriptor.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                final File selectedFile = fileChooser.getSelectedFile();
                mFileField.setText(selectedFile.getAbsolutePath());
            }
        }
    });

    final Box buttonPanel = new Box(BoxLayout.X_AXIS);
    gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    getContentPane().add(buttonPanel, gbc);

    buttonPanel.add(Box.createHorizontalGlue());
    final JButton ok = new JButton("Ok");
    buttonPanel.add(ok);
    ok.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent ae) {

            // use the selected description if nothing is entered in the file box
            final DescriptionInfo descriptionInfo = mCombo.getItemAt(mCombo.getSelectedIndex());
            if (null != descriptionInfo) {
                mSelected = descriptionInfo.getURL();
            }

            final String text = mFileField.getText();
            if (!StringUtils.isEmpty(text)) {
                final File file = new File(text);
                if (file.exists()) {
                    try {
                        mSelected = file.toURI().toURL();
                    } catch (final MalformedURLException e) {
                        throw new FLLInternalException("Can't turn file into URL?", e);
                    }
                }
            }

            setVisible(false);
        }
    });

    final JButton cancel = new JButton("Cancel");
    buttonPanel.add(cancel);
    cancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent ae) {
            mSelected = null;
            setVisible(false);
        }
    });

    pack();
}

From source file:org.opendatakit.briefcase.ui.ScrollingStatusListDialog.java

private ScrollingStatusListDialog(Frame frame, String title, IFormDefinition form, String statusHtml) {
    super(frame, title + form.getFormName(), true);
    this.form = form;
    AnnotationProcessor.process(this);
    // Create and initialize the buttons.
    JButton cancelButton = new JButton("Close");
    cancelButton.addActionListener(this);
    getRootPane().setDefaultButton(cancelButton);

    editorArea = new JEditorPane("text/plain", statusHtml);
    editorArea.setEditable(false);// w w w .jav  a2s.  c  o m
    //Put the editor pane in a scroll pane.
    JScrollPane editorScrollPane = new JScrollPane(editorArea);
    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPane.setPreferredSize(new Dimension(400, 300));
    editorScrollPane.setMinimumSize(new Dimension(10, 10));

    // Create a container so that we can add a title around
    // the scroll pane. Can't add a title directly to the
    // scroll pane because its background would be white.
    // Lay out the label and scroll pane from top to bottom.
    JPanel listPane = new JPanel();
    listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));
    listPane.add(Box.createRigidArea(new Dimension(0, 5)));
    listPane.add(editorScrollPane);
    listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    // Lay out the buttons from left to right.
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(cancelButton);

    // Put everything together, using the content pane's BorderLayout.
    Container contentPane = getContentPane();
    contentPane.add(listPane, BorderLayout.CENTER);
    contentPane.add(buttonPane, BorderLayout.PAGE_END);

    // Initialize values.
    pack();
    setLocationRelativeTo(null);
}

From source file:utybo.branchingstorytree.swing.editor.StoryEditor.java

public StoryEditor(BranchingStory baseStory) throws BSTException {
    setLayout(new MigLayout("hidemode 3", "[grow]", "[][grow]"));

    JToolBar toolBar = new JToolBar();
    toolBar.setBorder(null);/*  w w  w.  j  a  va2  s  .c  om*/
    toolBar.setFloatable(false);
    add(toolBar, "cell 0 0,growx");

    JButton btnSaveAs = new JButton(Lang.get("saveas"), new ImageIcon(Icons.getImage("Save As", 16)));
    btnSaveAs.addActionListener(e -> {
        saveAs();
    });
    toolBar.add(btnSaveAs);

    JButton btnSave = new JButton(Lang.get("save"), new ImageIcon(Icons.getImage("Save", 16)));
    btnSave.addActionListener(e -> {
        save();
    });
    toolBar.add(btnSave);

    JButton btnPlay = new JButton(Lang.get("play"), new ImageIcon(Icons.getImage("Circled Play", 16)));
    btnPlay.addActionListener(ev -> {
        try {
            String s = exportToString();
            File f = Files.createTempDirectory("openbst").toFile();
            File bstFile = new File(f, "expoted.bst");
            try (FileOutputStream fos = new FileOutputStream(bstFile);) {
                IOUtils.write(s, fos, StandardCharsets.UTF_8);
            }
            OpenBSTGUI.getInstance().openStory(bstFile);
        } catch (Exception e) {
            OpenBST.LOG.error("Export failed", e);
            Messagers.showException(OpenBSTGUI.getInstance(), Lang.get("editor.exportfail"), e);
        }
    });
    toolBar.add(btnPlay);

    JButton btnFilePreview = new JButton(Lang.get("editor.exportpreview"),
            new ImageIcon(Icons.getImage("PreviewText", 16)));
    btnFilePreview.addActionListener(e -> {
        try {
            String s = exportToString();
            JDialog dialog = new JDialog(OpenBSTGUI.getInstance(), Lang.get("editor.exportpreview"));
            JTextArea jta = new JTextArea(s);
            jta.setLineWrap(true);
            jta.setWrapStyleWord(true);
            dialog.add(new JScrollPane(jta));

            dialog.setModalityType(ModalityType.APPLICATION_MODAL);
            dialog.setSize((int) (Icons.getScale() * 350), (int) (Icons.getScale() * 300));
            dialog.setLocationRelativeTo(OpenBSTGUI.getInstance());
            dialog.setVisible(true);
        } catch (Exception x) {
            OpenBST.LOG.error("Failed to preview", x);
            Messagers.showException(OpenBSTGUI.getInstance(), Lang.get("editor.previewerror"), x);
        }
    });
    toolBar.add(btnFilePreview);

    Component horizontalGlue = Box.createHorizontalGlue();
    toolBar.add(horizontalGlue);

    JButton btnClose = new JButton(Lang.get("close"), new ImageIcon(Icons.getImage("Cancel", 16)));
    btnClose.addActionListener(e -> {
        askClose();
    });
    toolBar.add(btnClose);

    for (final Component component : toolBar.getComponents()) {
        if (component instanceof JButton) {
            ((JButton) component).setHideActionText(false);
            ((JButton) component).setToolTipText(((JButton) component).getText());
            ((JButton) component).setText("");
        }
    }

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.setTabPlacement(JTabbedPane.LEFT);
    add(tabbedPane, "cell 0 1,grow");

    tabbedPane.addTab("Beta Warning", new StoryEditorWelcomeScreen());

    details = new StoryDetailsEditor(this);
    tabbedPane.addTab(Lang.get("editor.details"), details);

    nodesEditor = new StoryNodesEditor();
    tabbedPane.addTab(Lang.get("editor.nodes"), nodesEditor);

    this.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("control S"),
            "doSave");
    this.getActionMap().put("doSave", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            save();
        }
    });

    importFrom(baseStory);
}

From source file:com.intel.stl.ui.common.view.DistributionPiePanel.java

public void setLabels(String[] itemNames, ImageIcon[] icons, int labelColumns) {
    if (icons.length != itemNames.length) {
        throw new IllegalArgumentException(
                "Inconsistent number of items. " + " itemNames=" + itemNames.length + " icons=" + icons.length);
    }//  w  ww.  ja  va2s.c  o  m

    labels = new JLabel[icons.length];
    for (int i = 0; i < icons.length; i++) {
        labels[i] = new JLabel(itemNames[i], icons[i], JLabel.LEFT);
    }

    int rows = 1;
    if (labelColumns <= 0) {
        labelPanel.setLayout(new FlowLayout());
        for (JLabel label : labels) {
            labelPanel.add(label);
        }
    } else {
        BoxLayout layout = new BoxLayout(labelPanel, BoxLayout.X_AXIS);
        labelPanel.setLayout(layout);
        JPanel[] columns = new JPanel[labelColumns];
        for (int i = 0; i < columns.length; i++) {
            labelPanel.add(Box.createHorizontalGlue());
            columns[i] = new JPanel();
            columns[i].setOpaque(false);
            columns[i].setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 3));
            BoxLayout cLayout = new BoxLayout(columns[i], BoxLayout.Y_AXIS);
            columns[i].setLayout(cLayout);
            labelPanel.add(columns[i]);
        }
        labelPanel.add(Box.createHorizontalGlue());
        rows = (int) Math.ceil((double) labels.length / labelColumns);
        int index = 0;
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < labelColumns; j++) {
                columns[i].add(index < labels.length ? labels[index] : Box.createGlue());
                index += 1;
            }
        }
    }
}

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

public VisibleMedSavantWorker(String pageName, String title) {
    super(pageName);
    view = ViewUtil.getClearPanel();//w w w .  j  av a 2s  . co m
    view.setOpaque(false);
    view.setBorder(ViewUtil.getMediumBorder());
    view.setLayout(new BoxLayout(view, BoxLayout.Y_AXIS));

    this.title = title;
    titleLabel = new JLabel(title);
    titleLabel.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 12));
    statusLabel = new JLabel();

    progressBar = ViewUtil.getIndeterminateProgressBar();

    resultsButton = ViewUtil.getSoftButton("View Results");
    cancelButton = ViewUtil.getSoftButton("Cancel");
    closeButton = ViewUtil.getSoftButton("Close");
    resultsButton.setVisible(false);
    closeButton.setVisible(false);
    resultsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            showResults();
        }
    });

    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            //   setStatus(JobStatus.CANCELLED);
            cancel(true);
        }
    });

    closeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            closeJob();
        }
    });

    JPanel buttonBar = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(buttonBar);

    buttonBar.add(resultsButton);
    buttonBar.add(cancelButton);
    buttonBar.add(closeButton);
    JPanel statusPanel = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(statusPanel);
    statusPanel.add(statusLabel);
    statusPanel.add(Box.createHorizontalStrut(20));
    statusPanel.add(Box.createHorizontalGlue());
    statusPanel.add(progressBar);
    statusPanel.setPreferredSize(new Dimension(300, 25));
    statusPanel.setMinimumSize(new Dimension(300, 25));

    view.add(ViewUtil.alignLeft(titleLabel));
    view.add(statusPanel);
    view.add(ViewUtil.alignRight(buttonBar));

    setStatus(JobStatus.NOT_STARTED);
}

From source file:net.sf.maltcms.chromaui.foldChangeViewer.ui.FoldChangeViewTopComponent.java

public void initialize(final IChromAUIProject project,
        final ADataset1D<StatisticsContainer, FoldChangeElement> ds) {
    if (initialized.compareAndSet(false, true)) {
        final ProgressHandle handle = ProgressHandleFactory.createHandle("Loading chart");
        final JComponent progressComponent = ProgressHandleFactory.createProgressComponent(handle);
        final JPanel box = new JPanel();
        box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
        box.add(Box.createHorizontalGlue());
        box.add(progressComponent);//  w ww.ja  va  2  s. c om
        box.add(Box.createHorizontalGlue());
        add(box, BorderLayout.CENTER);
        AProgressAwareRunnable runnable = new AProgressAwareRunnable() {
            @Override
            public void run() {
                try {
                    handle.start();
                    handle.progress("Initializing Overlays...");
                    if (project != null) {
                        ic.add(project);
                    }
                    dataset = ds;
                    annotations = new ArrayList<XYAnnotation>(0);
                    final DefaultComboBoxModel dcbm = new DefaultComboBoxModel();
                    ic.add(ds);
                    for (int i = 0; i < ds.getSeriesCount(); i++) {
                        ic.add(ds.getSource(i));
                    }
                    handle.progress("Initializing Settings and Properties...");
                    ic.add(new Properties());
                    sp = new SettingsPanel();
                    ic.add(sp);
                    handle.progress("Creating panel...");
                    jp = new FoldChangeViewPanel(ic, getLookup(), ds);
                    ic.add(jp);
                    ic.add(this);
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            //EDT stuff
                            setDisplayName("Fold change view of " + ds.getDisplayName());
                            setToolTipText(ds.getDescription());
                            remove(box);
                            add(jp, BorderLayout.CENTER);
                            load();
                        }
                    });
                } finally {
                    handle.finish();
                }
            }
        };
        runnable.setProgressHandle(handle);
        AProgressAwareRunnable.createAndRun("Creating chart", runnable);
    }
}

From source file:org.ecoinformatics.seek.ecogrid.RegistrySearchDialog.java

private void initMainPanel() {
    JPanel selectionPanel = new JPanel();
    selectionPanel.setLayout(new BoxLayout(selectionPanel, BoxLayout.X_AXIS));
    initOptions();// w w  w  . j  a v  a 2  s  .  c  o m
    optionList = new JComboBox(options);
    optionList.setEditable(false);
    optionList.addItemListener(new TextFieldEnableController());
    selectionPanel.add(optionList);
    selectionPanel.add(Box.createHorizontalStrut(EcogridPreferencesTab.GAP));
    JLabel label = new JLabel(CONTAINS);
    selectionPanel.add(label);
    selectionPanel.add(Box.createHorizontalStrut(EcogridPreferencesTab.GAP));
    inputField.setEnabled(false);
    selectionPanel.add(inputField);
    selectionPanel.add(Box.createHorizontalGlue());

    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(selectionPanel, BorderLayout.NORTH);
    mainPanel.add(Box.createVerticalGlue(), BorderLayout.CENTER);

    JPanel buttonPanel = new JPanel();
    JPanel rightButtonPanel = new JPanel();
    rightButtonPanel.setLayout(new BoxLayout(rightButtonPanel, BoxLayout.X_AXIS));
    /*searchButton = new JButton(new SearchRegistryAction("Search", this,
    parent, parent.getLocation()));
    searchButton.setPreferredSize(ServicesDisplayFrame.BUTTONDIMENSION);
    searchButton.setMaximumSize(ServicesDisplayFrame.BUTTONDIMENSION);
    rightButtonPanel.add(searchButton);*/
    rightButtonPanel.add(Box.createHorizontalStrut(EcogridPreferencesTab.MARGINGSIZE));
    cancelButton = new JButton(new CancelSearchAction("Cancel", this, parent));
    cancelButton.setPreferredSize(EcogridPreferencesTab.BUTTONDIMENSION);
    cancelButton.setMaximumSize(EcogridPreferencesTab.BUTTONDIMENSION);
    rightButtonPanel.add(cancelButton);
    buttonPanel.setLayout(new BorderLayout());
    buttonPanel.add(Box.createHorizontalGlue(), BorderLayout.CENTER);
    buttonPanel.add(rightButtonPanel, BorderLayout.EAST);

    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
}

From source file:com.actelion.research.spiritapp.ui.audit.RecentChangesDlg.java

public RecentChangesDlg(String userId) {
    super(UIUtils.getMainFrame(), "Recent Changes");
    if (userId == null) {
        userTextField.setText("");
        userTextField.setEnabled(true);// w  w  w.  j av  a  2  s  .co m
    } else {
        userTextField.setText(userId.length() == 0 ? "NA" : userId);
        userTextField.setEnabled(false);
    }
    userTextField.setTextWhenEmpty("UserId");

    fromTextField.setText(FormatterUtils.formatDate(DateUtils.addDays(new Date(), -3)));
    toTextField.setText(FormatterUtils.formatDate(DateUtils.addDays(new Date(), 1)));

    //RevisionPanel
    JButton filterButton = new JIconButton(IconType.SEARCH, "Search");
    filterButton.addActionListener(e -> loadRevisions());
    userTextField.addActionListener(e -> loadRevisions());
    //fromTextField.addActionListener(e->loadRevisions());
    //toTextField.addActionListener(e->loadRevisions());
    studyComboBox.addActionListener(e -> loadRevisions());
    byFieldCheckbox.addActionListener(e -> revisionPanel.setSingular(byFieldCheckbox.isSelected()));
    byFieldCheckbox.setVisible(SpiritProperties.getInstance().isAdvancedMode());

    exportChangeEventsAction.setParentDlg(this);
    JIconButton exportChangeEventsButton = new JIconButton(IconType.PDF, "Export Change Events...",
            exportChangeEventsAction);
    JPanel actionPanel = UIUtils.createHorizontalBox(Box.createHorizontalGlue(), exportChangeEventsButton);

    JPanel revisionQueryPanel = UIUtils.createTitleBox("Filters",
            UIUtils.createVerticalBox(
                    UIUtils.createTable(4, new JLabel("From: "), fromTextField, new JLabel(" To: "),
                            toTextField),
                    UIUtils.createHorizontalBox(byFieldCheckbox, Box.createHorizontalGlue()),
                    Box.createVerticalStrut(10), new JSeparator(JSeparator.HORIZONTAL),
                    UIUtils.createHorizontalBox(studyCheckBox, sampleCheckBox, locationCheckBox, resultCheckBox,
                            Box.createHorizontalGlue()),
                    UIUtils.createBox(BorderFactory.createEmptyBorder(10, 10, 10, 0),
                            UIUtils.createTable(2, new JLabel("StudyId: "),
                                    studyComboBox/*,
                                                 new JLabel("UserId: "), userTextField*/)),
                    new JSeparator(JSeparator.HORIZONTAL),
                    UIUtils.createHorizontalBox(adminChanges, Box.createHorizontalGlue()),
                    Box.createVerticalStrut(20), new JSeparator(JSeparator.HORIZONTAL),
                    UIUtils.createHorizontalBox(Box.createHorizontalGlue(), filterButton),
                    Box.createVerticalGlue()));
    getRootPane().setDefaultButton(filterButton);

    if (!SpiritProperties.getInstance().isChecked(PropertyKey.SYSTEM_RESULT)) {
        resultCheckBox.setVisible(false);
        resultCheckBox.setSelected(false);
    }

    //ContentPane
    setContentPane(UIUtils.createBox(revisionPanel, null, actionPanel, revisionQueryPanel, null));
    UIUtils.adaptSize(this, 1200, 800);
    setVisible(true);
}

From source file:com.eviware.soapui.impl.rest.panels.mock.RestMockResponseDesktopPanel.java

private JComponent createMediaTypeCombo() {
    MediaTypeComboBox mediaTypeComboBox = new MediaTypeComboBox(this.getModelItem());
    mediaTypeComboBox.addItemListener(new ItemListener() {
        @Override/*w ww.j  av a  2s  . c o m*/
        public void itemStateChanged(ItemEvent e) {
            setMediaType(getResponseEditor().getInputArea(), e.getItem().toString());
        }
    });
    JComponent innerPanel = createPanelWithLabel("Content | Media type: ", mediaTypeComboBox);

    JPanel outerPanel = new JPanel();
    outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.X_AXIS));
    outerPanel.add(innerPanel);
    outerPanel.add(Box.createHorizontalGlue());
    outerPanel
            .add(UISupport.createFormButton(new ShowOnlineHelpAction(HelpUrls.REST_MOCK_RESPONSE_EDITOR_BODY)));

    return outerPanel;
}