Example usage for javax.swing JScrollPane setBorder

List of usage examples for javax.swing JScrollPane setBorder

Introduction

In this page you can find the example usage for javax.swing JScrollPane 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:com.mirth.connect.client.ui.Frame.java

/**
 * Builds the content panel with a title bar and settings.
 *///from  www  . j  a  v  a 2  s.com
private void buildContentPanel(JXTitledPanel container, JScrollPane component, boolean opaque) {
    container.getContentContainer().setLayout(new BorderLayout());
    container.setBorder(null);
    container.setTitleFont(new Font("Tahoma", Font.BOLD, 18));
    container.setTitleForeground(UIConstants.HEADER_TITLE_TEXT_COLOR);
    JLabel mirthConnectImage = new JLabel();
    mirthConnectImage.setIcon(UIConstants.MIRTHCONNECT_LOGO_GRAY);
    mirthConnectImage.setText(" ");
    mirthConnectImage.setToolTipText(UIConstants.MIRTHCONNECT_TOOLTIP);
    mirthConnectImage.setCursor(new Cursor(Cursor.HAND_CURSOR));

    mirthConnectImage.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent evt) {
            BareBonesBrowserLaunch.openURL(UIConstants.MIRTHCONNECT_URL);
        }
    });

    ((JPanel) container.getComponent(0)).add(mirthConnectImage);

    component.setBorder(new LineBorder(Color.GRAY, 1));
    component.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    component.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);

    container.getContentContainer().add(component);
}

From source file:edu.ku.brc.af.ui.forms.FormViewObj.java

/**
 * Sets the component into the object/*from  www  . ja  v  a 2 s . c  o  m*/
 * @param formComp the UI component that represents this viewable
 */
public void setFormComp(final JComponent formComp) {
    // Remove existing component
    if (this.formComp != null) {
        mainComp.remove(this.formComp);
    }

    // add new component
    if (MultiView.isOptionOn(options, MultiView.NO_SCROLLBARS)) {
        if (ViewFactory.isFormTransparent()) {
            formComp.setOpaque(false);
        }
        this.mainComp.add(formComp, BorderLayout.CENTER);
        this.formComp = formComp;

    } else {
        JScrollPane scrollPane = new JScrollPane(formComp, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        scrollPane.getVerticalScrollBar().setUnitIncrement(10);

        scrollPane.setBorder(null);
        this.mainComp.add(scrollPane, BorderLayout.CENTER);
        this.formComp = scrollPane;

        if (ViewFactory.isFormTransparent()) {
            scrollPane.setOpaque(false);
            scrollPane.getViewport().setOpaque(false);
        }
    }

    if (businessRules != null && !hasInitBR) {
        businessRules.initialize(this);
        hasInitBR = true;
    }

    // This is needed to make the form layout correctly
    //XXX I hate that I have to do this
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            //mainComp.invalidate();
            //mainComp.validate();
            //mainComp.doLayout();
            UIRegistry.forceTopFrameRepaint();
        }
    });
}

From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java

