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:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_demand.java

public static void createLinkDemandGUI(final NetworkElementType networkElementType,
        final IVisualizationCallback callback) {
    final NetPlan netPlan = callback.getDesign();
    final JComboBox originNodeSelector = new WiderJComboBox();
    final JComboBox destinationNodeSelector = new WiderJComboBox();

    for (Node node : netPlan.getNodes()) {
        final String nodeName = node.getName();
        String nodeLabel = "Node " + node.getIndex();
        if (!nodeName.isEmpty())
            nodeLabel += " (" + nodeName + ")";

        originNodeSelector.addItem(StringLabeller.of(node.getId(), nodeLabel));
        destinationNodeSelector.addItem(StringLabeller.of(node.getId(), nodeLabel));
    }/*from  w ww  .  j  av  a2s.co m*/

    ItemListener nodeListener = new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            long originNodeId = (long) ((StringLabeller) originNodeSelector.getSelectedItem()).getObject();
            long destinationNodeId = (long) ((StringLabeller) destinationNodeSelector.getSelectedItem())
                    .getObject();
            callback.putTransientColorInElementTopologyCanvas(
                    Arrays.asList(netPlan.getNodeFromId(originNodeId)), Color.GREEN);
            callback.putTransientColorInElementTopologyCanvas(
                    Arrays.asList(netPlan.getNodeFromId(destinationNodeId)), Color.CYAN);
        }
    };

    originNodeSelector.addItemListener(nodeListener);
    destinationNodeSelector.addItemListener(nodeListener);

    originNodeSelector.setSelectedIndex(0);
    destinationNodeSelector.setSelectedIndex(1);

    JPanel pane = new JPanel();
    pane.add(networkElementType == NetworkElementType.LINK ? new JLabel("Origin node: ")
            : new JLabel("Ingress node: "));
    pane.add(originNodeSelector);
    pane.add(Box.createHorizontalStrut(15));
    pane.add(networkElementType == NetworkElementType.LINK ? new JLabel("Destination node: ")
            : new JLabel("Egress node: "));
    pane.add(destinationNodeSelector);

    while (true) {
        int result = JOptionPane.showConfirmDialog(null, pane,
                "Please enter end nodes for the new " + networkElementType, JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE);
        if (result != JOptionPane.OK_OPTION)
            return;

        try {
            long originNodeId = (long) ((StringLabeller) originNodeSelector.getSelectedItem()).getObject();
            long destinationNodeId = (long) ((StringLabeller) destinationNodeSelector.getSelectedItem())
                    .getObject();
            Node originNode = netPlan.getNodeFromId(originNodeId);
            Node destinationNode = netPlan.getNodeFromId(destinationNodeId);

            if (netPlan.getNodeFromId(originNodeId) == null)
                throw new Net2PlanException("Node of id: " + originNodeId + " does not exist");
            if (netPlan.getNodeFromId(destinationNodeId) == null)
                throw new Net2PlanException("Node of id: " + destinationNodeId + " does not exist");

            if (networkElementType == NetworkElementType.LINK) {
                final Link e = netPlan.addLink(originNode, destinationNode, 0, 0, 200000, null);
                callback.getVisualizationState()
                        .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals();
                callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.LINK));
                callback.getVisualizationState().pickLink(e);
                callback.updateVisualizationAfterPick();
                callback.getUndoRedoNavigationManager().addNetPlanChange();

            } else {
                final Demand d = netPlan.addDemand(originNode, destinationNode, 0, null);
                callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.DEMAND));
                callback.getVisualizationState().pickDemand(d);
                callback.updateVisualizationAfterPick();
                callback.getUndoRedoNavigationManager().addNetPlanChange();
            }

            break;
        } catch (Throwable ex) {
            ErrorHandling.showErrorDialog(ex.getMessage(), "Error adding " + networkElementType);
        }
    }
}

From source file:com.diversityarrays.dal.server.AskServerParams.java

