Example usage for javax.swing JToolBar setBorder

List of usage examples for javax.swing JToolBar setBorder

Introduction

In this page you can find the example usage for javax.swing JToolBar setBorder.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.")
public void setBorder(Border border) 

Source Link

Document

Sets the border of this component.

Usage

From source file:io.github.tavernaextras.biocatalogue.ui.filtertree.FilterTreePane.java

/**
 * @return A toolbar that replicates all actions available in the contextual menu of
 *         the filtering tree - mainly: saving current filter, reloading filter tree,
 *         expanding/collapsing and selecting/deselecting everything in the tree.
 *///from w  w  w  .  java2s .co  m
private JToolBar createTreeActionToolbar() {

    // the actual toolbar - no actions are added to it yet: done in a separate method
    JToolBar tbTreeActions = new JToolBar(JToolBar.HORIZONTAL);
    tbTreeActions.setAlignmentX(RIGHT_ALIGNMENT);
    tbTreeActions.setBorderPainted(true);
    tbTreeActions.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    tbTreeActions.setFloatable(false);
    return (tbTreeActions);
}

From source file:com.rapidminer.gui.graphs.GraphViewer.java

private JComponent createControlPanel() {
    // === mouse behaviour ===
    if (graphMouse != null) {
        vv.setGraphMouse(graphMouse);/*  w ww  .j a  v  a2 s . c o  m*/
        vv.addKeyListener(graphMouse.getModeKeyListener());
        graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
    }
    transformAction.setEnabled(false);
    pickingAction.setEnabled(true);

    vv.addGraphMouseListener(new GraphMouseListener<V>() {

        @Override
        public void graphClicked(V vertex, MouseEvent arg1) {
        }

        @Override
        public void graphPressed(V arg0, MouseEvent arg1) {
        }

        @Override
        public void graphReleased(V vertex, MouseEvent arg1) {
            if (currentMode.equals(ModalGraphMouse.Mode.TRANSFORMING)) {
                if (graphCreator.getObjectViewer() != null) {
                    vv.getPickedVertexState().clear();
                    vv.getPickedVertexState().pick(vertex, true);
                    graphCreator.getObjectViewer().showObject(graphCreator.getObject(vertex));
                }
            }
        }
    });

    JPanel controls = new JPanel();
    GridBagLayout gbLayout = new GridBagLayout();
    controls.setLayout(gbLayout);
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(4, 4, 4, 4);
    c.weightx = 1;
    c.weighty = 0;

    // zooming
    JToolBar zoomBar = new ExtendedJToolBar();
    zoomBar.setLayout(new FlowLayout(FlowLayout.CENTER));
    zoomBar.add(new ZoomInAction(this, IconSize.SMALL));
    zoomBar.add(new ZoomOutAction(this, IconSize.SMALL));
    zoomBar.setBorder(BorderFactory.createTitledBorder("Zoom"));
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(zoomBar, c);
    controls.add(zoomBar);

    // mode
    JToolBar modeBar = new ExtendedJToolBar();
    modeBar.setLayout(new FlowLayout(FlowLayout.CENTER));
    modeBar.add(transformAction);
    modeBar.add(pickingAction);
    modeBar.setBorder(BorderFactory.createTitledBorder("Mode"));
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(modeBar, c);
    controls.add(modeBar);

    // layout selection
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(layoutSelection, c);
    controls.add(layoutSelection);

    // show node labels
    JCheckBox nodeLabels = new JCheckBox("Node Labels", graphCreator.showVertexLabelsDefault());
    nodeLabels.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            togglePaintVertexLabels();
        }
    });
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(nodeLabels, c);
    controls.add(nodeLabels);

    // show edge labels
    JCheckBox edgeLabels = new JCheckBox("Edge Labels", graphCreator.showEdgeLabelsDefault());
    edgeLabels.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            togglePaintEdgeLabels();
        }
    });
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(edgeLabels, c);
    controls.add(edgeLabels);

    // option components
    for (int i = 0; i < graphCreator.getNumberOfOptionComponents(); i++) {
        JComponent optionComponent = graphCreator.getOptionComponent(this, i);
        if (optionComponent != null) {
            c.gridwidth = GridBagConstraints.REMAINDER;
            gbLayout.setConstraints(optionComponent, c);
            controls.add(optionComponent);
        }
    }

    // save image
    JButton imageButton = new JButton("Save Image...");
    imageButton.setToolTipText("Saves an image of the current graph.");
    imageButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final Component tosave = vv;
            new ExportImageAction(false) {

                private static final long serialVersionUID = 1L;

                @Override
                protected PrintableComponent getPrintableComponent() {
                    return new SimplePrintableComponent(tosave, "Graph");
                }

            }.actionPerformed(e);
        }
    });
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(imageButton, c);
    controls.add(imageButton);

    // help
    JButton help = new JButton("Help");
    help.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(vv, INSTRUCTIONS);
        }
    });
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(help, c);
    controls.add(help);

    JPanel fillPanel = new JPanel();
    c.weighty = 1.0d;
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(fillPanel, c);
    controls.add(fillPanel);

    return controls;
}

