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.stefanbrenner.droplet.ui.DevicePanel.java

/**
 * Create the panel.//from   ww w.  j ava2s. c o m
 */
public DevicePanel(final JComponent parent, final IDroplet droplet, final T device) {

    this.parent = parent;

    setDevice(device);

    setLayout(new BorderLayout(0, 5));
    setBorder(BorderFactory.createLineBorder(Color.BLACK));
    setBackground(DropletColors.getBackgroundColor(device));

    BeanAdapter<T> adapter = new BeanAdapter<T>(device, true);

    // device name textfield
    txtName = BasicComponentFactory.createTextField(adapter.getValueModel(IDevice.PROPERTY_NAME));
    txtName.setHorizontalAlignment(SwingConstants.CENTER);
    txtName.setColumns(1);
    txtName.setToolTipText(device.getName());
    adapter.addBeanPropertyChangeListener(IDevice.PROPERTY_NAME, new PropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            txtName.setToolTipText(device.getName());
        }
    });
    add(txtName, BorderLayout.NORTH);

    // actions panel with scroll pane
    actionsPanel = new JPanel();
    actionsPanel.setLayout(new BoxLayout(actionsPanel, BoxLayout.Y_AXIS));
    actionsPanel.setBackground(getBackground());

    JScrollPane scrollPane = new JScrollPane(actionsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    // resize vertical scrollbar
    scrollPane.getVerticalScrollBar().putClientProperty("JComponent.sizeVariant", "mini"); //$NON-NLS-1$ //$NON-NLS-2$
    SwingUtilities.updateComponentTreeUI(scrollPane);
    // we need no border
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    add(scrollPane, BorderLayout.CENTER);

    {
        JPanel panel = new JPanel();
        panel.setLayout(new GridLayout(0, 1));

        createAddButton(panel);

        // remove button
        JButton btnRemove = new JButton(Messages.getString("ActionDevicePanel.removeDevice")); //$NON-NLS-1$
        btnRemove.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent action) {
                int retVal = JOptionPane.showConfirmDialog(DevicePanel.this,
                        Messages.getString("ActionDevicePanel.removeDevice") + " '" + device.getName() + "'?", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                        StringUtils.EMPTY, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (retVal == JOptionPane.YES_OPTION) {
                    droplet.removeDevice(device);
                }
            }
        });
        btnRemove.setFocusable(false);
        panel.add(btnRemove);

        add(panel, BorderLayout.SOUTH);
    }

}

From source file:com.floreantpos.ui.dialog.DiscountSelectionDialog.java

private void initComponent() {
    setOkButtonText(POSConstants.SAVE_BUTTON_TEXT);
    createCouponSearchPanel();//from   w  ww .  j a  v  a2 s .c  om
    getContentPanel().add(itemSearchPanel, BorderLayout.NORTH);

    buttonsPanel = new ScrollableFlowPanel(FlowLayout.LEADING);

    JScrollPane scrollPane = new PosScrollPane(buttonsPanel, PosScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            PosScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(80, 0));
    scrollPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5),
            scrollPane.getBorder()));

    getContentPanel().add(scrollPane, BorderLayout.CENTER);

    rendererDiscounts();

    setSize(1024, 720);
}

From source file:at.tuwien.ifs.feature.evaluation.SimilarityRetrievalGUI.java