public AskServerParams(Image serverIconImage, final Window owner, String title, File www,
        DalServerPreferences prefs) {//from ww  w . j a v a2s  . com
    super(owner, title, ModalityType.APPLICATION_MODAL);

    this.wwwRoot = www;
    this.preferences = prefs;

    if (serverIconImage != null) {
        setIconImage(serverIconImage);
    }

    Iterator<DalDbProviderService> iter = ServiceRegistry.lookupProviders(DalDbProviderService.class);
    while (iter.hasNext()) {
        DalDbProviderService s = iter.next();
        factoryTabbedPane.addTab(s.getProviderName(), new ProviderPanel(s));
    }

    List<String> hostnames = DalServerUtil.collectHostnamesForChoice(true);
    hostnameChoice = new JComboBox<String>(hostnames.toArray(new String[hostnames.size()]));

    wwwRootPath.setText(wwwRoot.getPath());

    Box buttons = Box.createHorizontalBox();
    buttons.add(Box.createHorizontalStrut(10));
    buttons.add(okButton);
    buttons.add(Box.createHorizontalGlue());
    buttons.add(cancelButton);
    buttons.add(Box.createHorizontalStrut(10));

    getContentPane().add(BorderLayout.NORTH, initGui());
    getContentPane().add(BorderLayout.SOUTH, buttons);
    pack();

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent e) {
            removeWindowListener(this);
            if (owner != null) {
                GuiUtil.centreOnOwner(AskServerParams.this);
            } else {
                GuiUtil.centreOnScreen(AskServerParams.this);
            }
            okButton.requestFocus(); // unless it is disabled !
        }
    });
}

From source file:com.diversityarrays.kdxplore.trialmgr.trait.TraitExplorerPanel.java