private JPanel createAParameterBox(final boolean first) {

    final JLabel runLabel = new JLabel("<html><b>Number of runs:</b> 0</html>");
    final JLabel warningLabel = new JLabel();

    final JButton closeButton = new JButton();
    closeButton.setOpaque(false);//w  w  w.j a v  a  2  s  .c  om
    closeButton.setBorder(null);
    closeButton.setFocusable(false);

    if (!first) {
        closeButton.setRolloverIcon(PARAMETER_BOX_REMOVE);
        closeButton.setRolloverEnabled(true);
        closeButton.setIcon(RGBGrayFilter.getDisabledIcon(closeButton, PARAMETER_BOX_REMOVE));
        closeButton.setActionCommand(ACTIONCOMMAND_REMOVE_BOX);
    }

    final JScrollPane treeScrPane = new JScrollPane();
    final DefaultMutableTreeNode treeRoot = new DefaultMutableTreeNode();
    final JTree tree = new JTree(treeRoot);
    ToolTipManager.sharedInstance().registerComponent(tree);

    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setCellRenderer(new ParameterBoxTreeRenderer());
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(final TreeSelectionEvent e) {
            final TreePath selectionPath = tree.getSelectionPath();
            boolean success = true;
            if (editedNode != null
                    && (selectionPath == null || !editedNode.equals(selectionPath.getLastPathComponent())))
                success = modify();

            if (success) {
                if (selectionPath != null) {
                    cancelAllSelectionBut(tree);
                    final DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath
                            .getLastPathComponent();
                    if (!node.equals(editedNode)) {
                        ParameterInATree userObj = null;
                        final DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
                        if (!node.isRoot()
                                && selectionPath.getPathCount() == model.getPathToRoot(node).length) {
                            userObj = (ParameterInATree) node.getUserObject();
                            final ParameterInfo info = userObj.info;
                            editedNode = node;
                            editedTree = tree;
                            edit(info);
                        } else {
                            tree.setSelectionPath(null);
                            if (cancelButton.isEnabled())
                                cancelButton.doClick();
                            resetSettings();
                            enableDisableSettings(false);
                            editedNode = null;
                            editedTree = null;
                        }

                        updateDescriptionField(userObj);
                    } else
                        updateDescriptionField();

                } else
                    updateDescriptionField();

                enableDisableParameterCombinationButtons();
            } else {
                final DefaultTreeModel model = (DefaultTreeModel) editedTree.getModel();
                final DefaultMutableTreeNode storedEditedNode = editedNode;
                editedNode = null;
                tree.setSelectionPath(null);
                editedNode = storedEditedNode;
                editedTree.setSelectionPath(new TreePath(model.getPathToRoot(editedNode)));
            }
        }
    });

    treeScrPane.setViewportView(tree);
    treeScrPane.setBorder(null);
    treeScrPane.setViewportBorder(null);
    treeScrPane.setPreferredSize(new Dimension(450, 250));

    final JButton upButton = new JButton();
    upButton.setOpaque(false);
    upButton.setRolloverEnabled(true);
    upButton.setIcon(PARAMETER_UP_ICON);
    upButton.setRolloverIcon(PARAMETER_UP_ICON_RO);
    upButton.setDisabledIcon(PARAMETER_UP_ICON_DIS);
    upButton.setBorder(null);
    upButton.setToolTipText("Move up the selected parameter");
    upButton.setActionCommand(ACTIONCOMMAND_MOVE_UP);

    final JButton downButton = new JButton();
    downButton.setOpaque(false);
    downButton.setRolloverEnabled(true);
    downButton.setIcon(PARAMETER_DOWN_ICON);
    downButton.setRolloverIcon(PARAMETER_DOWN_ICON_RO);
    downButton.setDisabledIcon(PARAMETER_DOWN_ICON_DIS);
    downButton.setBorder(null);
    downButton.setToolTipText("Move down the selected parameter");
    downButton.setActionCommand(ACTIONCOMMAND_MOVE_DOWN);

    final JPanel mainPanel = FormsUtils.build("~ f:p:g ~ p ~ r:p",
            "012||" + "333||" + "44_||" + "445||" + "446||" + "44_ f:p:g", runLabel, first ? "" : warningLabel,
            first ? warningLabel : closeButton, new FormsUtils.Separator(""), treeScrPane, upButton, downButton)
            .getPanel();

    mainPanel.setBorder(BorderFactory.createTitledBorder(""));

    final JButton addButton = new JButton();
    addButton.setOpaque(false);
    addButton.setRolloverEnabled(true);
    addButton.setIcon(PARAMETER_ADD_ICON);
    addButton.setRolloverIcon(PARAMETER_ADD_ICON_RO);
    addButton.setDisabledIcon(PARAMETER_ADD_ICON_DIS);
    addButton.setBorder(null);
    addButton.setToolTipText("Add selected parameter");
    addButton.setActionCommand(ACTIONCOMMAND_ADD_PARAM);

    final JButton removeButton = new JButton();
    removeButton.setOpaque(false);
    removeButton.setRolloverEnabled(true);
    removeButton.setIcon(PARAMETER_REMOVE_ICON);
    removeButton.setRolloverIcon(PARAMETER_REMOVE_ICON_RO);
    removeButton.setDisabledIcon(PARAMETER_REMOVE_ICON_DIS);
    removeButton.setBorder(null);
    removeButton.setToolTipText("Remove selected parameter");
    removeButton.setActionCommand(ACTIONCOMMAND_REMOVE_PARAM);

    final JPanel result = FormsUtils.build("p ~ f:p:g", "_0 f:p:g||" + "10 p ||" + "20 p||" + "_0 f:p:g",
            mainPanel, addButton, removeButton).getPanel();

    Style.registerCssClasses(result, Dashboard.CSS_CLASS_COMMON_PANEL);

    final ParameterCombinationGUI pcGUI = new ParameterCombinationGUI(tree, treeRoot, runLabel, warningLabel,
            addButton, removeButton, upButton, downButton);
    parameterTreeBranches.add(pcGUI);

    final ActionListener boxActionListener = new ActionListener() {

        //====================================================================================================
        // methods

        //----------------------------------------------------------------------------------------------------
        public void actionPerformed(final ActionEvent e) {
            final String cmd = e.getActionCommand();

            if (ACTIONCOMMAND_ADD_PARAM.equals(cmd))
                handleAddParameter(pcGUI);
            else if (ACTIONCOMMAND_REMOVE_PARAM.equals(cmd))
                handleRemoveParameter(tree);
            else if (ACTIONCOMMAND_REMOVE_BOX.equals(cmd))
                handleRemoveBox(tree);
            else if (ACTIONCOMMAND_MOVE_UP.equals(cmd))
                handleMoveUp();
            else if (ACTIONCOMMAND_MOVE_DOWN.equals(cmd))
                handleMoveDown();
        }

        //----------------------------------------------------------------------------------------------------
        private void handleAddParameter(final ParameterCombinationGUI pcGUI) {
            final Object[] selectedValues = parameterList.getSelectedValues();
            if (selectedValues != null && selectedValues.length > 0) {
                final AvailableParameter[] params = new AvailableParameter[selectedValues.length];
                System.arraycopy(selectedValues, 0, params, 0, selectedValues.length);
                addParameterToTree(params, pcGUI);
                enableDisableParameterCombinationButtons();
            }
        }

        //----------------------------------------------------------------------------------------------------
        private void handleRemoveParameter(final JTree tree) {
            final TreePath selectionPath = tree.getSelectionPath();
            if (selectionPath != null) {
                cancelButton.doClick();

                final DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath
                        .getLastPathComponent();
                if (!node.isRoot()) {
                    final DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent();
                    if (parentNode.isRoot()) {
                        removeParameter(tree, node, parentNode);
                        enableDisableParameterCombinationButtons();
                    }
                }
            }
        }

        //----------------------------------------------------------------------------------------------------
        private void handleRemoveBox(final JTree tree) {
            final int answer = Utilities.askUser(dashboard, false, "Comfirmation",
                    "This operation deletes the combination.",
                    "All related parameter returns back to the list on the left side.", "Are you sure?");
            if (answer == 1) {
                final DefaultTreeModel treeModel = (DefaultTreeModel) tree.getModel();

                if (tree.getSelectionCount() > 0) {
                    editedNode = null;
                    tree.setSelectionPath(null);
                    if (cancelButton.isEnabled())
                        cancelButton.doClick();
                }

                final DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot();
                for (int i = 0; i < root.getChildCount(); ++i) {
                    final DefaultMutableTreeNode node = (DefaultMutableTreeNode) root.getChildAt(i);
                    removeParameter(tree, node, root);
                }

                enableDisableParameterCombinationButtons();

                parameterTreeBranches.remove(pcGUI);
                combinationsPanel.remove(result);
                combinationsPanel.revalidate();

                updateNumberOfRuns();
            }
        }

        //----------------------------------------------------------------------------------------------------
        private void removeParameter(final JTree tree, final DefaultMutableTreeNode node,
                final DefaultMutableTreeNode parentNode) {
            final ParameterInATree userObj = (ParameterInATree) node.getUserObject();
            final ParameterInfo originalInfo = findOriginalInfo(userObj.info);
            if (originalInfo != null) {
                final DefaultListModel model = (DefaultListModel) parameterList.getModel();
                model.addElement(new AvailableParameter(originalInfo, currentModelHandler.getModelClass()));
                final DefaultTreeModel treeModel = (DefaultTreeModel) tree.getModel();
                treeModel.removeNodeFromParent(node);
                updateNumberOfRuns();
                tree.expandPath(new TreePath(treeModel.getPathToRoot(parentNode)));
            } else
                throw new IllegalStateException(
                        "Parameter " + userObj.info.getName() + " is not found in the model.");
        }

        //----------------------------------------------------------------------------------------------------
        private void handleMoveUp() {
            final TreePath selectionPath = tree.getSelectionPath();
            if (selectionPath != null) {
                boolean success = true;
                if (editedNode != null)
                    success = modify();

                if (success) {
                    final DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath
                            .getLastPathComponent();
                    final DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();

                    if (parent == null || parent.getFirstChild().equals(node)) {
                        tree.setSelectionPath(null); // we need this to preserve the state of the parameter settings panel
                        tree.setSelectionPath(new TreePath(node.getPath()));
                        return;
                    }

                    final int index = parent.getIndex(node);
                    final DefaultTreeModel treemodel = (DefaultTreeModel) tree.getModel();
                    treemodel.removeNodeFromParent(node);
                    treemodel.insertNodeInto(node, parent, index - 1);
                    tree.setSelectionPath(new TreePath(node.getPath()));
                }

            }
        }

        //----------------------------------------------------------------------------------------------------
        private void handleMoveDown() {
            final TreePath selectionPath = tree.getSelectionPath();
            if (selectionPath != null) {
                boolean success = true;
                if (editedNode != null)
                    success = modify();

                if (success) {
                    final DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath
                            .getLastPathComponent();
                    final DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();

                    if (parent == null || parent.getLastChild().equals(node)) {
                        tree.setSelectionPath(null); // we need this to preserve the state of the parameter settings panel
                        tree.setSelectionPath(new TreePath(node.getPath()));
                        return;
                    }

                    final int index = parent.getIndex(node);
                    final DefaultTreeModel treemodel = (DefaultTreeModel) tree.getModel();
                    treemodel.removeNodeFromParent(node);
                    treemodel.insertNodeInto(node, parent, index + 1);
                    tree.setSelectionPath(new TreePath(node.getPath()));
                }
            }
        }
    };

    GUIUtils.addActionListener(boxActionListener, closeButton, upButton, downButton, addButton, removeButton);

    result.setPreferredSize(new Dimension(500, 250));
    enableDisableParameterCombinationButtons();

    Style.apply(result, dashboard.getCssStyle());

    return result;
}