From source file:net.sf.jabref.gui.preftabs.TableColumnsTab.java

/**
 * Customization of external program paths.
 *
 * @param prefs a <code>JabRefPreferences</code> value
 *//*from   ww  w . java  2  s  .  c o m*/
public TableColumnsTab(JabRefPreferences prefs, JabRefFrame frame) {
    this.prefs = prefs;
    this.frame = frame;
    setLayout(new BorderLayout());

    TableModel tm = new AbstractTableModel() {

        @Override
        public int getRowCount() {
            return rowCount;
        }

        @Override
        public int getColumnCount() {
            return 2;
        }

        @Override
        public Object getValueAt(int row, int column) {
            int internalRow = row;
            if (internalRow == 0) {
                return column == 0 ? InternalBibtexFields.NUMBER_COL : String.valueOf(ncWidth);
            }
            internalRow--;
            if (internalRow >= tableRows.size()) {
                return "";
            }
            Object rowContent = tableRows.get(internalRow);
            if (rowContent == null) {
                return "";
            }
            TableRow tr = (TableRow) rowContent;
            // Only two columns
            if (column == 0) {
                return tr.getName();
            } else {
                return tr.getLength() > 0 ? Integer.toString(tr.getLength()) : "";
            }
        }

        @Override
        public String getColumnName(int col) {
            return col == 0 ? Localization.lang("Field name") : Localization.lang("Column width");
        }

        @Override
        public Class<?> getColumnClass(int column) {
            if (column == 0) {
                return String.class;
            }
            return Integer.class;
        }

        @Override
        public boolean isCellEditable(int row, int col) {
            return !((row == 0) && (col == 0));
        }

        @Override
        public void setValueAt(Object value, int row, int col) {
            tableChanged = true;
            // Make sure the vector is long enough.
            while (row >= tableRows.size()) {
                tableRows.add(new TableRow("", -1));
            }

            if ((row == 0) && (col == 1)) {
                ncWidth = Integer.parseInt(value.toString());
                return;
            }

            TableRow rowContent = tableRows.get(row - 1);

            if (col == 0) {
                rowContent.setName(value.toString());
                if ("".equals(getValueAt(row, 1))) {
                    setValueAt(String.valueOf(BibtexSingleField.DEFAULT_FIELD_LENGTH), row, 1);
                }
            } else {
                if (value == null) {
                    rowContent.setLength(-1);
                } else {
                    rowContent.setLength(Integer.parseInt(value.toString()));
                }
            }
        }

    };

    colSetup = new JTable(tm);
    TableColumnModel cm = colSetup.getColumnModel();
    cm.getColumn(0).setPreferredWidth(140);
    cm.getColumn(1).setPreferredWidth(80);

    FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:pref", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    JPanel pan = new JPanel();
    JPanel tabPanel = new JPanel();
    tabPanel.setLayout(new BorderLayout());
    JScrollPane sp = new JScrollPane(colSetup, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    colSetup.setPreferredScrollableViewportSize(new Dimension(250, 200));
    sp.setMinimumSize(new Dimension(250, 300));
    tabPanel.add(sp, BorderLayout.CENTER);
    JToolBar toolBar = new OSXCompatibleToolbar(SwingConstants.VERTICAL);
    toolBar.setFloatable(false);
    AddRowAction addRow = new AddRowAction();
    DeleteRowAction deleteRow = new DeleteRowAction();
    MoveRowUpAction moveUp = new MoveRowUpAction();
    MoveRowDownAction moveDown = new MoveRowDownAction();
    toolBar.setBorder(null);
    toolBar.add(addRow);
    toolBar.add(deleteRow);
    toolBar.addSeparator();
    toolBar.add(moveUp);
    toolBar.add(moveDown);
    tabPanel.add(toolBar, BorderLayout.EAST);

    fileColumn = new JCheckBox(Localization.lang("Show file column"));
    urlColumn = new JCheckBox(Localization.lang("Show URL/DOI column"));
    preferUrl = new JRadioButton(Localization.lang("Show URL first"));
    preferDoi = new JRadioButton(Localization.lang("Show DOI first"));
    ButtonGroup preferUrlDoiGroup = new ButtonGroup();
    preferUrlDoiGroup.add(preferUrl);
    preferUrlDoiGroup.add(preferDoi);

    urlColumn.addChangeListener(arg0 -> {
        preferUrl.setEnabled(urlColumn.isSelected());
        preferDoi.setEnabled(urlColumn.isSelected());
    });
    arxivColumn = new JCheckBox(Localization.lang("Show ArXiv column"));

    Collection<ExternalFileType> fileTypes = ExternalFileTypes.getInstance().getExternalFileTypeSelection();
    String[] fileTypeNames = new String[fileTypes.size()];
    int i = 0;
    for (ExternalFileType fileType : fileTypes) {
        fileTypeNames[i++] = fileType.getName();
    }
    listOfFileColumns = new JList<>(fileTypeNames);
    JScrollPane listOfFileColumnsScrollPane = new JScrollPane(listOfFileColumns);
    listOfFileColumns.setVisibleRowCount(3);
    extraFileColumns = new JCheckBox(Localization.lang("Show extra columns"));
    extraFileColumns.addChangeListener(arg0 -> listOfFileColumns.setEnabled(extraFileColumns.isSelected()));

    /*** begin: special table columns and special fields ***/

    JButton helpButton = new HelpAction(Localization.lang("Help on special fields"), HelpFile.SPECIAL_FIELDS)
            .getHelpButton();

    rankingColumn = new JCheckBox(Localization.lang("Show rank"));
    qualityColumn = new JCheckBox(Localization.lang("Show quality"));
    priorityColumn = new JCheckBox(Localization.lang("Show priority"));
    relevanceColumn = new JCheckBox(Localization.lang("Show relevance"));
    printedColumn = new JCheckBox(Localization.lang("Show printed status"));
    readStatusColumn = new JCheckBox(Localization.lang("Show read status"));

    // "sync keywords" and "write special" fields may be configured mutually exclusive only
    // The implementation supports all combinations (TRUE+TRUE and FALSE+FALSE, even if the latter does not make sense)
    // To avoid confusion, we opted to make the setting mutually exclusive
    syncKeywords = new JRadioButton(Localization.lang("Synchronize with keywords"));
    writeSpecialFields = new JRadioButton(
            Localization.lang("Write values of special fields as separate fields to BibTeX"));
    ButtonGroup group = new ButtonGroup();
    group.add(syncKeywords);
    group.add(writeSpecialFields);

    specialFieldsEnabled = new JCheckBox(Localization.lang("Enable special fields"));
    specialFieldsEnabled.addChangeListener(event -> {
        boolean isEnabled = specialFieldsEnabled.isSelected();
        rankingColumn.setEnabled(isEnabled);
        qualityColumn.setEnabled(isEnabled);
        priorityColumn.setEnabled(isEnabled);
        relevanceColumn.setEnabled(isEnabled);
        printedColumn.setEnabled(isEnabled);
        readStatusColumn.setEnabled(isEnabled);
        syncKeywords.setEnabled(isEnabled);
        writeSpecialFields.setEnabled(isEnabled);
    });

    builder.appendSeparator(Localization.lang("Special table columns"));
    builder.nextLine();
    builder.append(pan);

    DefaultFormBuilder specialTableColumnsBuilder = new DefaultFormBuilder(
            new FormLayout("8dlu, 8dlu, 8cm, 8dlu, 8dlu, left:pref:grow",
                    "pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref"));
    CellConstraints cc = new CellConstraints();

    specialTableColumnsBuilder.add(specialFieldsEnabled, cc.xyw(1, 1, 3));
    specialTableColumnsBuilder.add(rankingColumn, cc.xyw(2, 2, 2));
    specialTableColumnsBuilder.add(relevanceColumn, cc.xyw(2, 3, 2));
    specialTableColumnsBuilder.add(qualityColumn, cc.xyw(2, 4, 2));
    specialTableColumnsBuilder.add(priorityColumn, cc.xyw(2, 5, 2));
    specialTableColumnsBuilder.add(printedColumn, cc.xyw(2, 6, 2));
    specialTableColumnsBuilder.add(readStatusColumn, cc.xyw(2, 7, 2));
    specialTableColumnsBuilder.add(syncKeywords, cc.xyw(2, 10, 2));
    specialTableColumnsBuilder.add(writeSpecialFields, cc.xyw(2, 11, 2));
    specialTableColumnsBuilder.add(helpButton, cc.xyw(1, 12, 2));

    specialTableColumnsBuilder.add(fileColumn, cc.xyw(5, 1, 2));
    specialTableColumnsBuilder.add(urlColumn, cc.xyw(5, 2, 2));
    specialTableColumnsBuilder.add(preferUrl, cc.xy(6, 3));
    specialTableColumnsBuilder.add(preferDoi, cc.xy(6, 4));
    specialTableColumnsBuilder.add(arxivColumn, cc.xyw(5, 5, 2));

    specialTableColumnsBuilder.add(extraFileColumns, cc.xyw(5, 6, 2));
    specialTableColumnsBuilder.add(listOfFileColumnsScrollPane, cc.xywh(5, 7, 2, 6));

    builder.append(specialTableColumnsBuilder.getPanel());
    builder.nextLine();

    /*** end: special table columns and special fields ***/

    builder.appendSeparator(Localization.lang("Entry table columns"));
    builder.nextLine();
    builder.append(pan);
    builder.append(tabPanel);
    builder.nextLine();
    builder.append(pan);
    JButton buttonWidth = new JButton(new UpdateWidthsAction());
    JButton buttonOrder = new JButton(new UpdateOrderAction());
    builder.append(buttonWidth);
    builder.nextLine();
    builder.append(pan);
    builder.append(buttonOrder);
    builder.nextLine();
    builder.append(pan);
    builder.nextLine();
    pan = builder.getPanel();
    pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(pan, BorderLayout.CENTER);
}

From source file:net.sf.jabref.EntryEditor.java

/**
 * Create toolbar for entry editor./*from   w ww  . ja  v  a2s .c o  m*/
 */
private void setupToolBar() {
    JToolBar tlb = new JToolBar(JToolBar.VERTICAL);
    CloseAction closeAction = new CloseAction();
    ;
    StoreFieldAction storeFieldAction = new StoreFieldAction();
    DeleteAction deleteAction = new DeleteAction();
    UndoAction undoAction = new UndoAction();
    RedoAction redoAction = new RedoAction();

    tlb.setBorder(null);
    tlb.setRollover(true);
    tlb.setMargin(new Insets(0, 0, 0, 2));
    tlb.setFloatable(false);
    tlb.addSeparator();
    tlb.add(deleteAction);
    tlb.addSeparator();
    tlb.add(prevEntryAction);
    tlb.add(nextEntryAction);
    tlb.addSeparator();
    tlb.add(helpAction);
    for (Component comp : tlb.getComponents()) {
        ((JComponent) comp).setOpaque(false);
    }

    // The toolbar carries all the key bindings that are valid for the whole window.
    ActionMap am = tlb.getActionMap();
    InputMap im = tlb.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(prefs.getKey("Close entry editor"), "close");
    am.put("close", closeAction);
    im.put(prefs.getKey("Entry editor, store field"), "store");
    am.put("store", storeFieldAction);
    im.put(prefs.getKey("Entry editor, previous entry"), "prev");
    am.put("prev", prevEntryAction);
    im.put(prefs.getKey("Entry editor, next entry"), "next");
    am.put("next", nextEntryAction);
    im.put(prefs.getKey("Undo"), "undo");
    am.put("undo", undoAction);
    im.put(prefs.getKey("Redo"), "redo");
    am.put("redo", redoAction);
    im.put(prefs.getKey("Help"), "help");
    am.put("help", helpAction);

    // Add actions (and thus buttons)
    JButton closeBut = new JButton(closeAction);
    closeBut.setText(null);
    closeBut.setBorder(null);

    // Create type-label
    TypeLabel typeLabel = new TypeLabel(entry.getType().getName());

    JPanel leftPan = new JPanel();
    leftPan.setLayout(new BorderLayout());
    leftPan.add(closeBut, BorderLayout.NORTH);
    leftPan.add(typeLabel, BorderLayout.CENTER);
    leftPan.add(tlb, BorderLayout.SOUTH);

    add(leftPan, BorderLayout.WEST);
}

From source file:net.sf.jabref.gui.entryeditor.EntryEditor.java

private void setupToolBar() {
    JPanel leftPan = new JPanel();
    leftPan.setLayout(new BorderLayout());
    JToolBar toolBar = new OSXCompatibleToolbar(SwingConstants.VERTICAL);

    toolBar.setBorder(null);
    toolBar.setRollover(true);/*ww  w.  ja  va 2  s.c  o  m*/

    toolBar.setMargin(new Insets(0, 0, 0, 2));

    // The toolbar carries all the key bindings that are valid for the whole
    // window.
    ActionMap actionMap = toolBar.getActionMap();
    InputMap inputMap = toolBar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);

    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_ENTRY_EDITOR), "close");
    actionMap.put("close", closeAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_STORE_FIELD), "store");
    actionMap.put("store", getStoreFieldAction());
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.AUTOGENERATE_BIBTEX_KEYS), "generateKey");
    actionMap.put("generateKey", getGenerateKeyAction());
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.AUTOMATICALLY_LINK_FILES), "autoLink");
    actionMap.put("autoLink", autoLinkAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_PREVIOUS_ENTRY), "prev");
    actionMap.put("prev", getPrevEntryAction());
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_NEXT_ENTRY), "next");
    actionMap.put("next", getNextEntryAction());
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.UNDO), "undo");
    actionMap.put("undo", undoAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.REDO), "redo");
    actionMap.put("redo", redoAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.HELP), "help");
    actionMap.put("help", getHelpAction());

    toolBar.setFloatable(false);

    // Add actions (and thus buttons)
    JButton closeBut = new JButton(closeAction);
    closeBut.setText(null);
    closeBut.setBorder(null);
    closeBut.setMargin(new Insets(8, 0, 8, 0));
    leftPan.add(closeBut, BorderLayout.NORTH);

    // Create type-label
    TypedBibEntry typedEntry = new TypedBibEntry(entry, Optional.empty(),
            panel.getBibDatabaseContext().getMode());
    leftPan.add(new TypeLabel(typedEntry.getTypeForDisplay()), BorderLayout.CENTER);
    TypeButton typeButton = new TypeButton();

    toolBar.add(typeButton);
    toolBar.add(getGenerateKeyAction());
    toolBar.add(autoLinkAction);

    toolBar.add(writeXmp);

    toolBar.addSeparator();

    toolBar.add(deleteAction);
    toolBar.add(getPrevEntryAction());
    toolBar.add(getNextEntryAction());

    toolBar.addSeparator();

    toolBar.add(getHelpAction());

    Component[] comps = toolBar.getComponents();

    for (Component comp : comps) {
        ((JComponent) comp).setOpaque(false);
    }

    leftPan.add(toolBar, BorderLayout.SOUTH);
    add(leftPan, BorderLayout.WEST);
}