public TraitExplorerPanel(MessagePrinter mp, OfflineData od, DALClientProvider clientProvider,
        // KdxUploadHandler uploadHandler,
        BackgroundRunner backgroundRunner, ImageIcon addBarcodeIcon,
        Transformer<Trial, Boolean> checkIfEditorActive) {
    super(new BorderLayout());

    this.backgroundRunner = backgroundRunner;
    this.clientProvider = clientProvider;
    // this.uploadHandler = uploadHandler;
    this.messagePrinter = mp;
    this.offlineData = od;
    this.checkIfEditorActive = checkIfEditorActive;

    offlineData.addOfflineDataChangeListener(offlineDataListener);

    editingLocked.setIcon(KDClientUtils.getIcon(ImageId.LOCKED));
    editingLocked.addActionListener(new ActionListener() {
        @Override//from   w  w  w .  j av a 2 s  . c o m
        public void actionPerformed(ActionEvent e) {
            changeEditable(editingLocked.isSelected(), DONT_OVERRIDE);
        }
    });

    changeManager.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            updateUndoRedoActions();
        }
    });

    KDClientUtils.initAction(ImageId.TRASH_24, deleteTraitsAction, "Remove Trait");
    deleteTraitsAction.setEnabled(false);

    KDClientUtils.initAction(ImageId.REFRESH_24, refreshAction, "Refresh Data");

    KDClientUtils.initAction(ImageId.PLUS_BLUE_24, addNewTraitAction, "Add Trait");

    KDClientUtils.initAction(ImageId.UPLOAD_24, uploadTraitsAction, "Upload Traits");

    KDClientUtils.initAction(ImageId.ADD_TRIALS_24, importTraitsAction, "Import Traits");

    KDClientUtils.initAction(ImageId.EXPORT_24, exportTraitsAction, "Export Traits");

    try {
        Class.forName("com.diversityarrays.kdxplore.upload.TraitUploadTask");
    } catch (ClassNotFoundException e1) {
        uploadTraitsAction.setEnabled(false);
        if (RunMode.getRunMode().isDeveloper()) {
            new Toast((JComponent) null,
                    "<HTML>Developer Warning<BR>" + "Trait Upload currently unavailable<BR>", 4000)
                            .showAsError();
        }
    }

    traitPropertiesTable
            .setTransferHandler(TableTransferHandler.initialiseForCopySelectAll(traitPropertiesTable, true));
    traitPropertiesTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            if (traitPropertiesTableModel.getRowCount() > 0) {
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        GuiUtil.initialiseTableColumnWidths(traitPropertiesTable);
                    }
                });
                traitPropertiesTableModel.removeTableModelListener(this);
            }
        }
    });

    traitTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            showCorrectCard();
        }
    });

    TrialManagerPreferences preferences = TrialManagerPreferences.getInstance();
    preferences.addChangeListener(TrialManagerPreferences.BAD_FOR_CALC, badForCalcColorChangeListener);
    badForCalc.setForeground(preferences.getBadForCalcColor());
    badForCalc.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isLeftMouseButton(e)) {
                KdxPreference<Color> pref = TrialManagerPreferences.BAD_FOR_CALC;
                String title = pref.getName();
                KdxplorePreferenceEditor.startEditorDialog(TraitExplorerPanel.this, title, pref);
            }
        }
    });

    traitsTable.setAutoCreateRowSorter(true);
    int index = traitTableModel.getTraitNameColumnIndex();
    if (index >= 0) {
        traitsTable.getColumnModel().getColumn(index).setCellRenderer(traitNameCellRenderer);
    }

    traitsTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isLeftMouseButton(e) && 2 == e.getClickCount()) {
                e.consume();

                int vrow = traitsTable.rowAtPoint(e.getPoint());
                if (vrow >= 0) {
                    int mrow = traitsTable.convertRowIndexToModel(vrow);
                    if (mrow >= 0) {
                        Trait trait = traitTableModel.getTraitAtRow(mrow);
                        Integer selectViewRow = null;
                        if (!traitTrialsTableModel.isSelectedTrait(trait)) {
                            selectViewRow = vrow;
                        }
                        if (traitsEditable) {
                            startEditingTraitInternal(trait, selectViewRow, null);
                        } else {
                            warnEditingLocked();
                        }
                    }
                }
            }
        }
    });

    traitsTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    traitsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {

                List<Trait> selectedTraits = getSelectedTraits();
                traitTrialsTableModel.setSelectedTraits(selectedTraits);

                if (selectedTraits.size() == 1) {
                    Trait trait = null;
                    int vrow = traitsTable.getSelectedRow();
                    if (vrow >= 0) {
                        int mrow = traitsTable.convertRowIndexToModel(vrow);
                        if (mrow >= 0) {
                            trait = traitTableModel.getEntityAt(mrow);
                        }
                    }
                    showTraitDetails(trait);
                }

                deleteTraitsAction.setEnabled(selectedTraits.size() > 0);

                showCorrectCard();
            }
        }
    });

    TraitTableModel.initValidationExpressionRenderer(traitsTable);
    if (RunMode.getRunMode().isDeveloper()) {
        TraitTableModel.initTableForRawExpression(traitsTable);
    }
    cardPanel.add(noTraitsComponent, CARD_NO_TRAITS);
    cardPanel.add(selectTraitComponent, CARD_SELECT_TO_EDIT);
    cardPanel.add(new JScrollPane(traitPropertiesTable), CARD_TRAIT_EDITOR);

    JButton undoButton = initAction(undoAction, ImageId.UNDO_24, "Undo",
            KeyStroke.getKeyStroke('Z', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    JButton redoButton = initAction(redoAction, ImageId.REDO_24, "Redo",
            KeyStroke.getKeyStroke('Y', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    Box undoRedoButtons = Box.createHorizontalBox();
    undoRedoButtons.add(undoButton);
    undoRedoButtons.add(redoButton);

    JPanel detailsPanel = new JPanel(new BorderLayout());
    detailsPanel.add(GuiUtil.createLabelSeparator("Details", undoRedoButtons), BorderLayout.NORTH);
    detailsPanel.add(cardPanel, BorderLayout.CENTER);
    detailsPanel.add(legendPanel, BorderLayout.SOUTH);

    PromptScrollPane scrollPane = new PromptScrollPane(traitsTable,
            "Drag/Drop Traits CSV file or use 'Import Traits'");

    TableTransferHandler tth = TableTransferHandler.initialiseForCopySelectAll(traitsTable, true);
    traitsTable.setTransferHandler(new ChainingTransferHandler(flth, tth));

    scrollPane.setTransferHandler(flth);

    if (addBarcodeIcon == null) {
        barcodesMenuAction.putValue(Action.NAME, "Barcodes...");
    } else {
        barcodesMenuAction.putValue(Action.SMALL_ICON, addBarcodeIcon);
    }

    italicsForProtectedCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            traitNameCellRenderer.setUseItalicsForProtected(italicsForProtectedCheckbox.isSelected());
            traitsTable.repaint();
        }
    });

    Box leftTopControls = Box.createHorizontalBox();
    leftTopControls.add(importTraitsButton);
    leftTopControls.add(barcodesMenuButton);
    leftTopControls.add(new JButton(addNewTraitAction));
    leftTopControls.add(new JButton(uploadTraitsAction));
    leftTopControls.add(new JButton(exportTraitsAction));

    leftTopControls.add(Box.createHorizontalGlue());

    leftTopControls.add(editingLocked);
    leftTopControls.add(fixTraitLevelsButton);
    leftTopControls.add(refreshButton);
    leftTopControls.add(Box.createHorizontalStrut(8));
    leftTopControls.add(new JButton(deleteTraitsAction));
    // leftTopControls.add(Box.createHorizontalStrut(4));

    Box explanations = Box.createHorizontalBox();
    explanations.add(italicsForProtectedCheckbox);
    explanations.add(badForCalc);
    explanations.add(Box.createHorizontalGlue());

    fixTraitLevelsButton.setToolTipText("Fix Traits with " + TraitLevel.UNDECIDABLE.visible + " 'Level'");
    fixTraitLevelsButton.setVisible(false);

    JPanel leftTop = new JPanel(new BorderLayout());
    leftTop.add(leftTopControls, BorderLayout.NORTH);
    leftTop.add(scrollPane, BorderLayout.CENTER);
    leftTop.add(explanations, BorderLayout.SOUTH);

    JPanel leftBot = new JPanel(new BorderLayout());
    leftBot.add(GuiUtil.createLabelSeparator("Used by Trials"), BorderLayout.NORTH);
    leftBot.add(new PromptScrollPane(traitTrialsTable, "Any Trials using selected Traits appear here"));

    JSplitPane leftSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, leftTop, leftBot);
    leftSplit.setResizeWeight(0.5);

    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftSplit, detailsPanel);
    splitPane.setOneTouchExpandable(true);
    splitPane.setResizeWeight(0.5);

    add(splitPane, BorderLayout.CENTER);
}

