Example usage for javax.swing Box createHorizontalStrut

List of usage examples for javax.swing Box createHorizontalStrut

Introduction

In this page you can find the example usage for javax.swing Box createHorizontalStrut.

Prototype

public static Component createHorizontalStrut(int width) 

Source Link

Document

Creates an invisible, fixed-width component.

Usage

From source file:org.openmicroscopy.shoola.agents.imviewer.util.proj.ProjSavingDialog.java

/** 
 * Builds and lays out the control.// w  w w.  ja  v a  2s. co m
 * 
 * @return See above.
 */
private JPanel buildToolBar() {
    JPanel bar = new JPanel();
    bar.add(closeButton);
    bar.add(Box.createHorizontalStrut(5));
    bar.add(projectButton);
    bar.add(Box.createHorizontalStrut(20));
    return UIUtilities.buildComponentPanelRight(bar);
}

From source file:org.openmicroscopy.shoola.agents.measurement.view.GraphPane.java

/** Builds and lays out the UI. */
private void buildGUI() {
    buildHistogramNoSelection();/*from ww w .  ja v a 2  s.co m*/
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    JPanel centrePanel = new JPanel();
    centrePanel.setLayout(new BoxLayout(centrePanel, BoxLayout.X_AXIS));

    centrePanel.add(zSlider);
    centrePanel.add(Box.createHorizontalStrut(5));
    centrePanel.add(mainPanel);
    centrePanel.add(export);
    add(centrePanel);
    add(tSlider);
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.AnnotationDataUI.java

/** Builds and lays out the UI. */
private void buildGUI() {
    removeAll();/*from  w w w  . j a  v a 2  s  .co m*/

    JLabel l = new JLabel();
    Font f = l.getFont();
    int size = f.getSize() - 1;
    content.removeAll();
    content.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(2, 1, 2, 1);
    c.anchor = GridBagConstraints.WEST;
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.HORIZONTAL;

    if (!model.isAnnotationLoaded()) {
        l.setText("Annotation could not be loaded");
        content.add(l, c);
        return;
    }

    if (model.isMultiSelection()) {
        Object refObject = model.getRefObject();
        StringBuffer buffer = new StringBuffer();
        buffer.append("Annotate the selected ");
        buffer.append(model.getObjectTypeAsString(refObject));
        buffer.append("s");
        l.setText(buffer.toString());
        content.add(l, c);
        c.gridy++;
    }

    // filters
    content.add(createBar(filterButton, null), c);
    c.gridy++;

    // rating
    c.gridwidth = 1;
    c.gridx = 0;
    c.weightx = 0;
    c.fill = GridBagConstraints.NONE;
    JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(UIUtilities.setTextFont("Rating:", Font.BOLD, size));
    p.add(createBar(unrateButton, null));
    content.add(p, c);
    c.gridx = 1;
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(rating);
    p.add(Box.createHorizontalStrut(2));
    p.add(otherRating);
    content.add(p, c);
    c.gridy++;

    // tags
    c.gridx = 0;
    p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(UIUtilities.setTextFont("Tags:", Font.BOLD, size));
    p.add(createBar(addTagsButton, removeTagsButton));
    content.add(p, c);
    c.gridy++;
    content.add(tagsPane, c);
    c.gridy++;

    // attachment
    c.gridx = 0;
    c.gridwidth = 2;
    p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(UIUtilities.setTextFont("Attachments:", Font.BOLD, size));
    p.add(createBar(addDocsButton, removeDocsButton));
    content.add(p, c);
    c.gridy++;
    content.add(docRef, c);
    c.gridy++;

    if (!model.isMultiSelection()) {
        mapsPane.reload(filter);
        content.add(mapsPane, c);
        c.gridy++;
    }

    // other
    if (!CollectionUtils.isEmpty(model.getAllOtherAnnotations())) {
        p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
        p.setBackground(UIUtilities.BACKGROUND_COLOR);
        p.add(UIUtilities.setTextFont("Others:", Font.BOLD, size));
        p.add(createBar(null, removeOtherAnnotationsButton));
        content.add(p, c);
        c.gridy++;
        content.add(otherPane, c);
    }

    add(content, BorderLayout.CENTER);
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.DocComponent.java

/** Builds and lays out the UI. */
private void buildGUI() {
    setBackground(UIUtilities.BACKGROUND_COLOR);
    setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    add(label);/*  w ww.ja  v a2s.  c o m*/
    JToolBar bar = new JToolBar();
    bar.setBackground(UIUtilities.BACKGROUND_COLOR);
    bar.setFloatable(false);
    bar.setRollover(true);
    bar.setBorder(null);
    bar.setOpaque(true);
    boolean b = setControlsEnabled(data != null);
    int count = 0;
    if (editButton != null)
        count++;
    if (unlinkButton != null)
        count++;
    if (downloadButton != null)
        count++;
    if (infoButton != null)
        count++;
    if (openButton != null)
        count++;
    if (count > 0 && data != null) {
        menuButton.setEnabled(true);
        if (model.isAcrossGroups())
            menuButton.setEnabled(false);
        bar.add(menuButton);
        if (!b)
            bar.add(Box.createHorizontalStrut(8));
        add(bar);
    }
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.OriginalMetadataComponent.java

/** Initializes the components. */
private void initComponents() {
    IconManager icons = IconManager.getInstance();
    Icon icon = icons.getIcon(IconManager.DOWNLOAD);
    downloadButton = new JButton(icon);
    downloadButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    downloadButton.setOpaque(false);//from  www . j a va 2  s.c  o  m
    UIUtilities.unifiedButtonLookAndFeel(downloadButton);
    downloadButton.setToolTipText("Download the metadata file.");
    downloadButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            download();
        }
    });
    toolBar = buildToolBar();
    toolBar.setBackground(UIUtilities.BACKGROUND_COLOR);
    JXBusyLabel label = new JXBusyLabel(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
    label.setBackground(UIUtilities.BACKGROUND_COLOR);
    label.setBusy(true);
    JPanel p = new JPanel();
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
    p.add(label);
    p.add(Box.createHorizontalStrut(5));
    JLabel l = new JLabel("Loading metadata");
    l.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(l);
    statusBar = UIUtilities.buildComponentPanel(p);
    statusBar.setBackground(UIUtilities.BACKGROUND_COLOR);
    setBackground(UIUtilities.BACKGROUND_COLOR);
    setLayout(new BorderLayout(0, 0));
    add(statusBar, BorderLayout.NORTH);
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java

/**
 * Lays out the passed components./*from  w w w .  j  ava2 s  . co m*/
 * 
 * @param pane The main pane.
 * @param components The components to lay out.
 */
private void layoutComponents(JPanel pane, Map<JLabel, JComponent> components) {
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(0, 2, 2, 0);
    Entry<JLabel, JComponent> entry;

    Iterator<Entry<JLabel, JComponent>> i = components.entrySet().iterator();
    c.gridy = 0;
    while (i.hasNext()) {
        c.gridx = 0;
        entry = i.next();
        ++c.gridy;
        c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
        c.fill = GridBagConstraints.NONE; //reset to default
        c.weightx = 0.0;
        pane.add(entry.getKey(), c);
        c.gridx++;
        pane.add(Box.createHorizontalStrut(5), c);
        c.gridx++;
        c.gridwidth = GridBagConstraints.REMAINDER;//end row
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 1.0;
        pane.add(entry.getValue(), c);
    }
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java

/**
 * Builds the properties component./*from   w  ww .j  a  v  a2  s .c  om*/
 * 
 * @return See above.
 */
private JPanel buildProperties() {
    Object refObject = model.getRefObject();
    JPanel p = new JPanel();
    p.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));

    JPanel idPanel = new JPanel();
    idPanel.setLayout(new BoxLayout(idPanel, BoxLayout.X_AXIS));
    idPanel.setBackground(UIUtilities.BACKGROUND_COLOR);
    JPanel l = UIUtilities.buildComponentPanel(idLabel, 0, 0);
    l.setBackground(UIUtilities.BACKGROUND_COLOR);
    idPanel.add(l);
    idPanel.add(Box.createHorizontalGlue());
    idPanel.add(inplaceIcon);
    p.add(idPanel);

    l = UIUtilities.buildComponentPanel(ownerLabel, 0, 0);
    l.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(l);
    int w = editName.getIcon().getIconWidth() + 4;
    l = UIUtilities.buildComponentPanel(gpLabel, 0, 0);
    l.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(layoutEditablefield(Box.createHorizontalStrut(w), l));
    l = UIUtilities.buildComponentPanel(parentLabel, 0, 0);
    l.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(layoutEditablefield(Box.createHorizontalStrut(w), l));
    l = UIUtilities.buildComponentPanel(wellLabel, 0, 0);
    l.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(layoutEditablefield(Box.createHorizontalStrut(w), l));

    namePanel = layoutEditablefield(editName, namePane);
    p.add(namePanel);
    p.add(Box.createVerticalStrut(5));

    if (refObject instanceof ImageData || refObject instanceof DatasetData || refObject instanceof ProjectData
            || refObject instanceof TagAnnotationData || refObject instanceof WellSampleData
            || refObject instanceof PlateData || refObject instanceof ScreenData
            || refObject instanceof PlateAcquisitionData) {

        descriptionScrollPane = new JScrollPane(descriptionWiki);
        descriptionScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        descriptionScrollPane.setBorder(AnnotationUI.EDIT_BORDER);
        Dimension viewportSize = new Dimension(WIDTH, HEIGHT);
        descriptionScrollPane.getViewport().setPreferredSize(viewportSize);

        double[][] design = new double[][] { { TableLayout.PREFERRED, TableLayout.FILL },
                { TableLayout.PREFERRED } };

        TableLayout table = new TableLayout(design);
        descriptionPanel = new JPanel(table);
        descriptionPanel.setBackground(UIUtilities.BACKGROUND_COLOR);
        descriptionPanel.add(descriptionButtonEdit, "0, 0, c, t");
        descriptionPanel.add(descriptionScrollPane, "1, 0");

        p.add(descriptionPanel);
        p.add(Box.createVerticalStrut(5));
    }
    return p;
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.ToolBar.java

/** 
 * Builds the general bar.//from  ww w .  j  a v a2 s .  c  o m
 * 
 * @return See above.
 */
private JComponent buildGeneralBar() {
    JToolBar bar = new JToolBar();
    bar.setBackground(UIUtilities.BACKGROUND_COLOR);
    bar.setFloatable(false);
    bar.setRollover(true);
    bar.setBorder(null);
    bar.add(saveButton);
    bar.add(Box.createHorizontalStrut(5));
    bar.add(refreshButton);
    bar.add(Box.createHorizontalStrut(5));
    bar.add(viewButton);
    bar.add(Box.createHorizontalStrut(5));
    bar.add(linkButton);
    bar.add(Box.createHorizontalStrut(5));
    bar.add(saveAsButton);
    bar.add(Box.createHorizontalStrut(5));
    bar.add(publishingButton);
    /*
    if (MetadataViewerAgent.isAdministrator()) {
       bar.add(Box.createHorizontalStrut(5));
        bar.add(uploadScriptButton);
    }
    bar.add(Box.createHorizontalStrut(5));
    bar.add(scriptsButton);
    */
    //bar.add(scriptsButton);
    return bar;
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.UserProfile.java

/**
 * Builds the panel hosting the user's details.
 * /*  ww  w .j  a v  a 2s. c  o m*/
 * @return See above.
 */
private JPanel buildContentPanel() {
    ExperimenterData user = (ExperimenterData) model.getRefObject();
    boolean editable = model.isUserOwner(user);
    if (!editable)
        editable = MetadataViewerAgent.isAdministrator();
    details = EditorUtil.convertExperimenter(user);
    JPanel content = new JPanel();
    content.setBorder(BorderFactory.createTitledBorder("User"));
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    Entry<String, String> entry;
    Iterator<Entry<String, String>> i = details.entrySet().iterator();
    JComponent label;
    JTextField area;
    String key, value;
    content.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(0, 2, 2, 0);
    //Add log in name but cannot edit.
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;//end row
    c.fill = GridBagConstraints.HORIZONTAL;
    content.add(buildProfileCanvas(), c);
    c.gridy++;
    c.gridx = 0;
    label = EditorUtil.getLabel(EditorUtil.DISPLAY_NAME, true);
    label.setBackground(UIUtilities.BACKGROUND_COLOR);
    c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
    c.fill = GridBagConstraints.NONE;//reset to default
    c.weightx = 0.0;
    content.add(label, c);
    c.gridx++;
    content.add(Box.createHorizontalStrut(5), c);
    c.gridx++;
    c.gridwidth = GridBagConstraints.REMAINDER;//end row
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    loginArea.setText(user.getUserName());
    loginArea.setEnabled(false);
    loginArea.setEditable(false);
    if (MetadataViewerAgent.isAdministrator() && !model.isSystemUser(user.getId()) && !model.isSelf()) {
        loginArea.setEnabled(true);
        loginArea.getDocument().addDocumentListener(this);
    }
    content.add(loginArea, c);
    while (i.hasNext()) {
        ++c.gridy;
        c.gridx = 0;
        entry = i.next();
        key = entry.getKey();
        value = entry.getValue();
        label = EditorUtil.getLabel(key, EditorUtil.FIRST_NAME.equals(key) || EditorUtil.LAST_NAME.equals(key));
        area = new JTextField(value);
        area.setBackground(UIUtilities.BACKGROUND_COLOR);
        area.setEditable(editable);
        area.setEnabled(editable);
        if (editable)
            area.getDocument().addDocumentListener(this);
        items.put(key, area);
        label.setBackground(UIUtilities.BACKGROUND_COLOR);
        c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
        c.fill = GridBagConstraints.NONE;//reset to default
        c.weightx = 0.0;
        content.add(label, c);
        c.gridx++;
        content.add(Box.createHorizontalStrut(5), c);
        c.gridx++;
        c.gridwidth = GridBagConstraints.REMAINDER;//end row
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 1.0;
        content.add(area, c);
    }
    c.gridx = 0;
    c.gridy++;
    label = EditorUtil.getLabel(EditorUtil.DEFAULT_GROUP, false);
    c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
    c.fill = GridBagConstraints.NONE;//reset to default
    c.weightx = 0.0;
    content.add(label, c);
    c.gridx++;
    content.add(Box.createHorizontalStrut(5), c);
    c.gridx++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    content.add(groupsBox, c);
    c.gridy++;
    content.add(permissionsPane, c);
    c.gridx = 0;
    c.gridy++;
    label = EditorUtil.getLabel(EditorUtil.GROUP_OWNER, false);
    c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
    c.fill = GridBagConstraints.NONE; //reset to default
    c.weightx = 0.0;
    content.add(label, c);
    c.gridx++;
    content.add(Box.createHorizontalStrut(5), c);
    c.gridx++;
    c.gridwidth = GridBagConstraints.REMAINDER; //end row
    c.fill = GridBagConstraints.NONE;
    c.weightx = 1.0;
    content.add(ownerBox, c);
    if (activeBox.isVisible()) {
        c.gridx = 0;
        c.gridy++;
        label = EditorUtil.getLabel(EditorUtil.ACTIVE, false);
        c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
        c.fill = GridBagConstraints.NONE;
        c.weightx = 0.0;
        content.add(label, c);
        c.gridx++;
        content.add(Box.createHorizontalStrut(5), c);
        c.gridx++;
        c.gridwidth = GridBagConstraints.REMAINDER;
        c.fill = GridBagConstraints.NONE;
        c.weightx = 1.0;
        content.add(activeBox, c);
    }
    if (adminBox.isVisible()) {
        c.gridx = 0;
        c.gridy++;
        label = EditorUtil.getLabel(EditorUtil.ADMINISTRATOR, false);
        c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
        c.fill = GridBagConstraints.NONE;
        c.weightx = 0.0;
        content.add(label, c);
        c.gridx++;
        content.add(Box.createHorizontalStrut(5), c);
        c.gridx++;
        c.gridwidth = GridBagConstraints.REMAINDER;
        c.fill = GridBagConstraints.NONE;
        c.weightx = 1.0;
        content.add(adminBox, c);
    }
    c.gridx = 0;
    c.gridy++;
    content.add(Box.createHorizontalStrut(10), c);
    c.gridy++;
    label = UIUtilities.setTextFont(EditorUtil.MANDATORY_DESCRIPTION, Font.ITALIC);
    label.setForeground(UIUtilities.REQUIRED_FIELDS_COLOR);
    c.weightx = 0.0;
    content.add(label, c);
    return content;
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.browser.BrowserUI.java

/** Helper method to create the menu bar. */
private void createMenuBars() {
    rightMenuBar = new JToolBar();
    rightMenuBar.setBorder(null);/*from w  ww .j  a  v  a 2 s. c  o  m*/
    rightMenuBar.setRollover(true);
    rightMenuBar.setFloatable(false);

    JButton button;
    leftMenuBar = new JToolBar();
    leftMenuBar.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
    leftMenuBar.setRollover(true);
    leftMenuBar.setFloatable(false);
    BrowserManageAction a;
    int type = model.getBrowserType();
    switch (type) {
    case Browser.PROJECTS_EXPLORER:
    case Browser.SCREENS_EXPLORER:
        a = (BrowserManageAction) controller.getAction(BrowserControl.NEW_CONTAINER);
        button = new JButton(a);
        button.setName("new container button");
        button.setBorderPainted(false);
        button.addMouseListener(a);
        rightMenuBar.add(button);
        break;
    case Browser.ADMIN_EXPLORER:
        a = (BrowserManageAction) controller.getAction(BrowserControl.NEW_ADMIN);
        button = new JButton(a);
        button.setName("new group or user button");
        button.setBorderPainted(false);
        button.addMouseListener(a);
        rightMenuBar.add(button);
        break;
    case Browser.TAGS_EXPLORER:
        a = (BrowserManageAction) controller.getAction(BrowserControl.NEW_TAG);
        button = new JButton(a);
        button.setName("new tag button");
        button.setBorderPainted(false);
        button.addMouseListener(a);
        rightMenuBar.add(button);
    }
    button = new JButton(controller.getAction(BrowserControl.CUT));
    button.setName("cut button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);
    button = new JButton(controller.getAction(BrowserControl.COPY));
    button.setName("copy button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);
    button = new JButton(controller.getAction(BrowserControl.PASTE));
    button.setName("paste button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);
    button = new JButton(controller.getAction(BrowserControl.DELETE));
    button.setName("delete button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);
    button = new JButton(controller.getAction(BrowserControl.REFRESH));
    button.setName("refresh button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);

    if (type == Browser.ADMIN_EXPLORER) {
        button = new JButton(controller.getAction(BrowserControl.RESET_PASSWORD));
        button.setBorderPainted(false);
        rightMenuBar.add(button);
    } else {
        button = new JButton(controller.getAction(BrowserControl.IMPORT));
        button.setBorderPainted(false);
        //rightMenuBar.add(button);
    }
    rightMenuBar.add(Box.createHorizontalStrut(6));
    rightMenuBar.add(new JSeparator());
    rightMenuBar.add(Box.createHorizontalStrut(6));
    ButtonGroup group = new ButtonGroup();
    JToggleButton b = new JToggleButton();
    group.add(b);
    b.setBorderPainted(true);
    b.setSelected(true);
    b.setAction(controller.getAction(BrowserControl.SORT));

    rightMenuBar.add(b);
    b = new JToggleButton(controller.getAction(BrowserControl.SORT_DATE));
    b.setBorderPainted(true);
    group.add(b);
    rightMenuBar.add(b);

    partialButton = new JToggleButton(controller.getAction(BrowserControl.PARTIAL_NAME));
    partialButton.setBorderPainted(true);
    rightMenuBar.add(partialButton);
    rightMenuBar.add(new JSeparator(JSeparator.VERTICAL));
    button = new JButton(controller.getAction(BrowserControl.COLLAPSE));
    button.setBorderPainted(false);
    rightMenuBar.add(button);
}