public SimilarityRetrievalGUI() {
    super("Similarity Retrieval GUI");
    setLayout(new GridBagLayout());
    GridBagConstraintsIFS gcMain = new GridBagConstraintsIFS(GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // the panel with the feature files, allows to load new ones
    JPanel panelFeatureFiles = UiUtils.makeBorderedPanel(new VerticalLayout(), "Feature files");
    getContentPane().add(panelFeatureFiles, gcMain);

    panelLoadedFeatureFiles.add(labelNoInputData);

    panelFeatureFiles.add(panelLoadedFeatureFiles);

    JButton btnLoad = initButtonLoad();
    panelFeatureFiles.add(btnLoad);//from  www .jav a  2 s  . co m

    txtFieldMusicPath.setToolTipText("Path to the music");

    // TODO: remove
    txtFieldMusicPath.setText("/data/music/ISMIRgenre/mp3_44khz_128kbit_stereo_30sec");

    JButton btnBrowseMusicPath = UiUtils.createBrowseButton(txtFieldMusicPath, this, true);

    JPanel panelMusicPath = new JPanel();
    panelMusicPath.add(new JLabel("Music path"));
    panelMusicPath.add(txtFieldMusicPath);
    panelMusicPath.add(btnBrowseMusicPath);

    panelFeatureFiles.add(panelMusicPath);

    initButtonStart();

    initButtonSaveResults();

    JRadioButton rbDistanceAbsolute = UiUtils.makeRadioButton("absolute", bgDistanceDisplay, true);
    bgDistanceDisplay.add(rbDistanceAbsolute);
    JRadioButton rbDistanceRelative = UiUtils.makeRadioButton("relative", bgDistanceDisplay);
    bgDistanceDisplay.add(rbDistanceRelative);

    initPanelRetrieval();

    ((JSpinner.DefaultEditor) spinnerNumberNeighbours.getEditor()).getTextField().setColumns(6);

    panelRetrieval.setBorder(new TitledBorder("Options"));
    GridBagConstraintsIFS gc = new GridBagConstraintsIFS().setInsets(5, 2);
    panelRetrieval.add(new JLabel("# to retrieve"), gc);
    panelRetrieval.add(spinnerNumberNeighbours, gc.nextCol());
    panelRetrieval.add(new JLabel("Query vector"), gc.nextRow());
    panelRetrieval.add(comboQueryVector, gc.nextCol());

    panelRetrieval.add(new JLabel("Distances"), gc.nextRow());
    panelRetrieval.add(UiUtils.makeAndFillPanel(rbDistanceAbsolute, rbDistanceRelative), gc.nextCol());

    boxMetric.setSelectedItem(L2Metric.class.getSimpleName());
    panelRetrieval.add(new JLabel("Distance metric"), gc.nextRow());
    panelRetrieval.add(boxMetric, gc.nextCol());

    gc.nextRow().setGridWidth(2).setAnchor(GridBagConstraints.CENTER);
    panelRetrieval.add(UiUtils.makeAndFillPanel(btnStart, btnSaveResults), gc);
    panelRetrieval.setEnabled(false);

    getContentPane().add(panelRetrieval, gcMain.nextRow());

    resizeResultTableColumns();

    JScrollPane scrollPaneResults = new JScrollPane(resultsTable);
    scrollPaneResults.setBorder(new TitledBorder("Results"));
    getContentPane().add(scrollPaneResults, gcMain.nextRow());

    databaseDetailsTable = new JTable(new DefaultTableModel(new Object[][] {}, databaseDetailsColumnNames));
    databaseDetailsTable.setAutoCreateRowSorter(true);

    databaseDetailsTable.setDefaultEditor(JButton.class, new ButtonCellEditor());

    resizeDatabaseDetailsTableColumns();
    JScrollPane scrollPaneDatabaseDetails = new JScrollPane(databaseDetailsTable);

    // panel in the upper-right corner, holding the database table & buttons to load class assignment
    JPanel databaseDetailsPanel = UiUtils.makeBorderedPanel(new GridBagLayout(), "Database Details");
    GridBagConstraintsIFS gcDatabaseDetails = new GridBagConstraintsIFS(GridBagConstraints.CENTER,
            GridBagConstraints.BOTH);
    gcDatabaseDetails.setWeights(1, 1);
    databaseDetailsPanel.add(scrollPaneDatabaseDetails, gcDatabaseDetails);

    initButtonLoadClassInfo();
    databaseDetailsPanel.add(buttonLoadClassInfo, gc.nextRow());

    JPanel histogramPanel = UiUtils.makeBorderedPanel("Histogram of Distances");
    histogramPanel.add(chartPanel);

    JPanel detailsPanel = new JPanel(new VerticalLayout());
    gcMain.setGridHeight(3);
    gcMain.setWeights(1, 1);
    getContentPane().add(detailsPanel, gcMain.moveTo(1, 0));
    detailsPanel.add(databaseDetailsPanel);
    detailsPanel.add(histogramPanel);

}

From source file:com.edduarte.protbox.ui.windows.RestoreFileWindow.java

private RestoreFileWindow(final PReg registry) {
    super();/*from w w  w. jav a 2  s .c o  m*/
    setLayout(null);

    final JTextField searchField = new JTextField();
    searchField.setLayout(null);
    searchField.setBounds(2, 2, 301, 26);
    searchField.setBorder(new LineBorder(Color.lightGray));
    searchField.setFont(Constants.FONT);
    add(searchField);

    final JLabel noBackupFilesLabel = new JLabel("<html>No backups files were found!<br><br>"
            + "<font color=\"gray\">If you think there is a problem with the<br>"
            + "backup system, please create an issue here:<br>"
            + "<a href=\"#\">https://github.com/com.edduarte/protbox/issues</a></font></html>");
    noBackupFilesLabel.setLayout(null);
    noBackupFilesLabel.setBounds(20, 50, 300, 300);
    noBackupFilesLabel.setFont(Constants.FONT.deriveFont(14f));
    noBackupFilesLabel.addMouseListener((OnMouseClick) e -> {
        String urlPath = "https://github.com/com.edduarte/protbox/issues";

        try {

            if (Desktop.isDesktopSupported()) {
                Desktop.getDesktop().browse(new URI(urlPath));

            } else {
                if (SystemUtils.IS_OS_WINDOWS) {
                    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + urlPath);

                } else {
                    java.util.List<String> browsers = Lists.newArrayList("firefox", "opera", "safari",
                            "mozilla", "chrome");

                    for (String browser : browsers) {
                        if (Runtime.getRuntime().exec(new String[] { "which", browser }).waitFor() == 0) {

                            Runtime.getRuntime().exec(new String[] { browser, urlPath });
                            break;
                        }
                    }
                }
            }

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    });

    DefaultMutableTreeNode rootTreeNode = registry.buildEntryTree();
    final JTree tree = new JTree(rootTreeNode);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    if (rootTreeNode.getChildCount() == 0) {
        searchField.setEnabled(false);
        add(noBackupFilesLabel);
    }
    expandTree(tree);
    tree.setLayout(null);
    tree.setRootVisible(false);
    tree.setEditable(false);
    tree.setCellRenderer(new SearchableTreeCellRenderer(searchField));
    searchField.addKeyListener((OnKeyReleased) e -> {

        // update and expand tree
        DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
        model.nodeStructureChanged((TreeNode) model.getRoot());
        expandTree(tree);
    });
    final JScrollPane scroll = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll.setBorder(new DropShadowBorder());
    scroll.setBorder(new LineBorder(Color.lightGray));
    scroll.setBounds(2, 30, 334, 360);
    add(scroll);

    JLabel close = new JLabel(new ImageIcon(Constants.getAsset("close.png")));
    close.setLayout(null);
    close.setBounds(312, 7, 18, 18);
    close.setFont(Constants.FONT);
    close.setForeground(Color.gray);
    close.addMouseListener((OnMouseClick) e -> dispose());
    add(close);

    final JLabel permanentDeleteButton = new JLabel(new ImageIcon(Constants.getAsset("permanent.png")));
    permanentDeleteButton.setLayout(null);
    permanentDeleteButton.setBounds(91, 390, 40, 39);
    permanentDeleteButton.setBackground(Color.black);
    permanentDeleteButton.setEnabled(false);
    permanentDeleteButton.addMouseListener((OnMouseClick) e -> {
        if (permanentDeleteButton.isEnabled()) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
            PbxEntry entry = (PbxEntry) node.getUserObject();

            if (JOptionPane.showConfirmDialog(null,
                    "Are you sure you wish to permanently delete '" + entry.realName()
                            + "'?\nThis file and its "
                            + "backup copies will be deleted immediately. You cannot undo this action.",
                    "Confirm Cancel", JOptionPane.YES_NO_OPTION,
                    JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {

                registry.permanentDelete(entry);
                dispose();
                RestoreFileWindow.getInstance(registry);

            } else {
                setVisible(true);
            }
        }
    });
    add(permanentDeleteButton);

    final JLabel configBackupsButton = new JLabel(new ImageIcon(Constants.getAsset("config.png")));
    configBackupsButton.setLayout(null);
    configBackupsButton.setBounds(134, 390, 40, 39);
    configBackupsButton.setBackground(Color.black);
    configBackupsButton.setEnabled(false);
    configBackupsButton.addMouseListener((OnMouseClick) e -> {
        if (configBackupsButton.isEnabled()) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
            PbxEntry entry = (PbxEntry) node.getUserObject();
            if (entry instanceof PbxFile) {
                PbxFile pbxFile = (PbxFile) entry;

                JFrame frame = new JFrame("Choose backup policy");
                Object option = JOptionPane.showInputDialog(frame,
                        "Choose below the backup policy for this file:", "Choose backup",
                        JOptionPane.QUESTION_MESSAGE, null, PbxFile.BackupPolicy.values(),
                        pbxFile.getBackupPolicy());

                if (option == null) {
                    setVisible(true);
                    return;
                }
                PbxFile.BackupPolicy pickedPolicy = PbxFile.BackupPolicy.valueOf(option.toString());
                pbxFile.setBackupPolicy(pickedPolicy);
            }
            setVisible(true);
        }
    });
    add(configBackupsButton);

    final JLabel restoreBackupButton = new JLabel(new ImageIcon(Constants.getAsset("restore.png")));
    restoreBackupButton.setLayout(null);
    restoreBackupButton.setBounds(3, 390, 85, 39);
    restoreBackupButton.setBackground(Color.black);
    restoreBackupButton.setEnabled(false);
    restoreBackupButton.addMouseListener((OnMouseClick) e -> {
        if (restoreBackupButton.isEnabled()) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
            PbxEntry entry = (PbxEntry) node.getUserObject();
            if (entry instanceof PbxFolder) {
                registry.restoreFolderFromEntry((PbxFolder) entry);

            } else if (entry instanceof PbxFile) {
                PbxFile pbxFile = (PbxFile) entry;
                java.util.List<String> snapshots = pbxFile.snapshotsToString();
                if (snapshots.isEmpty()) {
                    setVisible(true);
                    return;
                }

                JFrame frame = new JFrame("Choose backup");
                Object option = JOptionPane.showInputDialog(frame,
                        "Choose below what backup snapshot would you like restore:", "Choose backup",
                        JOptionPane.QUESTION_MESSAGE, null, snapshots.toArray(), snapshots.get(0));

                if (option == null) {
                    setVisible(true);
                    return;
                }
                int pickedIndex = snapshots.indexOf(option.toString());
                registry.restoreFileFromEntry((PbxFile) entry, pickedIndex);
            }
            dispose();
        }
    });
    add(restoreBackupButton);

    tree.addMouseListener((OnMouseClick) e -> {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
        if (node != null) {
            PbxEntry entry = (PbxEntry) node.getUserObject();
            if ((entry instanceof PbxFolder && entry.areNativeFilesDeleted())) {
                permanentDeleteButton.setEnabled(true);
                restoreBackupButton.setEnabled(true);
                configBackupsButton.setEnabled(false);

            } else if (entry instanceof PbxFile) {
                permanentDeleteButton.setEnabled(true);
                restoreBackupButton.setEnabled(true);
                configBackupsButton.setEnabled(true);

            } else {
                permanentDeleteButton.setEnabled(false);
                restoreBackupButton.setEnabled(false);
                configBackupsButton.setEnabled(false);
            }
        }
    });

    final JLabel cancel = new JLabel(new ImageIcon(Constants.getAsset("cancel.png")));
    cancel.setLayout(null);
    cancel.setBounds(229, 390, 122, 39);
    cancel.setBackground(Color.black);
    cancel.addMouseListener((OnMouseClick) e -> dispose());
    add(cancel);

    addWindowFocusListener(new WindowFocusListener() {
        private boolean gained = false;

        @Override
        public void windowGainedFocus(WindowEvent e) {
            gained = true;
        }

        @Override
        public void windowLostFocus(WindowEvent e) {
            if (gained) {
                dispose();
            }
        }
    });

    setSize(340, 432);
    setUndecorated(true);
    getContentPane().setBackground(Color.white);
    setResizable(false);
    getRootPane().setBorder(BorderFactory.createLineBorder(new Color(100, 100, 100)));
    Utils.setComponentLocationOnCenter(this);
    setVisible(true);
}

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