From source file:net.pms.newgui.LooksFrame.java

public JComponent buildContent() {
    JPanel panel = new JPanel(new BorderLayout());
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);/*from  w  w  w  .  j a  va  2s  . c  o m*/
    toolBar.setRollover(true);

    toolBar.add(new JPanel());

    if (PMS.getConfiguration().useWebInterface()) {
        webinterface = createToolBarButton(Messages.getString("LooksFrame.29"), "button-wif.png");
        webinterface.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String error = null;
                if (PMS.get().getWebInterface() != null && isNotBlank(PMS.get().getWebInterface().getUrl())) {
                    try {
                        URI uri = new URI(PMS.get().getWebInterface().getUrl());
                        try {
                            Desktop.getDesktop().browse(uri);
                        } catch (RuntimeException | IOException be) {
                            LOGGER.error("Cound not open the default web browser: {}", be.getMessage());
                            LOGGER.trace("", be);
                            error = Messages.getString("LooksFrame.BrowserError") + "\n" + be.getMessage();
                        }
                    } catch (URISyntaxException se) {
                        LOGGER.error("Could not form a valid web interface URI from \"{}\": {}",
                                PMS.get().getWebInterface().getUrl(), se.getMessage());
                        LOGGER.trace("", se);
                        error = Messages.getString("LooksFrame.URIError");
                    }
                } else {
                    error = Messages.getString("LooksFrame.URIError");
                }
                if (error != null) {
                    JOptionPane.showMessageDialog(null, error, Messages.getString("Dialog.Error"),
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        });
        webinterface.setToolTipText(Messages.getString("LooksFrame.30"));
        webinterface.setEnabled(configuration.useWebInterface());
        toolBar.add(webinterface);
        toolBar.addSeparator(new Dimension(20, 1));
    }

    restartIcon = (AnimatedIcon) reload.getIcon();
    restartRequredIcon.start();
    setReloadable(false);
    reload.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            reload.setEnabled(false);
            PMS.get().reset();
        }
    });
    reload.setToolTipText(Messages.getString("LooksFrame.28"));
    toolBar.add(reload);

    toolBar.addSeparator(new Dimension(20, 1));
    AbstractButton quit = createToolBarButton(Messages.getString("LooksFrame.5"), "button-quit.png");
    quit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            quit();
        }
    });
    toolBar.add(quit);
    if (System.getProperty(START_SERVICE) != null) {
        quit.setEnabled(false);
    }
    toolBar.add(new JPanel());

    // Apply the orientation to the toolbar and all components in it
    ComponentOrientation orientation = ComponentOrientation.getOrientation(PMS.getLocale());
    toolBar.applyComponentOrientation(orientation);
    toolBar.setBorder(new EmptyBorder(new Insets(8, 0, 0, 0)));

    panel.add(toolBar, BorderLayout.NORTH);
    panel.add(buildMain(), BorderLayout.CENTER);
    status = new JLabel("");
    status.setBorder(BorderFactory.createEmptyBorder());
    status.setComponentOrientation(orientation);

    // Calling applyComponentOrientation() here would be ideal.
    // Alas it horribly mutilates the layout of several tabs.
    //panel.applyComponentOrientation(orientation);
    panel.add(status, BorderLayout.SOUTH);

    return panel;
}