From source file:org.carrot2.workbench.vis.aduna.AdunaClusterMapViewPage.java

private void createAdunaControl(Composite parent) {
    /*//from  www  .  j a v a  2 s  .c  om
     * If <code>true</code>, try some dirty hacks to avoid flicker on Windows.
     */
    final boolean windowsFlickerHack = true;
    if (windowsFlickerHack) {
        System.setProperty("sun.awt.noerasebackground", "true");
    }

    this.scrollable = new Composite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    scrollable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    final GridLayout layout = new GridLayout();
    layout.marginBottom = 0;
    layout.marginLeft = 0;
    layout.marginRight = 0;
    layout.marginTop = 0;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    scrollable.setLayout(layout);

    embedded = new Composite(scrollable, SWT.NO_BACKGROUND | SWT.EMBEDDED);
    embedded.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    final Frame frame = SWT_AWT.new_Frame(embedded);
    frame.setLayout(new java.awt.BorderLayout());

    // LINGO-446: flicker fix; see "Creating a Root Pane Container" in http://www.eclipse.org/articles/article.php?file=Article-Swing-SWT-Integration/index.html
    final JApplet applet = new JApplet();
    frame.add(applet);
    applet.setLayout(new java.awt.BorderLayout());

    final JScrollPane scrollPanel = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_NEVER,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPanel.setDoubleBuffered(true);

    scrollPanel.setBorder(BorderFactory.createEmptyBorder());
    applet.getContentPane().add(scrollPanel, java.awt.BorderLayout.CENTER);

    final ClusterMapFactory factory = ClusterMapFactory.createFactory();
    final ClusterMap clusterMap = factory.createClusterMap();
    final ClusterMapMediator mapMediator = factory.createMediator(clusterMap);
    this.mapMediator = mapMediator;

    final ClusterGraphPanel graphPanel = mapMediator.getGraphPanel();
    graphPanel.setDoubleBuffered(true);
    scrollPanel.setViewportView(graphPanel);

    scrollable.addControlListener(new ControlAdapter() {
        @Override
        public void controlResized(ControlEvent e) {
            updateScrollBars();
        }
    });

    final SelectionAdapter adapter = new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            ScrollBar hbar = scrollable.getHorizontalBar();
            ScrollBar vbar = scrollable.getVerticalBar();
            final java.awt.Rectangle viewport = new java.awt.Rectangle(hbar.getSelection(), vbar.getSelection(),
                    hbar.getThumb(), vbar.getThumb());
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    graphPanel.scrollRectToVisible(viewport);
                }
            });
        }
    };
    scrollable.getVerticalBar().addSelectionListener(adapter);
    scrollable.getHorizontalBar().addSelectionListener(adapter);

    final Runnable updateScrollBarsAsync = new Runnable() {
        public void run() {
            updateScrollBars();
        }
    };

    graphPanel.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentShown(ComponentEvent e) {
            graphPanelSize = graphPanel.getPreferredSize();
            Display.getDefault().asyncExec(updateScrollBarsAsync);
        }

        @Override
        public void componentResized(ComponentEvent e) {
            graphPanelSize = graphPanel.getPreferredSize();
            Display.getDefault().asyncExec(updateScrollBarsAsync);
        }
    });
}