From source file:io.heming.accountbook.ui.MainFrame.java

private void initStatusBar() {
    statusBar = Box.createHorizontalBox();
    statusBar.setPreferredSize(new Dimension(getWidth(), 26));
    statusBar.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0),
            BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)));

    ImageIcon loading = new ImageIcon(getClass().getResource("stopped-loader.png"));
    statusLabel = new JLabel("", loading, JLabel.LEFT);
    statusLabel.setHorizontalAlignment(SwingConstants.LEFT);

    statusBar.add(statusLabel);//from   w w w .  j a v a2  s. com
    statusBar.add(Box.createHorizontalGlue());

    infoLabel = new JLabel();
    infoLabel.setForeground(Color.GRAY);
    infoLabel.setPreferredSize(new Dimension(270, 20));
    infoLabel.setMaximumSize(infoLabel.getPreferredSize());
    statusBar.add(infoLabel);
    statusBar.add(Box.createHorizontalStrut(20));

    pageLabel = new JLabel();
    pageLabel.setForeground(Color.GRAY);
    pageLabel.setPreferredSize(new Dimension(80, 20));
    pageLabel.setMaximumSize(pageLabel.getPreferredSize());
    statusBar.add(pageLabel);

    Insets insets = new Insets(2, 10, 2, 10);
    firstPageButton = new JButton();
    firstPageButton.setMargin(insets);
    firstPageButton.setActionCommand("");
    firstPageButton.setToolTipText("");
    firstPageButton.setIcon(new ImageIcon(getClass().getResource("go-first.png")));
    firstPageButton.addActionListener(e -> firstPage());

    prevPageButton = new JButton();
    prevPageButton.setMargin(insets);
    prevPageButton.setActionCommand("?");
    prevPageButton.setToolTipText("?");
    prevPageButton.setIcon(new ImageIcon(getClass().getResource("go-previous-2.png")));
    prevPageButton.addActionListener(e -> prevPage());

    nextPageButton = new JButton();
    nextPageButton.setMargin(insets);
    nextPageButton.setActionCommand("");
    nextPageButton.setToolTipText("");
    nextPageButton.setIcon(new ImageIcon(getClass().getResource("go-next-2.png")));
    nextPageButton.addActionListener(e -> nextPage());

    lastPageButton = new JButton();
    lastPageButton.setMargin(insets);
    lastPageButton.setActionCommand("");
    lastPageButton.setToolTipText("");
    lastPageButton.setIcon(new ImageIcon(getClass().getResource("go-last.png")));
    lastPageButton.addActionListener(e -> lastPage());

    statusBar.add(firstPageButton);
    statusBar.add(prevPageButton);
    statusBar.add(nextPageButton);
    statusBar.add(lastPageButton);

    add(statusBar, BorderLayout.SOUTH);
}