From source file:ome.formats.importer.gui.FileQueueChooser.java

/**
 * File chooser on the file picker tab of the importer
 * /*from w  w  w. j av a2  s. com*/
 * @param config ImportConfig
 * @param scanReader OmeroWrapper
 */
FileQueueChooser(ImportConfig config, OMEROWrapper scanReader) {

    try {
        JPanel fp = null;
        JToolBar tb = null;

        String refreshIcon = "gfx/recycled12.png";
        refreshBtn = GuiCommonElements.addBasicButton("Refresh ", refreshIcon, null);
        refreshBtn.setActionCommand(REFRESHED);
        refreshBtn.addActionListener(this);
        JPanel panel = new JPanel();

        // Set up the main panel for tPane, quit, and send buttons
        double mainTable[][] = { { 10, TableLayout.FILL, TableLayout.PREFERRED, TableLayout.FILL, 10 }, // columns
                { TableLayout.PREFERRED } }; // rows

        TableLayout tl = new TableLayout(mainTable);
        panel.setLayout(tl);

        // Here's a nice little pieces of test code to find all components
        if (DEBUG) {
            try {
                Component[] components = this.getComponents();
                Component component = null;
                System.err.println("Components: " + components.length);
                for (int i = 0; i < components.length; i++) {
                    component = components[i];
                    System.err.println("Component " + i + " = " + component.getClass());
                }
            } catch (Exception e) {
                log.info("component exception ignore");
            }
        }

        if (laf.contains("AquaLookAndFeel")) {
            //Do Aqua implimentation
            fp = (JPanel) this.getComponent(1);
            fp.setLayout(new BoxLayout(fp, BoxLayout.X_AXIS));
            fp.add(refreshBtn);
        } else if (laf.contains("QuaquaLookAndFeel")) {
            //do Quaqua implimentation
            fp = (JPanel) this.getComponent(1);
            panel.add(refreshBtn, "1,0,C,C");
            panel.add(fp.getComponent(0), "2,0,C,C");
            fp.add(panel, BorderLayout.NORTH);
        } else if (laf.contains("Windows")) {
            try {
                //Do windows implimentation
                tb = (JToolBar) this.getComponent(1);
                refreshBtn.setToolTipText("Refresh");
                refreshBtn.setText(null);
                tb.add(refreshBtn, 8);
            } catch (Exception e) {
                log.info("Exception ignored.");
            }
        }
        /* Disabled temporarily */
        else if (laf.contains("MetalLookAndFeel")) {
            //Do Metal implimentation
            JPanel prefp = (JPanel) this.getComponent(0);
            fp = (JPanel) prefp.getComponent(0);
            refreshBtn.setToolTipText("Refresh");
            refreshBtn.setText(null);
            Dimension size = new Dimension(24, 24);
            refreshBtn.setMaximumSize(size);
            refreshBtn.setPreferredSize(size);
            refreshBtn.setMinimumSize(size);
            refreshBtn.setSize(size);
            fp.add(Box.createRigidArea(new Dimension(5, 0)));
            fp.add(refreshBtn);
        }

        else if (laf.contains("GTKLookAndFeel")) {
            //do GTK implimentation
            fp = (JPanel) this.getComponent(0);
            refreshBtn.setIcon(null);
            fp.add(refreshBtn);
        } else if (laf.contains("MotifLookAndFeel")) {
            //do Motif implimentation
            fp = (JPanel) this.getComponent(0);
            fp.add(refreshBtn);
        }

        if (fp != null && DEBUG == true) {
            fp.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red),
                    fp.getBorder()));
            System.err.println(fp.getLayout());
        }

        if (tb != null && DEBUG == true) {
            tb.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red),
                    tb.getBorder()));
            System.err.println(tb.getLayout());
        }
    } catch (ArrayIndexOutOfBoundsException e) {
    }

    File dir = null;
    if (config != null)
        dir = config.savedDirectory.get();

    if (dir != null) {
        this.setCurrentDirectory(dir);
    } else {
        this.setCurrentDirectory(this.getFileSystemView().getHomeDirectory());
    }

    this.setControlButtonsAreShown(false);
    this.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    this.setMultiSelectionEnabled(true);
    this.setDragEnabled(true);

    setAcceptAllFileFilterUsed(false);

    FileFilter[] originalFF = null;
    int readerFFSize = 0;
    if (scanReader != null) {
        originalFF = loci.formats.gui.GUITools.buildFileFilters(scanReader.getImageReader());
        FileFilter filter;
        List<FileFilter> extensionFilters = new ArrayList<FileFilter>();
        for (int i = 0; i < originalFF.length; i++) {
            filter = originalFF[i];
            if (filter instanceof ComboFileFilter) {
                ComboFileFilter cff = (ComboFileFilter) filter;
                extensionFilters.add(cff);
                extensionFilters.addAll(Arrays.asList(cff.getFilters()));
                break;
            }
        }
        if (extensionFilters != null) {
            originalFF = extensionFilters.toArray(new FileFilter[extensionFilters.size()]);
        }
        readerFFSize = originalFF.length;
    }

    FileFilter[] ff = new FileFilter[readerFFSize + 7];
    ff[0] = new DashFileFilter();
    ff[readerFFSize + 1] = new DashFileFilter();
    ff[readerFFSize + 2] = new R3DNewFileFilter();
    ff[readerFFSize + 3] = new R3DOldFileFilter();
    ff[readerFFSize + 4] = new D3DNewFileFilter();
    ff[readerFFSize + 5] = new D3DOldFileFilter();
    ff[readerFFSize + 6] = new D3DNPrjFileFilter();

    if (originalFF != null)
        System.arraycopy(originalFF, 0, ff, 1, originalFF.length);

    //this.addChoosableFileFilter(new DashFileFilter());

    //FileFilter combo = null;
    for (int i = 0; i < ff.length; i++)
        this.addChoosableFileFilter(ff[i]);
    this.setFileFilter(ff[1]);

    //Retrieve all JLists and JTables from the fileChooser
    fileListObjects = getFileListObjects(this);

    //For now, assume the first list/table found is the correct one
    //(this will need to be adjusted if LAF bugs crop up)
    //Shouldn't break anything since dblclick will just stop working if
    //this changes for some reason
    if (fileListObjects.length > 0 && !laf.contains("Windows")) {
        fileList = fileListObjects[0];
        MouseCommand mc = new MouseCommand();
        fileList.addMouseListener(mc);
    }
}