From source file:org.dishevelled.brainstorm.BrainStorm.java

/**
 * Layout components./*w w w  . ja v a  2 s .  c  o m*/
 */
private void layoutComponents() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setBorder(null);
    scrollPane.setOpaque(true);
    scrollPane.setBackground(backgroundColor);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
    add(placeholder);

    JPanel flow = new JPanel();
    flow.setLayout(new FlowLayout());
    flow.setOpaque(false);
    flow.add(scrollPane);

    add(flow);
    add(Box.createVerticalGlue());
    add(Box.createVerticalGlue());
}

From source file:org.executequery.gui.browser.ConnectionPanel.java

private void init() {

    // ---------------------------------
    // create the basic props panel

    // initialise the fields
    nameField = createTextField();/*from  w  ww  . j  a v a  2 s  . co m*/
    passwordField = createPasswordField();
    hostField = createTextField();
    portField = createNumberTextField();
    sourceField = createMatchedWidthTextField();
    userField = createTextField();
    urlField = createMatchedWidthTextField();

    nameField.addFocusListener(new ConnectionNameFieldListener(this));

    savePwdCheck = ActionUtilities.createCheckBox("Store Password", "setStorePassword");
    encryptPwdCheck = ActionUtilities.createCheckBox("Encrypt Password", "setEncryptPassword");

    savePwdCheck.addActionListener(this);
    encryptPwdCheck.addActionListener(this);

    // retrieve the drivers
    buildDriversList();

    // ---------------------------------
    // add the basic connection fields

    TextFieldPanel mainPanel = new TextFieldPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.insets = new Insets(10, 10, 10, 10);
    gbc.gridy = 0;
    gbc.gridx = 0;

    statusLabel = new DefaultFieldLabel();
    addLabelFieldPair(mainPanel, "Status:", statusLabel, "Current connection status", gbc);

    gbc.insets.bottom = 5;
    addLabelFieldPair(mainPanel, "Connection Name:", nameField, "A friendly name for this connection", gbc);

    addLabelFieldPair(mainPanel, "User Name:", userField, "Login user name", gbc);

    addLabelFieldPair(mainPanel, "Password:", passwordField, "Login password", gbc);

    JButton showPassword = new LinkButton("Show Password");
    showPassword.setActionCommand("showPassword");
    showPassword.addActionListener(this);

    JPanel passwordOptionsPanel = new JPanel(new GridBagLayout());
    addComponents(passwordOptionsPanel,
            new ComponentToolTipPair[] {
                    new ComponentToolTipPair(savePwdCheck,
                            "Store the password with the connection information"),
                    new ComponentToolTipPair(encryptPwdCheck, "Encrypt the password when saving"),
                    new ComponentToolTipPair(showPassword, "Show the password in plain text") });

    gbc.gridy++;
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    mainPanel.add(passwordOptionsPanel, gbc);

    addLabelFieldPair(mainPanel, "Host Name:", hostField, "Server host name or IP address", gbc);

    addLabelFieldPair(mainPanel, "Port:", portField, "Database port number", gbc);

    addLabelFieldPair(mainPanel, "Data Source:", sourceField, "Data source name", gbc);

    addLabelFieldPair(mainPanel, "JDBC URL:", urlField, "The full JDBC URL for this connection (optional)",
            gbc);

    addDriverFields(mainPanel, gbc);

    connectButton = createButton("Connect", CONNECT_ACTION_COMMAND, 'T');
    disconnectButton = createButton("Disconnect", "disconnect", 'D');

    JPanel buttons = new JPanel(new GridBagLayout());
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.insets.top = 5;
    gbc.insets.left = 0;
    gbc.insets.right = 10;
    gbc.gridwidth = 1;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.anchor = GridBagConstraints.NORTHEAST;
    gbc.fill = GridBagConstraints.NONE;
    buttons.add(connectButton, gbc);
    gbc.gridx++;
    gbc.weightx = 0;
    buttons.add(disconnectButton, gbc);

    gbc.insets.right = 0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    mainPanel.add(buttons, gbc);

    // ---------------------------------
    // create the advanced panel

    model = new JdbcPropertiesTableModel();
    JTable table = new DefaultTable(model);
    table.getTableHeader().setReorderingAllowed(false);

    TableColumnModel tcm = table.getColumnModel();

    TableColumn column = tcm.getColumn(2);
    column.setCellRenderer(new DeleteButtonRenderer());
    column.setCellEditor(new DeleteButtonEditor(table, new JCheckBox()));
    column.setMaxWidth(24);
    column.setMinWidth(24);

    JScrollPane scroller = new JScrollPane(table);

    // advanced jdbc properties
    JPanel advPropsPanel = new JPanel(new GridBagLayout());
    advPropsPanel.setBorder(BorderFactory.createTitledBorder("JDBC Properties"));
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.insets.top = 0;
    gbc.insets.left = 10;
    gbc.insets.right = 10;
    gbc.weighty = 0;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    advPropsPanel.add(new DefaultFieldLabel("Enter any key/value pair properties for this connection"), gbc);
    gbc.gridy++;
    advPropsPanel.add(
            new DefaultFieldLabel("Refer to the relevant JDBC driver documentation for possible entries"), gbc);
    gbc.gridy++;
    gbc.insets.bottom = 10;
    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    advPropsPanel.add(scroller, gbc);

    // transaction isolation
    txApplyButton = WidgetFactory.createInlineFieldButton("Apply", "transactionLevelChanged");
    txApplyButton.setToolTipText("Apply this level to all open connections of this type");
    txApplyButton.setEnabled(false);
    txApplyButton.addActionListener(this);

    // add a dummy select value to the tx levels
    String[] txLevels = new String[Constants.TRANSACTION_LEVELS.length + 1];
    txLevels[0] = "Database Default";
    for (int i = 1; i < txLevels.length; i++) {
        txLevels[i] = Constants.TRANSACTION_LEVELS[i - 1];
    }
    txCombo = WidgetFactory.createComboBox(txLevels);

    JPanel advTxPanel = new JPanel(new GridBagLayout());
    advTxPanel.setBorder(BorderFactory.createTitledBorder("Transaction Isolation"));
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.insets.top = 0;
    gbc.insets.left = 10;
    gbc.insets.right = 10;
    gbc.insets.bottom = 5;
    gbc.weighty = 0;
    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    advTxPanel.add(new DefaultFieldLabel("Default transaction isolation level for this connection"), gbc);
    gbc.gridy++;
    gbc.insets.bottom = 10;
    advTxPanel.add(
            new DefaultFieldLabel(
                    "Note: the selected isolation level " + "will apply to ALL open connections of this type."),
            gbc);
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.gridwidth = 1;
    gbc.insets.top = 0;
    gbc.insets.left = 10;
    gbc.weightx = 0;
    advTxPanel.add(new DefaultFieldLabel("Isolation Level:"), gbc);
    gbc.gridx = 1;
    gbc.insets.left = 5;
    gbc.weightx = 1.0;
    gbc.insets.right = 5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    advTxPanel.add(txCombo, gbc);
    gbc.gridx = 2;
    gbc.weightx = 0;
    gbc.insets.left = 0;
    gbc.insets.right = 10;
    advTxPanel.add(txApplyButton, gbc);

    JPanel advancedPanel = new JPanel(new BorderLayout());
    advancedPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    advancedPanel.add(advPropsPanel, BorderLayout.CENTER);
    advancedPanel.add(advTxPanel, BorderLayout.SOUTH);

    JScrollPane scrollPane = new JScrollPane(mainPanel);
    scrollPane.setBorder(null);

    sshTunnelConnectionPanel = new SSHTunnelConnectionPanel();

    tabPane = new JTabbedPane(JTabbedPane.BOTTOM);
    tabPane.addTab("Basic", scrollPane);
    tabPane.addTab("Advanced", advancedPanel);
    tabPane.addTab("SSH Tunnel", sshTunnelConnectionPanel);

    tabPane.addChangeListener(this);

    add(tabPane, BorderLayout.CENTER);

    EventMediator.registerListener(this);
}