public JComponent build() {
    // Apply the orientation for the locale
    ComponentOrientation orientation = ComponentOrientation.getOrientation(PMS.getLocale());

    String colSpec = FormLayoutUtil.getColSpec("pref, 30dlu, fill:pref:grow, 30dlu, pref", orientation);
    //                                             1     2          3           4     5

    FormLayout layout = new FormLayout(colSpec,
            //                          1     2          3            4     5
            //                   //////////////////////////////////////////////////
            "p," // Detected Media Renderers --------------------//  1
                    + "9dlu," //                                              //
                    + "fill:p:grow," //                 <renderers>                  //  3
                    + "3dlu," //                                              //
                    + "p," // ---------------------------------------------//  5
                    + "3dlu," //           |                       |          //
                    + "p," // Connected |  Memory Usage         |<bitrate> //  7
                    + "3dlu," //           |                       |          //
                    + "p," //  <icon>   |  <statusbar>          |          //  9
                           //////////////////////////////////////////////////
    );/*  ww w. j  ava 2  s.  c om*/

    PanelBuilder builder = new PanelBuilder(layout);
    builder.border(Borders.DIALOG);
    builder.opaque(true);
    CellConstraints cc = new CellConstraints();

    // Renderers
    JComponent cmp = builder.addSeparator(Messages.getString("StatusTab.9"),
            FormLayoutUtil.flip(cc.xyw(1, 1, 5), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    Font bold = cmp.getFont().deriveFont(Font.BOLD);
    Color fgColor = new Color(68, 68, 68);
    cmp.setFont(bold);

    renderers = new JPanel(new GuiUtil.WrapLayout(FlowLayout.CENTER, 20, 10));
    JScrollPane rsp = new JScrollPane(renderers, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    rsp.setBorder(BorderFactory.createEmptyBorder());
    rsp.setPreferredSize(new Dimension(0, 260));
    rsp.getHorizontalScrollBar().setLocation(0, 250);

    builder.add(rsp, cc.xyw(1, 3, 5));

    cmp = builder.addSeparator(null, FormLayoutUtil.flip(cc.xyw(1, 5, 5), colSpec, orientation));

    // Connected
    jl = new JLabel(Messages.getString("StatusTab.3"));
    builder.add(jl, FormLayoutUtil.flip(cc.xy(1, 7, "center, top"), colSpec, orientation));
    jl.setFont(bold);
    jl.setForeground(fgColor);

    imagePanel = buildImagePanel("/resources/images/icon-status-connecting.png");
    builder.add(imagePanel, FormLayoutUtil.flip(cc.xy(1, 9), colSpec, orientation));

    // Memory
    memBarUI = new GuiUtil.SegmentedProgressBarUI(Color.white, Color.gray);
    memBarUI.setActiveLabel("{}", Color.white, 0);
    memBarUI.setActiveLabel("{}", Color.red, 90);
    memBarUI.addSegment("", memColor);
    memBarUI.addSegment("", bufColor);
    memBarUI.setTickMarks(getTickMarks(), "{}");
    memoryProgressBar = new GuiUtil.CustomUIProgressBar(0, 100, memBarUI);
    memoryProgressBar.setStringPainted(true);
    memoryProgressBar.setForeground(new Color(75, 140, 181));
    memoryProgressBar.setString(Messages.getString("StatusTab.5"));

    JLabel mem = builder
            .addLabel(
                    "<html><b>" + Messages.getString("StatusTab.6") + "</b> ("
                            + Messages.getString("StatusTab.12") + ")</html>",
                    FormLayoutUtil.flip(cc.xy(3, 7), colSpec, orientation));
    mem.setForeground(fgColor);
    builder.add(memoryProgressBar, FormLayoutUtil.flip(cc.xyw(3, 9, 1), colSpec, orientation));

    // Bitrate
    String bitColSpec = "left:pref, 3dlu, right:pref:grow";
    PanelBuilder bitrateBuilder = new PanelBuilder(new FormLayout(bitColSpec, "p, 1dlu, p, 1dlu, p"));

    bitrateLabel = new JLabel("<html><b>" + Messages.getString("StatusTab.13") + "</b> ("
            + Messages.getString("StatusTab.11") + ")</html>");
    bitrateLabel.setForeground(fgColor);
    bitrateBuilder.add(bitrateLabel, FormLayoutUtil.flip(cc.xy(1, 1), bitColSpec, orientation));

    currentBitrateLabel = new JLabel(Messages.getString("StatusTab.14"));
    currentBitrateLabel.setForeground(fgColor);
    bitrateBuilder.add(currentBitrateLabel, FormLayoutUtil.flip(cc.xy(1, 3), bitColSpec, orientation));

    currentBitrate = new JLabel("0");
    currentBitrate.setForeground(fgColor);
    bitrateBuilder.add(currentBitrate, FormLayoutUtil.flip(cc.xy(3, 3), bitColSpec, orientation));

    peakBitrateLabel = new JLabel(Messages.getString("StatusTab.15"));
    peakBitrateLabel.setForeground(fgColor);
    bitrateBuilder.add(peakBitrateLabel, FormLayoutUtil.flip(cc.xy(1, 5), bitColSpec, orientation));

    peakBitrate = new JLabel("0");
    peakBitrate.setForeground(fgColor);
    bitrateBuilder.add(peakBitrate, FormLayoutUtil.flip(cc.xy(3, 5), bitColSpec, orientation));

    builder.add(bitrateBuilder.getPanel(),
            FormLayoutUtil.flip(cc.xywh(5, 7, 1, 3, "left, top"), colSpec, orientation));

    JPanel panel = builder.getPanel();

    // Apply the orientation to the panel and all components in it
    panel.applyComponentOrientation(orientation);

    JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_NEVER,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    startMemoryUpdater();
    return scrollPane;
}

From source file:net.sf.jabref.gui.journals.ManageJournalsPanel.java

private void buildExternalsPanel() {

    FormBuilder builder = FormBuilder.create().layout(new FormLayout("fill:pref:grow", "p"));
    int row = 1;/*from  w  w  w  . j av a2s  .com*/
    for (ExternalFileEntry efe : externals) {
        builder.add(efe.getPanel()).xy(1, row);
        builder.appendRows("2dlu, p");
        row += 2;
    }
    builder.add(Box.createVerticalGlue()).xy(1, row);
    builder.appendRows("2dlu, p, 2dlu, p");
    builder.add(addExtPan).xy(1, row + 2);
    builder.add(Box.createVerticalGlue()).xy(1, row + 2);

    JScrollPane pane = new JScrollPane(builder.getPanel());
    pane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    externalFilesPanel.setMinimumSize(new Dimension(400, 400));
    externalFilesPanel.setPreferredSize(new Dimension(400, 400));
    externalFilesPanel.removeAll();
    externalFilesPanel.add(pane, BorderLayout.CENTER);
    externalFilesPanel.revalidate();
    externalFilesPanel.repaint();

}

From source file:org.esa.snap.rcp.statistics.StatisticsPanel.java

@Override
protected void initComponents() {
    init = true;/*from   w  w w.  jav a2  s .  c om*/

    computePanel = new MultipleRoiComputePanel(this, getRaster());
    exportButton = getExportButton();

    final JPanel exportAndHelpPanel = GridBagUtils.createPanel();
    GridBagConstraints helpPanelConstraints = GridBagUtils
            .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1,ipadx=0");
    GridBagUtils.addToPanel(exportAndHelpPanel, new JSeparator(), helpPanelConstraints,
            "fill=HORIZONTAL,gridwidth=2,insets.left=5,insets.right=5");
    GridBagUtils.addToPanel(exportAndHelpPanel, exportButton, helpPanelConstraints,
            "gridy=1,anchor=WEST,fill=NONE");
    GridBagUtils.addToPanel(exportAndHelpPanel, getHelpButton(), helpPanelConstraints,
            "gridx=1,gridy=1,anchor=EAST,fill=NONE");

    final JPanel rightPanel = GridBagUtils.createPanel();
    GridBagConstraints extendedOptionsPanelConstraints = GridBagUtils
            .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1,insets.right=-2");
    GridBagUtils.addToPanel(rightPanel, computePanel, extendedOptionsPanelConstraints,
            "gridy=0,fill=BOTH,weighty=1");
    GridBagUtils.addToPanel(rightPanel, createAccuracyPanel(), extendedOptionsPanelConstraints,
            "gridy=1,fill=BOTH,weighty=1");
    GridBagUtils.addToPanel(rightPanel, exportAndHelpPanel, extendedOptionsPanelConstraints,
            "gridy=2,anchor=SOUTHWEST,fill=HORIZONTAL,weighty=0");

    final ImageIcon collapseIcon = UIUtils.loadImageIcon("icons/PanelRight12.png");
    final ImageIcon collapseRolloverIcon = ToolButtonFactory.createRolloverIcon(collapseIcon);
    final ImageIcon expandIcon = UIUtils.loadImageIcon("icons/PanelLeft12.png");
    final ImageIcon expandRolloverIcon = ToolButtonFactory.createRolloverIcon(expandIcon);

    hideAndShowButton = ToolButtonFactory.createButton(collapseIcon, false);
    hideAndShowButton.setToolTipText("Collapse Options Panel");
    hideAndShowButton.setName("switchToChartButton");
    hideAndShowButton.addActionListener(new ActionListener() {

        public boolean rightPanelShown;

        @Override
        public void actionPerformed(ActionEvent e) {
            rightPanel.setVisible(rightPanelShown);
            if (rightPanelShown) {
                hideAndShowButton.setIcon(collapseIcon);
                hideAndShowButton.setRolloverIcon(collapseRolloverIcon);
                hideAndShowButton.setToolTipText("Collapse Options Panel");
            } else {
                hideAndShowButton.setIcon(expandIcon);
                hideAndShowButton.setRolloverIcon(expandRolloverIcon);
                hideAndShowButton.setToolTipText("Expand Options Panel");
            }
            rightPanelShown = !rightPanelShown;
        }
    });

    contentPanel = new JPanel(new GridLayout(-1, 1));
    contentPanel.setBackground(Color.WHITE);
    contentPanel.addMouseListener(popupHandler);

    final JScrollPane contentScrollPane = new JScrollPane(contentPanel);
    contentScrollPane.setBorder(null);
    contentScrollPane.setBackground(Color.WHITE);

    backgroundPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    GridBagUtils.addToPanel(backgroundPanel, contentScrollPane, gbc,
            "fill=BOTH, weightx=1.0, weighty=1.0, anchor=NORTH");
    GridBagUtils.addToPanel(backgroundPanel, rightPanel, gbc, "gridx=1, fill=VERTICAL, weightx=0.0");

    JLayeredPane layeredPane = new JLayeredPane();
    layeredPane.add(backgroundPanel);
    layeredPane.add(hideAndShowButton);
    add(layeredPane);
}

From source file:net.aepik.alasca.gui.ldap.SchemaObjectEditorFrame.java

/**
 * Build frame./*from w  w w .j a  va  2 s  .co m*/
 */
private void build() {
    setTitle("Proprits de l'objet " + objetSchema.getId());
    setSize(700, 400);
    setResizable(false);
    setLocationRelativeTo(mainFrame);

    if (mainFrame != null)
        setIconImage(mainFrame.getIconImage());

    // - Panel bouton du bas -

    JPanel boutonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    boutonsPanel.add(boutonOk);
    boutonsPanel.add(boutonAnnuler);

    // - Description -

    JTextArea textAreaValues = new JTextArea("Vous pouvez apporter des modifications sur les paramtres"
            + " de cet objet d'identifiant " + objetSchema.getId() + ". Les"
            + " modifications apportes  des paramtres non-cochs ne" + " seront pas prises en compte.");
    textAreaValues.setEditable(false);
    textAreaValues.setLineWrap(true);
    textAreaValues.setWrapStyleWord(true);
    textAreaValues.setFont((new JLabel()).getFont());
    textAreaValues.setBorder(BorderFactory.createEmptyBorder(7, 8, 7, 8));
    textAreaValues.setBackground((new JLabel()).getBackground());

    // - La table des valeurs -
    // Correction : Tri alphabtique des valeurs

    Enumeration<String> k = values.keys();
    String[] keys = new String[values.size()];

    for (int i = 0; i < keys.length; i++)
        keys[i] = k.nextElement();
    Arrays.sort(keys);

    JPanel colonne1 = new JPanel(new GridLayout(keys.length, 1));
    JPanel colonne2 = new JPanel(new GridLayout(keys.length, 1));

    // Enumeration<JComponent> l = labels.elements();
    // Enumeration<JComponent> v = values.elements();
    // Enumeration<String> k = values.keys();
    // JPanel colonne1 = new JPanel( new GridLayout( values.size(), 1 ) );
    // JPanel colonne2 = new JPanel( new GridLayout( values.size(), 1 ) );

    for (int i = 0; keys != null && i < keys.length; i++) {

        // while( l.hasMoreElements() && v.hasMoreElements() && k.hasMoreElements() ) {

        String key = keys[i];
        JComponent label = labels.get(key);
        JComponent value = values.get(key);
        JCheckBox checkbox = valuesPresent.get(key);

        // String key = k.nextElement();
        // JComponent label = l.nextElement();
        // JComponent value = v.nextElement();
        // JCheckBox checkbox = valuesPresent.get( key );

        if (!value.isEnabled() && value instanceof JTextField) {

            //value.setEnabled( true );

            JButton b = new JButton("...");
            b.setBorder(BorderFactory.createCompoundBorder(
                    BorderFactory.createMatteBorder(0, 5, 0, 0, Color.white), b.getBorder()));
            b.addActionListener(new SchemaValueEditorLauncher(b, (JTextField) value, objetSchema, key));

            JPanel tmp = new JPanel(new BorderLayout());
            tmp.add(value, BorderLayout.CENTER);
            tmp.add(b, BorderLayout.EAST);
            tmp.setOpaque(false);
            value = tmp;
        }

        JPanel panelTmp1 = new JPanel(new BorderLayout());
        panelTmp1.add(checkbox, BorderLayout.WEST);
        panelTmp1.add(label, BorderLayout.CENTER);
        panelTmp1.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 3));
        colonne1.add(panelTmp1);

        JPanel panelTmp2 = new JPanel(new BorderLayout());
        panelTmp2.add(value, BorderLayout.CENTER);
        panelTmp2.setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 3));
        colonne2.add(panelTmp2);

        checkbox.setOpaque(false);
        label.setOpaque(false);
        value.setOpaque(false);
        panelTmp1.setOpaque(false);
        panelTmp2.setOpaque(false);
    }

    JPanel tablePanel = new JPanel(new BorderLayout());
    tablePanel.add(colonne1, BorderLayout.WEST);
    tablePanel.add(colonne2, BorderLayout.EAST);
    tablePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    colonne1.setOpaque(false);
    colonne2.setOpaque(false);
    tablePanel.setOpaque(false);

    JPanel tablePanelContainer = new JPanel(new BorderLayout());
    tablePanelContainer.add(tablePanel, BorderLayout.NORTH);
    tablePanelContainer.setBackground(Color.white);

    JList tmpForBorderList = new JList();
    JScrollPane tmpForBorderScroller = new JScrollPane(tmpForBorderList);

    JScrollPane tableScroller = new JScrollPane(tablePanelContainer);
    //tableScroller.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
    tableScroller.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 6, 1, 6),
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(" Listes des paramtres "),
                    BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5),
                            tmpForBorderScroller.getBorder()))));

    // - Organisation gnrale -

    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(textAreaValues, BorderLayout.NORTH);
    mainPanel.add(tableScroller, BorderLayout.CENTER);

    JPanel mainPanelContainer = new JPanel(new BorderLayout());
    mainPanelContainer.add(mainPanel, BorderLayout.CENTER);
    mainPanelContainer.add(boutonsPanel, BorderLayout.SOUTH);
    mainPanelContainer.setBorder(BorderFactory.createEmptyBorder(2, 1, 1, 1));

    getContentPane().add(mainPanelContainer);

    // - Listeners -

    addWindowListener(this);
    boutonOk.addActionListener(this);
    boutonAnnuler.addActionListener(this);
}