From source file:gda.gui.mca.McaGUI.java

private JPanel getNamePanel() {
    nameLabel = new JLabel("MultiChannelAnalyser");
    startButton = new JButton("Start");
    startButton.addActionListener(new java.awt.event.ActionListener() {
        @Override//from  ww w  .j a  v  a2 s .c  om
        public void actionPerformed(java.awt.event.ActionEvent e) {
            try {
                analyser.startAcquisition();
                // if(xaxisCombo.getSelectedIndex() == ENERGY_PLOT)
                // selectedPlot = ENERGY_PLOT;
                // else
                // selectedPlot = CHANNEL_PLOT;
                // xaxisCombo.setEnabled(false);

            } catch (DeviceException e1) {
                logger.error(e1.getMessage());

            }
        }
    });
    stopButton = new JButton("Stop");
    stopButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            try {
                analyser.stopAcquisition();
                // if(calibrationAvailable)
                // xaxisCombo.setEnabled(true);

            } catch (DeviceException e1) {
                logger.error(e1.getMessage());
            }
        }
    });
    eraseButton = new JButton("Erase");
    eraseButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            try {
                analyser.clear();
            } catch (DeviceException e1) {
                logger.error(e1.getMessage());
            }
        }
    });
    statusLabel = new JLabel("Status");
    namePanel = new JPanel();
    namePanel.setLayout(new BoxLayout(namePanel, BoxLayout.X_AXIS));
    namePanel.add(nameLabel);
    namePanel.add(Box.createHorizontalStrut(10));
    namePanel.add(startButton);
    namePanel.add(Box.createHorizontalStrut(10));
    namePanel.add(stopButton);
    namePanel.add(Box.createHorizontalStrut(10));
    namePanel.add(eraseButton);
    namePanel.add(Box.createHorizontalStrut(10));
    namePanel.add(statusLabel);
    namePanel.add(Box.createHorizontalStrut(10));
    return namePanel;
}

From source file:org.biojava.bio.view.MotifAnalyzer.java

private Box getControlBox(SequencePanel seqPanel, String seqName) {
    JSlider scale;/*from   w  ww .jav  a 2  s . co m*/
    Box controlBox = null;
    if (controlBox == null) {
        controlBox = Box.createHorizontalBox();
        scale = new JSlider(SwingConstants.HORIZONTAL, 1, 100, INITIAL_SCALE);

        controlBox.add(new JLabel(seqName));
        controlBox.add(Box.createHorizontalGlue());
        controlBox.add(Box.createHorizontalStrut(10));
        controlBox.add(Box.createHorizontalGlue());
        controlBox.add(new JLabel("Scale"));
        controlBox.add(Box.createHorizontalStrut(5));
        controlBox.add(scale);
        controlBox.add(Box.createHorizontalGlue());

        scale.addChangeListener(new SliderListener(seqPanel));
    }
    return controlBox;
}

From source file:de.bwravencl.controllerbuddy.gui.Main.java