From source file:org.executequery.gui.browser.SSHTunnelConnectionPanel.java

private void init() throws IOException {

    hostField = new DisabledField();
    userNameField = WidgetFactory.createTextField();
    passwordField = WidgetFactory.createPasswordField();
    portField = WidgetFactory.createNumberTextField();

    mainPanel = new TextFieldPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.insets = new Insets(10, 10, 10, 10);
    gbc.gridy = 0;//from www .j a  v a  2 s  . co m
    gbc.gridx = 0;

    gbc.insets.bottom = 5;

    gbc.gridwidth = GridBagConstraints.REMAINDER;
    mainPanel.add(new DefaultFieldLabel(
            FileUtils.loadResource("org/executequery/gui/browser/resource/ssh-tunnel.html")), gbc);

    addLabelFieldPair(mainPanel, "SSH Host:", hostField, "The SSH host server for the tunnel", gbc);

    addLabelFieldPair(mainPanel, "SSH Port:", portField, "The SSH server port", gbc);

    addLabelFieldPair(mainPanel, "SSH User Name:", userNameField, "The SSH user name for the tunnel", gbc);

    addLabelFieldPair(mainPanel, "SSH Password:", passwordField, "The SSH user password for the tunnel", gbc);

    savePwdCheck = ActionUtilities.createCheckBox("Store Password", "setStorePassword");

    JButton showPassword = new LinkButton("Show Password");
    showPassword.setActionCommand("showPassword");
    showPassword.addActionListener(this);

    JPanel passwordOptionsPanel = new JPanel(new GridBagLayout());
    addComponents(passwordOptionsPanel,
            new ComponentToolTipPair[] {
                    new ComponentToolTipPair(savePwdCheck,
                            "Store the password with the connection information"),
                    new ComponentToolTipPair(showPassword, "Show the password in plain text") });

    gbc.gridy++;
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    mainPanel.add(passwordOptionsPanel, gbc);

    JScrollPane scrollPane = new JScrollPane(mainPanel);
    scrollPane.setBorder(null);

    useSshCheckbox = ActionUtilities.createCheckBox(this, "Connect Using an SSH Tunnel", "useSshSelected");
    ComponentTitledPanel titledPanel = new ComponentTitledPanel(useSshCheckbox);

    JPanel panel = titledPanel.getContentPane();
    panel.setLayout(new BorderLayout());
    panel.add(scrollPane, BorderLayout.CENTER);

    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(titledPanel, BorderLayout.NORTH);
}

