Example usage for javax.swing JToolBar setFloatable

List of usage examples for javax.swing JToolBar setFloatable

Introduction

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

Prototype

@BeanProperty(preferred = true, description = "Can the tool bar be made to float by the user?")
public void setFloatable(boolean b) 

Source Link

Document

Sets the floatable property, which must be true for the user to move the tool bar.

Usage

From source file:com.net2plan.gui.tools.GUINetworkDesign.java

private JPanel configureLeftBottomPanel() {
    this.focusPanel = new FocusPane(this);
    final JPanel focusPanelContainer = new JPanel(new BorderLayout());
    final JToolBar navigationToolbar = new JToolBar(JToolBar.VERTICAL);
    navigationToolbar.setRollover(true);
    navigationToolbar.setFloatable(false);
    navigationToolbar.setOpaque(false);//from   www .ja v  a2s. c o m

    final JButton btn_pickNavigationUndo, btn_pickNavigationRedo;

    btn_pickNavigationUndo = new JButton("");
    btn_pickNavigationUndo
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/undoPick.png")));
    btn_pickNavigationUndo.setToolTipText("Navigate back to the previous element picked");
    btn_pickNavigationRedo = new JButton("");
    btn_pickNavigationRedo
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/redoPick.png")));
    btn_pickNavigationRedo.setToolTipText("Navigate forward to the next element picked");

    final ActionListener action = e -> {
        Pair<NetworkElement, Pair<Demand, Link>> backOrForward;
        do {
            backOrForward = (e.getSource() == btn_pickNavigationUndo)
                    ? GUINetworkDesign.this.getVisualizationState().getPickNavigationBackElement()
                    : GUINetworkDesign.this.getVisualizationState().getPickNavigationForwardElement();
            if (backOrForward == null)
                break;
            final NetworkElement ne = backOrForward.getFirst(); // For network elements
            final Pair<Demand, Link> fr = backOrForward.getSecond(); // For forwarding rules
            if (ne != null) {
                if (ne.getNetPlan() != GUINetworkDesign.this.getDesign())
                    continue;
                if (ne.getNetPlan() == null)
                    continue;
                break;
            } else if (fr != null) {
                if (fr.getFirst().getNetPlan() != GUINetworkDesign.this.getDesign())
                    continue;
                if (fr.getFirst().getNetPlan() == null)
                    continue;
                if (fr.getSecond().getNetPlan() != GUINetworkDesign.this.getDesign())
                    continue;
                if (fr.getSecond().getNetPlan() == null)
                    continue;
                break;
            } else
                break; // null,null => reset picked state
        } while (true);
        if (backOrForward != null) {
            if (backOrForward.getFirst() != null)
                GUINetworkDesign.this.getVisualizationState().pickElement(backOrForward.getFirst());
            else if (backOrForward.getSecond() != null)
                GUINetworkDesign.this.getVisualizationState().pickForwardingRule(backOrForward.getSecond());
            else
                GUINetworkDesign.this.getVisualizationState().resetPickedState();

            GUINetworkDesign.this.updateVisualizationAfterPick();
        }
    };

    btn_pickNavigationUndo.addActionListener(action);
    btn_pickNavigationRedo.addActionListener(action);

    btn_pickNavigationRedo.setFocusable(false);
    btn_pickNavigationUndo.setFocusable(false);

    navigationToolbar.add(btn_pickNavigationUndo);
    navigationToolbar.add(btn_pickNavigationRedo);

    final JScrollPane scPane = new JScrollPane(focusPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scPane.getVerticalScrollBar().setUnitIncrement(20);
    scPane.getHorizontalScrollBar().setUnitIncrement(20);
    scPane.setBorder(BorderFactory.createEmptyBorder());

    // Control the scroll
    scPane.getHorizontalScrollBar().addAdjustmentListener(e -> {
        // Repaints the panel each time the horizontal scroll bar is moves, in order to avoid ghosting.
        focusPanelContainer.revalidate();
        focusPanelContainer.repaint();
    });

    focusPanelContainer.add(navigationToolbar, BorderLayout.WEST);
    focusPanelContainer.add(scPane, BorderLayout.CENTER);

    JPanel pane = new JPanel(new MigLayout("fill, insets 0 0 0 0"));
    pane.setBorder(BorderFactory.createTitledBorder(new LineBorder(Color.BLACK), "Focus panel"));

    pane.add(focusPanelContainer, "grow");
    return pane;
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakListChartPanel.java

private JToolBar createToolBar() {
    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);

    toolbar.add(theActionManager.get("new"));
    toolbar.add(theActionManager.get("open"));

    toolbar.addSeparator();/*from  www . j a v a2  s  . com*/

    toolbar.add(theActionManager.get("print"));

    toolbar.addSeparator();

    toolbar.add(theActionManager.get("arrow"));
    toolbar.add(theActionManager.get("hand"));

    toolbar.addSeparator();

    toolbar.add(theActionManager.get("zoomnone"));
    toolbar.add(theActionManager.get("zoomin"));
    toolbar.add(theActionManager.get("zoomout"));

    toolbar.addSeparator();

    toolbar.add(mslevel_button = new JButton(theActionManager.get("mslevel=msms")));
    mslevel_button.setText(null);
    toolbar.add(theActionManager.get("annotatepeaks"));

    toolbar.addSeparator();

    toolbar.add(isotopes_button = new JButton(theActionManager.get("updateisotopecurves=true")));
    isotopes_button.setText(null);
    toolbar.add(ftmode_button = new JButton(theActionManager.get("showallisotopes=true")));
    ftmode_button.setText(null);

    return toolbar;
}

From source file:com.net2plan.gui.utils.topologyPane.TopologyPanel.java

/**
 * Default constructor.//  www  . java 2  s  .com
 *
 * @param callback               Topology callback listening plugin events
 * @param defaultDesignDirectory Default location for design {@code .n2p} files (it may be null, then default is equal to {@code net2planFolder/workspace/data/networkTopologies})
 * @param defaultDemandDirectory Default location for design {@code .n2p} files (it may be null, then default is equal to {@code net2planFolder/workspace/data/trafficMatrices})
 * @param canvasType             Canvas type (i.e. JUNG)
 * @param plugins                List of plugins to be included (it may be null)
 */
public TopologyPanel(final IVisualizationCallback callback, File defaultDesignDirectory,
        File defaultDemandDirectory, Class<? extends ITopologyCanvas> canvasType,
        List<ITopologyCanvasPlugin> plugins) {
    File currentDir = SystemUtils.getCurrentDir();

    this.callback = callback;
    this.defaultDesignDirectory = defaultDesignDirectory == null ? new File(
            currentDir + SystemUtils.getDirectorySeparator() + "workspace" + SystemUtils.getDirectorySeparator()
                    + "data" + SystemUtils.getDirectorySeparator() + "networkTopologies")
            : defaultDesignDirectory;
    this.defaultDemandDirectory = defaultDemandDirectory == null ? new File(
            currentDir + SystemUtils.getDirectorySeparator() + "workspace" + SystemUtils.getDirectorySeparator()
                    + "data" + SystemUtils.getDirectorySeparator() + "trafficMatrices")
            : defaultDemandDirectory;
    this.multilayerControlPanel = new MultiLayerControlPanel(callback);

    try {
        canvas = canvasType.getDeclaredConstructor(IVisualizationCallback.class, TopologyPanel.class)
                .newInstance(callback, this);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    if (plugins != null)
        for (ITopologyCanvasPlugin plugin : plugins)
            addPlugin(plugin);

    setLayout(new BorderLayout());

    JToolBar toolbar = new JToolBar();
    toolbar.setRollover(true);
    toolbar.setFloatable(false);
    toolbar.setOpaque(false);
    toolbar.setBorderPainted(false);

    JPanel topPanel = new JPanel(new BorderLayout());
    topPanel.add(toolbar, BorderLayout.NORTH);

    add(topPanel, BorderLayout.NORTH);

    JComponent canvasComponent = canvas.getCanvasComponent();

    canvasPanel = new JPanel(new BorderLayout());
    canvasComponent.setBorder(LineBorder.createBlackLineBorder());

    JToolBar multiLayerToolbar = new JToolBar(JToolBar.VERTICAL);
    multiLayerToolbar.setRollover(true);
    multiLayerToolbar.setFloatable(false);
    multiLayerToolbar.setOpaque(false);

    canvasPanel.add(canvasComponent, BorderLayout.CENTER);
    canvasPanel.add(multiLayerToolbar, BorderLayout.WEST);
    add(canvasPanel, BorderLayout.CENTER);

    btn_load = new JButton();
    btn_load.setToolTipText("Load a network design");
    btn_loadDemand = new JButton();
    btn_loadDemand.setToolTipText("Load a traffic demand set");
    btn_save = new JButton();
    btn_save.setToolTipText("Save current state to a file");
    btn_zoomIn = new JButton();
    btn_zoomIn.setToolTipText("Zoom in");
    btn_zoomOut = new JButton();
    btn_zoomOut.setToolTipText("Zoom out");
    btn_zoomAll = new JButton();
    btn_zoomAll.setToolTipText("Zoom all");
    btn_takeSnapshot = new JButton();
    btn_takeSnapshot.setToolTipText("Take a snapshot of the canvas");
    btn_showNodeNames = new JToggleButton();
    btn_showNodeNames.setToolTipText("Show/hide node names");
    btn_showLinkIds = new JToggleButton();
    btn_showLinkIds.setToolTipText(
            "Show/hide link utilization, measured as the ratio between the total traffic in the link (including that in protection segments) and total link capacity (including that reserved by protection segments)");
    btn_showNonConnectedNodes = new JToggleButton();
    btn_showNonConnectedNodes.setToolTipText("Show/hide non-connected nodes");
    btn_increaseNodeSize = new JButton();
    btn_increaseNodeSize.setToolTipText("Increase node size");
    btn_decreaseNodeSize = new JButton();
    btn_decreaseNodeSize.setToolTipText("Decrease node size");
    btn_increaseFontSize = new JButton();
    btn_increaseFontSize.setToolTipText("Increase font size");
    btn_decreaseFontSize = new JButton();
    btn_decreaseFontSize.setToolTipText("Decrease font size");
    /* Multilayer buttons */
    btn_increaseInterLayerDistance = new JButton();
    btn_increaseInterLayerDistance
            .setToolTipText("Increase the distance between layers (when more than one layer is visible)");
    btn_decreaseInterLayerDistance = new JButton();
    btn_decreaseInterLayerDistance
            .setToolTipText("Decrease the distance between layers (when more than one layer is visible)");
    btn_showLowerLayerInfo = new JToggleButton();
    btn_showLowerLayerInfo
            .setToolTipText("Shows the links in lower layers that carry traffic of the picked element");
    btn_showLowerLayerInfo.setSelected(getVisualizationState().isShowInCanvasLowerLayerPropagation());
    btn_showUpperLayerInfo = new JToggleButton();
    btn_showUpperLayerInfo.setToolTipText(
            "Shows the links in upper layers that carry traffic that appears in the picked element");
    btn_showUpperLayerInfo.setSelected(getVisualizationState().isShowInCanvasUpperLayerPropagation());
    btn_showThisLayerInfo = new JToggleButton();
    btn_showThisLayerInfo.setToolTipText(
            "Shows the links in the same layer as the picked element, that carry traffic that appears in the picked element");
    btn_showThisLayerInfo.setSelected(getVisualizationState().isShowInCanvasThisLayerPropagation());
    btn_npChangeUndo = new JButton();
    btn_npChangeUndo.setToolTipText(
            "Navigate back to the previous state of the network (last time the network design was changed)");
    btn_npChangeRedo = new JButton();
    btn_npChangeRedo.setToolTipText(
            "Navigate forward to the next state of the network (when network design was changed");

    btn_osmMap = new JToggleButton();
    btn_osmMap.setToolTipText(
            "Toggle between on/off the OSM support. An internet connection is required in order for this to work.");
    btn_tableControlWindow = new JButton();
    btn_tableControlWindow.setToolTipText("Show the network topology control window.");

    // MultiLayer control window
    JPopupMenu multiLayerPopUp = new JPopupMenu();
    multiLayerPopUp.add(multilayerControlPanel);
    JPopUpButton btn_multilayer = new JPopUpButton("", multiLayerPopUp);

    btn_reset = new JButton("Reset");
    btn_reset.setToolTipText("Reset the user interface");
    btn_reset.setMnemonic(KeyEvent.VK_R);

    btn_load.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/loadDesign.png")));
    btn_loadDemand.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/loadDemand.png")));
    btn_save.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/saveDesign.png")));
    btn_showNodeNames
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNodeName.png")));
    btn_showLinkIds
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLinkUtilization.png")));
    btn_showNonConnectedNodes.setIcon(
            new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNonConnectedNodes.png")));
    //btn_whatIfActivated.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNonConnectedNodes.png")));
    btn_zoomIn.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomIn.png")));
    btn_zoomOut.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomOut.png")));
    btn_zoomAll.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomAll.png")));
    btn_takeSnapshot.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/takeSnapshot.png")));
    btn_increaseNodeSize
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseNode.png")));
    btn_decreaseNodeSize
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseNode.png")));
    btn_increaseFontSize
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseFont.png")));
    btn_decreaseFontSize
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseFont.png")));
    btn_increaseInterLayerDistance.setIcon(
            new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseLayerDistance.png")));
    btn_decreaseInterLayerDistance.setIcon(
            new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseLayerDistance.png")));
    btn_multilayer
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerControl.png")));
    btn_showThisLayerInfo
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerPropagation.png")));
    btn_showUpperLayerInfo.setIcon(
            new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerUpperPropagation.png")));
    btn_showLowerLayerInfo.setIcon(
            new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerLowerPropagation.png")));
    btn_tableControlWindow
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showControl.png")));
    btn_osmMap.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showOSM.png")));
    btn_npChangeUndo.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/undoButton.png")));
    btn_npChangeRedo.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/redoButton.png")));

    btn_load.addActionListener(this);
    btn_loadDemand.addActionListener(this);
    btn_save.addActionListener(this);
    btn_showNodeNames.addActionListener(this);
    btn_showLinkIds.addActionListener(this);
    btn_showNonConnectedNodes.addActionListener(this);
    btn_zoomIn.addActionListener(this);
    btn_zoomOut.addActionListener(this);
    btn_zoomAll.addActionListener(this);
    btn_takeSnapshot.addActionListener(this);
    btn_reset.addActionListener(this);
    btn_increaseInterLayerDistance.addActionListener(this);
    btn_decreaseInterLayerDistance.addActionListener(this);
    btn_showLowerLayerInfo.addActionListener(this);
    btn_showUpperLayerInfo.addActionListener(this);
    btn_showThisLayerInfo.addActionListener(this);
    btn_increaseNodeSize.addActionListener(this);
    btn_decreaseNodeSize.addActionListener(this);
    btn_increaseFontSize.addActionListener(this);
    btn_decreaseFontSize.addActionListener(this);
    btn_npChangeUndo.addActionListener(this);
    btn_npChangeRedo.addActionListener(this);
    btn_osmMap.addActionListener(this);
    btn_tableControlWindow.addActionListener(this);

    toolbar.add(btn_load);
    toolbar.add(btn_loadDemand);
    toolbar.add(btn_save);
    toolbar.add(new JToolBar.Separator());
    toolbar.add(btn_zoomIn);
    toolbar.add(btn_zoomOut);
    toolbar.add(btn_zoomAll);
    toolbar.add(btn_takeSnapshot);
    toolbar.add(new JToolBar.Separator());
    toolbar.add(btn_showNodeNames);
    toolbar.add(btn_showLinkIds);
    toolbar.add(btn_showNonConnectedNodes);
    toolbar.add(new JToolBar.Separator());
    toolbar.add(btn_increaseNodeSize);
    toolbar.add(btn_decreaseNodeSize);
    toolbar.add(btn_increaseFontSize);
    toolbar.add(btn_decreaseFontSize);
    toolbar.add(new JToolBar.Separator());
    toolbar.add(Box.createHorizontalGlue());
    toolbar.add(btn_osmMap);
    toolbar.add(btn_tableControlWindow);
    toolbar.add(btn_reset);

    multiLayerToolbar.add(new JToolBar.Separator());
    multiLayerToolbar.add(btn_multilayer);
    multiLayerToolbar.add(btn_increaseInterLayerDistance);
    multiLayerToolbar.add(btn_decreaseInterLayerDistance);
    multiLayerToolbar.add(btn_showLowerLayerInfo);
    multiLayerToolbar.add(btn_showUpperLayerInfo);
    multiLayerToolbar.add(btn_showThisLayerInfo);
    multiLayerToolbar.add(Box.createVerticalGlue());
    multiLayerToolbar.add(btn_npChangeUndo);
    multiLayerToolbar.add(btn_npChangeRedo);

    this.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            if (e.getComponent().getSize().getHeight() != 0 && e.getComponent().getSize().getWidth() != 0) {
                canvas.zoomAll();
            }
        }
    });

    List<Component> children = SwingUtils.getAllComponents(this);
    for (Component component : children)
        if (component instanceof AbstractButton)
            component.setFocusable(false);

    if (ErrorHandling.isDebugEnabled()) {
        canvas.getCanvasComponent().addMouseMotionListener(new MouseMotionAdapter() {
            @Override
            public void mouseMoved(MouseEvent e) {
                Point point = e.getPoint();
                position.setText("view = " + point + ", NetPlan coord = "
                        + canvas.getCanvasPointFromNetPlanPoint(point));
            }
        });

        position = new JLabel();
        add(position, BorderLayout.SOUTH);
    } else {
        position = null;
    }

    new FileDrop(canvasComponent, new LineBorder(Color.BLACK), new FileDrop.Listener() {
        @Override
        public void filesDropped(File[] files) {
            for (File file : files) {
                try {
                    if (!file.getName().toLowerCase(Locale.getDefault()).endsWith(".n2p"))
                        return;
                    loadDesignFromFile(file);
                    break;
                } catch (Throwable e) {
                    break;
                }
            }
        }
    });

    btn_showNodeNames.setSelected(getVisualizationState().isCanvasShowNodeNames());
    btn_showLinkIds.setSelected(getVisualizationState().isCanvasShowLinkLabels());
    btn_showNonConnectedNodes.setSelected(getVisualizationState().isCanvasShowNonConnectedNodes());

    final ITopologyCanvasPlugin popupPlugin = new PopupMenuPlugin(callback, this.canvas);
    addPlugin(new PanGraphPlugin(callback, canvas, MouseEvent.BUTTON1_MASK));
    if (callback.getVisualizationState().isNetPlanEditable() && getCanvas() instanceof JUNGCanvas)
        addPlugin(new AddLinkGraphPlugin(callback, canvas, MouseEvent.BUTTON1_MASK,
                MouseEvent.BUTTON1_MASK | MouseEvent.SHIFT_MASK));
    addPlugin(popupPlugin);
    if (callback.getVisualizationState().isNetPlanEditable())
        addPlugin(new MoveNodePlugin(callback, canvas, MouseEvent.BUTTON1_MASK | MouseEvent.CTRL_MASK));

    setBorder(BorderFactory.createTitledBorder(new LineBorder(Color.BLACK), "Network topology"));
    //        setAllowLoadTrafficDemand(callback.allowLoadTrafficDemands());
}

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

/**
 * Customization of external program paths.
 *
 * @param prefs a <code>JabRefPreferences</code> value
 *//*from  w  w w.j  a  va 2s . c  om*/
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:de.ailis.xadrian.frames.MainFrame.java

/**
 * Creates the tool bar./*  www. ja  v  a2  s .  co m*/
 */
private void createToolBar() {
    final JToolBar toolBar = new JToolBar(SwingConstants.HORIZONTAL);
    toolBar.setFloatable(false);
    toolBar.setRollover(true);
    toolBar.add(this.exitAction);
    toolBar.addSeparator();
    toolBar.add(this.newAction);
    toolBar.add(this.openAction);
    toolBar.add(this.closeAction);
    toolBar.add(this.saveAction);
    toolBar.add(this.printAction);
    toolBar.addSeparator();
    toolBar.add(this.addFactoryAction);
    toolBar.add(this.changeSectorAction);
    toolBar.add(this.changeSunsAction);
    toolBar.add(this.changePricesAction);
    final JToggleButton btn = new JToggleButton(this.toggleBaseComplexAction);
    btn.setHideActionText(true);
    toolBar.add(btn);
    add(toolBar, BorderLayout.NORTH);

    installStatusHandler(toolBar);
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.SpectraPanel.java

private JToolBar createToolBar() {
    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);

    toolbar.add(theActionManager.get("previous"));
    toolbar.add(theActionManager.get("close"));
    toolbar.add(theActionManager.get("next"));

    toolbar.addSeparator();//w  w  w  .ja v  a 2 s .com

    toolbar.add(theActionManager.get("new"));
    toolbar.add(theActionManager.get("openspectra"));
    toolbar.add(theActionManager.get("edit"));

    toolbar.addSeparator();

    toolbar.add(theActionManager.get("print"));

    toolbar.addSeparator();

    toolbar.add(theActionManager.get("arrow"));
    toolbar.add(theActionManager.get("hand"));

    toolbar.addSeparator();

    toolbar.add(theActionManager.get("zoomnone"));
    toolbar.add(theActionManager.get("zoomin"));
    toolbar.add(theActionManager.get("zoomout"));

    toolbar.addSeparator();

    toolbar.add(mslevel_button = new JButton(theActionManager.get("mslevel=msms")));
    mslevel_button.setText(null);
    toolbar.add(theActionManager.get("addpeaks"));
    toolbar.add(theActionManager.get("annotatepeaks"));

    toolbar.addSeparator();

    toolbar.add(theActionManager.get("noisefilter"));
    toolbar.add(theActionManager.get("baselinecorrection"));
    toolbar.add(theActionManager.get("centroid"));
    toolbar.add(isotopes_button = new JButton(theActionManager.get("updateisotopecurves=false")));
    isotopes_button.setText(null);
    toolbar.add(ftmode_button = new JButton(theActionManager.get("showallisotopes=true")));
    ftmode_button.setText(null);

    return toolbar;
}

From source file:com.nbt.TreeFrame.java

protected JToolBar createToolBar() {
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);

    Action[] actions = { /* newAction, */browseAction, saveAction, /* saveAsAction, */refreshAction, null,
            deleteAction, null, openAction, null, addByteAction, addShortAction, addIntAction, addLongAction,
            addFloatAction, addDoubleAction, addByteArrayAction, addStringAction, addListAction,
            addCompoundAction };//from w  ww .  j a  v a 2 s. co m
    for (Action action : actions) {
        if (action == null) {
            toolBar.addSeparator();
        } else {
            ToolBarButton button = new ToolBarButton(action);
            toolBar.add(button);
        }
    }

    return toolBar;
}

From source file:fll.scheduler.SchedulerUI.java

private JToolBar createScheduleToolbar() {
    final JToolBar toolbar = new JToolBar("Schedule Toolbar");
    toolbar.setFloatable(false);

    toolbar.add(mScheduleFilename);//  w  w  w . j  a  v a2  s .c o m
    toolbar.addSeparator();
    toolbar.add(mOpenScheduleAction);
    toolbar.add(mReloadFileAction);
    toolbar.add(mWriteSchedulesAction);
    toolbar.add(mDisplayGeneralScheduleAction);

    return toolbar;
}

From source file:fll.scheduler.SchedulerUI.java

private JToolBar createDescriptionToolbar() {
    final JToolBar toolbar = new JToolBar("Description Toolbar");
    toolbar.setFloatable(false);

    toolbar.add(mDescriptionFilename);//from   www.ja  v  a 2  s .c  o  m
    toolbar.addSeparator();
    toolbar.add(mNewScheduleDescriptionAction);
    toolbar.add(mOpenScheduleDescriptionAction);
    toolbar.add(mSaveScheduleDescriptionAction);
    toolbar.add(mRunSchedulerAction);

    return toolbar;
}

From source file:com._17od.upm.gui.MainWindow.java

private JToolBar createToolBar() {

    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);
    toolbar.setRollover(true);//  w w w .  j a  v a2s.  com

    // The "Add Account" button
    addAccountButton = new JButton();
    addAccountButton.setToolTipText(Translator.translate(ADD_ACCOUNT_TXT));
    addAccountButton.setIcon(Util.loadImage("add_account.gif"));
    addAccountButton.setDisabledIcon(Util.loadImage("add_account_d.gif"));
    ;
    addAccountButton.addActionListener(this);
    addAccountButton.setEnabled(false);
    addAccountButton.setActionCommand(ADD_ACCOUNT_TXT);
    toolbar.add(addAccountButton);

    // The "Edit Account" button
    editAccountButton = new JButton();
    editAccountButton.setToolTipText(Translator.translate(EDIT_ACCOUNT_TXT));
    editAccountButton.setIcon(Util.loadImage("edit_account.gif"));
    editAccountButton.setDisabledIcon(Util.loadImage("edit_account_d.gif"));
    ;
    editAccountButton.addActionListener(this);
    editAccountButton.setEnabled(false);
    editAccountButton.setActionCommand(EDIT_ACCOUNT_TXT);
    toolbar.add(editAccountButton);

    // The "Delete Account" button
    deleteAccountButton = new JButton();
    deleteAccountButton.setToolTipText(Translator.translate(DELETE_ACCOUNT_TXT));
    deleteAccountButton.setIcon(Util.loadImage("delete_account.gif"));
    deleteAccountButton.setDisabledIcon(Util.loadImage("delete_account_d.gif"));
    ;
    deleteAccountButton.addActionListener(this);
    deleteAccountButton.setEnabled(false);
    deleteAccountButton.setActionCommand(DELETE_ACCOUNT_TXT);
    toolbar.add(deleteAccountButton);

    toolbar.addSeparator();

    // The "Copy Username" button
    copyUsernameButton = new JButton();
    copyUsernameButton.setToolTipText(Translator.translate(COPY_USERNAME_TXT));
    copyUsernameButton.setIcon(Util.loadImage("copy_username.gif"));
    copyUsernameButton.setDisabledIcon(Util.loadImage("copy_username_d.gif"));
    ;
    copyUsernameButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            copyUsernameToClipboard();
        }
    });
    copyUsernameButton.setEnabled(false);
    toolbar.add(copyUsernameButton);

    // The "Copy Password" button
    copyPasswordButton = new JButton();
    copyPasswordButton.setToolTipText(Translator.translate(COPY_PASSWORD_TXT));
    copyPasswordButton.setIcon(Util.loadImage("copy_password.gif"));
    copyPasswordButton.setDisabledIcon(Util.loadImage("copy_password_d.gif"));
    ;
    copyPasswordButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            copyPasswordToClipboard();
        }
    });
    copyPasswordButton.setEnabled(false);
    toolbar.add(copyPasswordButton);

    // The "Launch URL" button
    launchURLButton = new JButton();
    launchURLButton.setToolTipText(Translator.translate(LAUNCH_URL_TXT));
    launchURLButton.setIcon(Util.loadImage("launch_URL.gif"));
    launchURLButton.setDisabledIcon(Util.loadImage("launch_URL_d.gif"));
    ;
    launchURLButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            AccountInformation accInfo = dbActions.getSelectedAccount();
            String uRl = accInfo.getUrl();

            // Check if the selected url is null or emty and inform the user
            // via JoptioPane message
            if ((uRl == null) || (uRl.length() == 0)) {
                JOptionPane.showMessageDialog(launchURLButton.getParent(),
                        Translator.translate("EmptyUrlJoptionpaneMsg"),
                        Translator.translate("UrlErrorJoptionpaneTitle"), JOptionPane.WARNING_MESSAGE);

                // Check if the selected url is a valid formated url(via
                // urlIsValid() method) and inform the user via JoptioPane
                // message
            } else if (!(urlIsValid(uRl))) {
                JOptionPane.showMessageDialog(launchURLButton.getParent(),
                        Translator.translate("InvalidUrlJoptionpaneMsg"),
                        Translator.translate("UrlErrorJoptionpaneTitle"), JOptionPane.WARNING_MESSAGE);

                // Call the method LaunchSelectedURL() using the selected
                // url as input
            } else {
                LaunchSelectedURL(uRl);

            }
        }
    });
    launchURLButton.setEnabled(false);
    toolbar.add(launchURLButton);

    toolbar.addSeparator();

    // The "Option" button
    optionsButton = new JButton();
    optionsButton.setToolTipText(Translator.translate(OPTIONS_TXT));
    optionsButton.setIcon(Util.loadImage("options.gif"));
    optionsButton.setDisabledIcon(Util.loadImage("options_d.gif"));
    ;
    optionsButton.addActionListener(this);
    optionsButton.setEnabled(true);
    optionsButton.setActionCommand(OPTIONS_TXT);
    toolbar.add(optionsButton);

    toolbar.addSeparator();

    // The Sync database button
    syncDatabaseButton = new JButton();
    syncDatabaseButton.setToolTipText(Translator.translate(SYNC_DATABASE_TXT));
    syncDatabaseButton.setIcon(Util.loadImage("sync.png"));
    syncDatabaseButton.setDisabledIcon(Util.loadImage("sync_d.png"));
    ;
    syncDatabaseButton.addActionListener(this);
    syncDatabaseButton.setEnabled(false);
    syncDatabaseButton.setActionCommand(SYNC_DATABASE_TXT);
    toolbar.add(syncDatabaseButton);

    return toolbar;
}