From source file:org.apache.cayenne.modeler.editor.EditorView.java

private void initView() {

    // init widgets
    JButton collapseButton = getAction(CollapseTreeAction.class).buildButton();
    collapseButton.setPreferredSize(new Dimension(30, 20));
    JButton filterButton = getAction(FilterAction.class).buildButton();
    filterButton.setPreferredSize(new Dimension(30, 20));
    actionManager.getAction(CollapseTreeAction.class).setAlwaysOn(true);
    actionManager.getAction(FilterAction.class).setAlwaysOn(true);

    JToolBar barPanel = new JToolBar();
    barPanel.setMinimumSize(new Dimension(75, 25));
    barPanel.setBorder(BorderFactory.createEtchedBorder());
    barPanel.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    barPanel.add(Box.createHorizontalStrut(3));
    barPanel.add(filterButton);//from   w ww  . ja  v  a 2  s.c o  m
    barPanel.addSeparator();
    barPanel.add(collapseButton);

    treePanel = new ProjectTreeView(eventController);
    treePanel.setMinimumSize(new Dimension(75, 180));
    JPanel treeNavigatePanel = new JPanel();
    treeNavigatePanel.setMinimumSize(new Dimension(75, 220));
    treeNavigatePanel.setLayout(new BorderLayout());
    treeNavigatePanel.add(treePanel, BorderLayout.CENTER);

    this.detailPanel = new JPanel();
    this.splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    this.leftPanel = new JPanel(new BorderLayout());
    // assemble...

    this.detailLayout = new CardLayout();
    detailPanel.setLayout(detailLayout);

    // some but not all panels must be wrapped in a scroll pane
    // those that are not wrapped usually have there own scrollers
    // in subpanels...

    detailPanel.add(new JPanel(), EMPTY_VIEW);

    dataDomainView = new DataDomainTabbedView(eventController);
    detailPanel.add(dataDomainView, DOMAIN_VIEW);

    DataNodeEditor nodeController = new DataNodeEditor(eventController);
    detailPanel.add(nodeController.getView(), NODE_VIEW);

    dataNodeView = nodeController.getTabComponent();

    dataMapView = new DataMapTabbedView(eventController);
    detailPanel.add(dataMapView, DATA_MAP_VIEW);

    procedureView = new ProcedureTabbedView(eventController);
    detailPanel.add(procedureView, PROCEDURE_VIEW);

    selectQueryView = new SelectQueryTabbedView(eventController);
    detailPanel.add(selectQueryView, SELECT_QUERY_VIEW);

    sqlTemplateView = new SQLTemplateTabbedView(eventController);
    detailPanel.add(sqlTemplateView, SQL_TEMPLATE_VIEW);

    Component procedureQueryView = new ProcedureQueryView(eventController);
    detailPanel.add(new JScrollPane(procedureQueryView), PROCEDURE_QUERY_VIEW);

    ejbqlQueryView = new EjbqlTabbedView(eventController);
    detailPanel.add(ejbqlQueryView, EJBQL_QUERY_VIEW);

    embeddableView = new EmbeddableTabbedView(eventController);
    detailPanel.add(embeddableView, EMBEDDABLE_VIEW);

    objDetailView = new ObjEntityTabbedView(eventController);
    detailPanel.add(objDetailView, OBJ_VIEW);

    dbDetailView = new DbEntityTabbedView(eventController);
    detailPanel.add(dbDetailView, DB_VIEW);

    leftPanel.add(barPanel, BorderLayout.NORTH);
    leftPanel.add(new JScrollPane(treeNavigatePanel), BorderLayout.CENTER);
    splitPane.setLeftComponent(leftPanel);
    splitPane.setRightComponent(detailPanel);

    setLayout(new BorderLayout());
    add(splitPane, BorderLayout.CENTER);

}

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

/**
 * Creates a tool bar and adds the passed buttons to it.
 * //from   w  w  w.jav  a 2  s . c  o  m
 * @param addButton The button to add.
 * @param removeButton The button to add.
 * @return See above.
 */
private JToolBar createBar(JButton addButton, JButton removeButton) {
    JToolBar bar = new JToolBar();
    bar.setFloatable(false);
    bar.setBorder(null);
    bar.setBackground(UIUtilities.BACKGROUND_COLOR);
    if (addButton != null)
        bar.add(addButton);
    if (removeButton != null)
        bar.add(removeButton);
    return bar;
}

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);/*from   w w  w.  j  a  va2  s . com*/
    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);
    }
}