From source file:edu.ku.brc.af.core.NavBox.java

/**
 * Constructor (with name).//from   w  ww .  jav a 2 s  .com
 * @param name the name of the NavBox.
 * @param collapsable indicates whether the NavBox can be collapsable
 */
public NavBox(final String name, final boolean collapsable, final boolean scrollable) {
    super();
    this.name = name;
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    this.scrollable = scrollable;

    SkinItem skinItem = SkinsMgr.getSkinItem("NavBox");

    if (scrollable) {
        itemsPanel = new JPanel();//new BoxLayout(this, BoxLayout.Y_AXIS));

        itemsPanel.setBorder(null);

        if (skinItem != null) {
            itemsPanel.setOpaque(skinItem.isOpaque());
            skinItem.setupPanel(itemsPanel);

        } else {
            itemsPanel.setBackground(NavBoxMgr.getBGColor());
        }
    }

    setBorder(BorderFactory.createEmptyBorder(22, 4, 4, 4));
    setBackground(NavBoxMgr.getBGColor());
    setOpaque(!SkinsMgr.hasSkins());

    if (scrollable) {
        JScrollPane scrollPane = new JScrollPane(itemsPanel);
        scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        scrollPane.setBorder(null);
        add(scrollPane);
    }

    if (collapsable) {
        /*
           collapsableIconOpen   = IconManager.getIcon("Minimize");
           collapsableIconClosed = IconManager.getIcon("Maximize");
                   
           addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e)
        {
            if (iconRect != null && iconRect.contains(e.getPoint()))
            {
                collapsed = !collapsed;
                if (collapsed)
                {
                    icon = collapsableIconClosed;
                    setSize(getSize().width, minHeight);
                } else
                {
                    icon = collapsableIconOpen;
                    setSize(getPreferredSize());
                }
                validate();
                invalidate();
                doLayout();
            }
        }
           });
        */ }
}

From source file:gdt.jgui.entity.procedure.JProcedurePanel.java

/**
 * The default constructor./*from   www  .  j av a  2 s.com*/
 */
public JProcedurePanel() {
    sourcePanel = new JEditorPane();
    JScrollPane scrollPaneTop = new JScrollPane(sourcePanel);
    scrollPaneTop.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Java Source",
            TitledBorder.CENTER, TitledBorder.TOP));
    reportPanel = new JEditorPane();
    JScrollPane scrollPaneBottom = new JScrollPane(reportPanel);
    scrollPaneBottom.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Report",
            TitledBorder.CENTER, TitledBorder.TOP));
    setLayout(new BorderLayout(0, 0));
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scrollPaneTop, scrollPaneBottom);
    splitPane.setDividerLocation(0.5);
    add(splitPane);
    splitPane.addComponentListener(new ShowListener());
}