From source file:org.executequery.gui.editor.QueryEditorTextPanel.java

/** Initializes the state of this instance. */
private void init() throws Exception {

    // setup the query text panel and associated scroller
    queryPane = new QueryEditorTextPane(this);

    JScrollPane queryScroller = new JScrollPane();
    queryScroller.getViewport().add(queryPane, BorderLayout.CENTER);
    queryScroller.setRowHeaderView(queryPane.getLineBorder());
    queryScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    queryScroller.setBorder(new EditorScrollerBorder());

    add(queryScroller, BorderLayout.CENTER);
}

From source file:org.formic.wizard.step.gui.TemplateStep.java

/**
 * {@inheritDoc}//from  w ww  .ja  va2  s.com
 * @see org.formic.wizard.step.GuiStep#init()
 */
public Component init() {
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    if (html != null) {
        JEditorPane editor = new JEditorPane("text/html", StringUtils.EMPTY);
        editor.setEditable(false);
        editor.setOpaque(false);
        editor.addHyperlinkListener(new HyperlinkListener());
        editor.setBorder(null);
        editor.setFocusable(false);
        content = editor;
    } else {
        JTextArea area = new JTextArea();
        area.setEditable(false);
        content = area;
    }
    JScrollPane scroll = new JScrollPane(content);
    scroll.setBorder(null);
    panel.add(scroll, BorderLayout.CENTER);

    return panel;
}