void updateModesPanel() {
    if (modesListPanel == null)
        return;/*from  www  .j  a  va  2 s.co  m*/

    modesListPanel.removeAll();

    final var modes = input.getProfile().getModes();
    for (var i = 0; i < modes.size(); i++) {
        final var mode = modes.get(i);

        final var modePanel = new JPanel(new GridBagLayout());
        modesListPanel.add(modePanel,
                new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0,
                        GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,
                        new Insets(0, 0, 0, 0), 0, 5));

        final var modeNoLabel = new JLabel(rb.getString("MODE_NO_LABEL_PREFIX") + (i + 1));
        modeNoLabel.setPreferredSize(new Dimension(100, 15));
        modePanel.add(modeNoLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BASELINE,
                GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        modePanel.add(Box.createGlue(), new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0,
                GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        final var descriptionTextField = new JTextField(mode.getDescription(), 20);
        modePanel.add(descriptionTextField, new GridBagConstraints(2, 0, 1, 1, 1.0, 1.0,
                GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        final var setModeDescriptionAction = new SetModeDescriptionAction(mode, descriptionTextField);
        descriptionTextField.addActionListener(setModeDescriptionAction);
        descriptionTextField.getDocument().addDocumentListener(setModeDescriptionAction);

        modePanel.add(Box.createGlue(), new GridBagConstraints(3, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0,
                GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        if (Profile.defaultMode.equals(mode) || OnScreenKeyboard.onScreenKeyboardMode.equals(mode)) {
            descriptionTextField.setEditable(false);
            modePanel.add(Box.createHorizontalStrut(BUTTON_DIMENSION.width));
        } else {
            final var deleteButton = new JButton(new RemoveModeAction(mode));
            deleteButton.setPreferredSize(BUTTON_DIMENSION);
            modePanel.add(deleteButton, new GridBagConstraints(4, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0,
                    GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
        }
    }

    modesListPanel.add(Box.createGlue(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0,
            GridBagConstraints.FIRST_LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    modesScrollPane.setViewportView(modesListPanel);
}

From source file:net.sourceforge.squirrel_sql.client.preferences.UpdatePreferencesPanel.java

private JPanel createUpdateSitePanel() {
    JPanel pnl = new JPanel(new GridBagLayout());
    pnl.setBorder(BorderFactory.createTitledBorder(i18n.UPDATE_SITE_BORDER_LABEL));

    ItemListener urlUpdateItemListener = new UrlItemListener();
    DocumentListener urlDocumentListener = new UrlDocumentListener();
    final GridBagConstraints gbc = new GridBagConstraints();

    setSeparatorConstraints(gbc, 0);/*from   w  w w  . j  a  v  a  2  s .  c o m*/
    gbc.gridwidth = 1;
    gbc.weightx = 0;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    siteTypeLabel = new JLabel(i18n.SITE_TYPE_LABEL, JLabel.RIGHT);
    pnl.add(siteTypeLabel, gbc);

    // Site type

    setSeparatorConstraints(gbc, 0);
    gbc.gridx = 1;
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.NONE;
    pnl.add(getSiteTypePanel(), gbc);

    setSeparatorConstraints(gbc, 1);
    pnl.add(getSep(), gbc);

    // Update server name

    setLabelConstraints(gbc, 2);
    _serverLabel = new JLabel(i18n.SERVER, SwingConstants.RIGHT);
    pnl.add(_serverLabel, gbc);

    setFieldConstraints(gbc, 2);
    _updateServerName.getDocument().addDocumentListener(urlDocumentListener);
    pnl.add(_updateServerName, gbc);

    // Update server port

    setLabelConstraints(gbc, 3);
    _portLabel = new JLabel(i18n.PORT, SwingConstants.RIGHT);
    pnl.add(_portLabel, gbc);

    setFieldConstraints(gbc, 3);
    _updateServerPort.getDocument().addDocumentListener(urlDocumentListener);
    pnl.add(_updateServerPort, gbc);

    // Path to release.xml

    setLabelConstraints(gbc, 4);
    _pathLabel = new JLabel(i18n.PATH, SwingConstants.RIGHT);
    pnl.add(_pathLabel, gbc);

    setFieldConstraints(gbc, 4);
    _updateServerPath.getDocument().addDocumentListener(urlDocumentListener);
    pnl.add(_updateServerPath, gbc);

    // Channnel combo-box

    setLabelConstraints(gbc, 5);
    _channelLabel = new JLabel(i18n.CHANNEL, SwingConstants.RIGHT);
    pnl.add(_channelLabel, gbc);

    setFieldConstraints(gbc, 5);
    gbc.fill = GridBagConstraints.NONE;
    _updateServerChannel.addItemListener(urlUpdateItemListener);
    pnl.add(_updateServerChannel, gbc);

    // URL text field

    setLabelConstraints(gbc, 6);
    _urlLabel = new JLabel(i18n.URL, SwingConstants.RIGHT);
    pnl.add(_urlLabel, gbc);

    setFieldConstraints(gbc, 6);
    updateUrl();
    pnl.add(_updateUrl, gbc);

    setFieldConstraints(gbc, 7);
    JLabel lblProxy = new JLabel(s_stringMgr.getString("UpdatePreferencesPanel.proxyHintHtml"));
    lblProxy.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    lblProxy.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            _prefrenceTabActvivationListener.activateTabForClass(ProxyPreferenceTabComponent.class);
        }
    });
    pnl.add(lblProxy, gbc);

    // Test Connection Button Panel (Both the button and the status label

    setFieldConstraints(gbc, 8);

    Box buttonBox = Box.createHorizontalBox();
    buttonBox.add(_testConnectionButton);
    buttonBox.add(Box.createHorizontalStrut(20));
    buttonBox.add(_testConnectionStatusLabel);
    _testConnectionButton.addActionListener(new TestConnectionButtonListener());
    pnl.add(buttonBox, gbc);

    // Separator

    setSeparatorConstraints(gbc, 9);
    pnl.add(getSep(), gbc);

    // Local update directory

    setLabelConstraints(gbc, 10);
    _localPathLabel = new JLabel(i18n.LOCAL_PATH, SwingConstants.RIGHT);
    pnl.add(_localPathLabel, gbc);

    setFieldConstraints(gbc, 10);
    pnl.add(_localPath, gbc);
    return pnl;
}

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);//  w ww . j  av a  2s  .  c  om
    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.apache.jmeter.protocol.http.config.gui.UrlConfigGui.java

protected JPanel getProtocolAndMethodPanel() {

    // Implementation
    if (showImplementation) {
        httpImplementation = new JLabeledChoice(JMeterUtils.getResString("http_implementation"), // $NON-NLS-1$
                HTTPSamplerFactory.getImplementations());
        httpImplementation.addValue("");
    }/* w  ww .j  a va2s . c o  m*/

    // PROTOCOL
    protocol = new JTextField(4);
    JLabel protocolLabel = new JLabel(JMeterUtils.getResString("protocol")); // $NON-NLS-1$
    protocolLabel.setLabelFor(protocol);

    // CONTENT_ENCODING
    contentEncoding = new JTextField(10);
    JLabel contentEncodingLabel = new JLabel(JMeterUtils.getResString("content_encoding")); // $NON-NLS-1$
    contentEncodingLabel.setLabelFor(contentEncoding);

    if (notConfigOnly) {
        method = new JLabeledChoice(JMeterUtils.getResString("method"), // $NON-NLS-1$
                HTTPSamplerBase.getValidMethodsAsArray(), true, false);
        method.addChangeListener(this);
    }

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));

    if (showImplementation) {
        panel.add(httpImplementation);
    }
    panel.add(protocolLabel);
    panel.add(protocol);
    panel.add(Box.createHorizontalStrut(5));

    if (notConfigOnly) {
        panel.add(method);
    }
    panel.setMinimumSize(panel.getPreferredSize());
    panel.add(Box.createHorizontalStrut(5));

    panel.add(contentEncodingLabel);
    panel.add(contentEncoding);
    panel.setMinimumSize(panel.getPreferredSize());
    return panel;
}