From source file:org.isatools.gui.datamanager.exportisa.ExportISAGUI.java

public void createGUI() {
    // header image
    add(UIHelper.wrapComponentInPanel(new JLabel(panelHeader, SwingConstants.RIGHT)), BorderLayout.NORTH);

    // add a checkable jtree with investigations & studies...
    JPanel availableSubmissionsContainer = new JPanel(new BorderLayout());
    availableSubmissionsContainer.setOpaque(false);

    JPanel optionsContainer = new JPanel();
    optionsContainer.setLayout(new BoxLayout(optionsContainer, BoxLayout.LINE_AXIS));
    optionsContainer.setOpaque(false);/*from   w  w  w.  j  a v  a2  s . c  om*/

    JPanel optionsAndInformationPanel = new JPanel();
    optionsAndInformationPanel.setLayout(new BoxLayout(optionsAndInformationPanel, BoxLayout.PAGE_AXIS));
    optionsAndInformationPanel.setOpaque(false);

    JLabel fileInformation = UIHelper.createLabel("<html><i>where</i> to save the isatab files?</html>",
            UIHelper.VER_12_BOLD, UIHelper.LIGHT_GREY_COLOR);
    fileInformation.setVerticalAlignment(JLabel.TOP);

    JPanel fileLocationOptionContainer = new JPanel();
    fileLocationOptionContainer.setLayout(new BoxLayout(fileLocationOptionContainer, BoxLayout.PAGE_AXIS));
    fileLocationOptionContainer.setOpaque(false);

    // add component for selection of output to repository or output to folder...
    fileLocationOptionGroup = new OptionGroup<String>(OptionGroup.HORIZONTAL_ALIGNMENT, true);
    fileLocationOptionGroup.addOptionItem("BII repository", true);
    fileLocationOptionGroup.addOptionItem("Local file system");

    localDirectoryLocation = new FileSelectionUtil("select output directory", createFileChooser(),
            UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR);
    localDirectoryLocation.setVisible(false);
    localDirectoryLocation.setPreferredSize(new Dimension(150, 20));

    fileLocationOptionGroup.addPropertyChangeListener("optionSelectionChange", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            localDirectoryLocation
                    .setVisible(fileLocationOptionGroup.getSelectedItem().equals("Local file system"));
            revalidate();
        }
    });

    fileLocationOptionContainer.add(UIHelper.wrapComponentInPanel(fileInformation));
    fileLocationOptionContainer.add(UIHelper.wrapComponentInPanel(fileLocationOptionGroup));
    fileLocationOptionContainer.add(Box.createVerticalStrut(5));
    fileLocationOptionContainer.add(UIHelper.wrapComponentInPanel(localDirectoryLocation));

    optionsContainer.add(fileLocationOptionContainer);

    JPanel dataFileExportOptionContainer = new JPanel();
    dataFileExportOptionContainer.setLayout(new BoxLayout(dataFileExportOptionContainer, BoxLayout.PAGE_AXIS));
    dataFileExportOptionContainer.setOpaque(false);

    JLabel dataFileExportInformation = UIHelper.createLabel("<html>export data files?</html>",
            UIHelper.VER_12_BOLD, UIHelper.LIGHT_GREY_COLOR);
    dataFileExportInformation.setVerticalAlignment(JLabel.TOP);

    dataFileExportOptionGroup = new OptionGroup<String>(OptionGroup.HORIZONTAL_ALIGNMENT, true);
    dataFileExportOptionGroup.addOptionItem("yes", true);
    dataFileExportOptionGroup.addOptionItem("no");

    dataFileExportOptionContainer.add(UIHelper.wrapComponentInPanel(dataFileExportInformation));
    dataFileExportOptionContainer.add(UIHelper.wrapComponentInPanel(dataFileExportOptionGroup));
    dataFileExportOptionContainer.add(Box.createVerticalStrut(25));

    optionsContainer.add(dataFileExportOptionContainer);

    optionsAndInformationPanel.add(Box.createVerticalStrut(5));
    optionsAndInformationPanel.add(optionsContainer);
    optionsAndInformationPanel.add(Box.createVerticalStrut(10));

    JLabel information = UIHelper.createLabel(
            "<html>please <i>select</i> the submissions to be exported...</html>", UIHelper.VER_12_BOLD,
            UIHelper.LIGHT_GREY_COLOR);
    information.setVerticalAlignment(JLabel.TOP);

    optionsAndInformationPanel.add(UIHelper.wrapComponentInPanel(information));
    optionsAndInformationPanel.add(Box.createVerticalStrut(5));

    availableSubmissionsContainer.add(optionsAndInformationPanel, BorderLayout.NORTH);

    retrieveAndProcessStudyInformation();

    JScrollPane treeScroller = new JScrollPane(studyAvailabilityTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    treeScroller.getViewport().setOpaque(false);
    treeScroller.setOpaque(false);
    treeScroller.setBorder(new EmptyBorder(1, 1, 1, 1));

    treeScroller.setPreferredSize(new Dimension(380, 250));

    availableSubmissionsContainer.add(treeScroller, BorderLayout.CENTER);
    add(availableSubmissionsContainer, BorderLayout.CENTER);
    add(createSouthPanel(), BorderLayout.SOUTH);
}