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:org.tinymediamanager.ui.tvshows.settings.TvShowSubtitleSettingsPanel.java

private void initComponents() {
    // data init// w w w .  j av  a2s  . co  m
    List<String> enabledSubtitleProviders = settings.getTvShowSubtitleScrapers();
    int selectedIndex = -1;
    int counter = 0;
    for (MediaScraper scraper : TvShowList.getInstance().getAvailableSubtitleScrapers()) {
        SubtitleScraper subtitleScraper = new SubtitleScraper(scraper);
        if (enabledSubtitleProviders.contains(subtitleScraper.getScraperId())) {
            subtitleScraper.active = true;
            if (selectedIndex < 0) {
                selectedIndex = counter;
            }
        }
        scrapers.add(subtitleScraper);
        counter++;
    }

    // UI init
    setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    JPanel panelSubtitleScrapers = new JPanel();
    panelSubtitleScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"),
            BUNDLE.getString("scraper.subtitle"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$
    add(panelSubtitleScrapers, "2, 2, 5, 1, fill, fill");
    panelSubtitleScrapers.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"), }));

    final JScrollPane scrollPaneScraperDetails = new JScrollPane();
    scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPaneScraperDetails.setBorder(null);
    panelSubtitleScrapers.add(scrollPaneScraperDetails, "4, 1, 1, 2, fill, fill");

    JPanel panelScraperDetails = new JPanel();
    scrollPaneScraperDetails.setViewportView(panelScraperDetails);
    panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), },
            new RowSpec[] { RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, }));
    {
        // add a CSS rule to force body tags to use the default label font
        // instead of the value in javax.swing.text.html.default.csss
        Font font = UIManager.getFont("Label.font");
        String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize()
                + "pt; }";
        tpScraperDescription = new JTextPane();
        tpScraperDescription.setOpaque(false);
        tpScraperDescription.setEditorKit(new HTMLEditorKit());
        ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule);
        panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top");
    }
    panelScraperOptions = new ScrollablePanel();
    panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT));
    panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top");

    JScrollPane scrollPaneScraper = new JScrollPane();
    panelSubtitleScrapers.add(scrollPaneScraper, "2, 2, fill, fill");

    tableScraper = new JTable();
    tableScraper.setRowHeight(29);
    scrollPaneScraper.setViewportView(tableScraper);

    final JLabel lblScraperLanguage = new JLabel(BUNDLE.getString("Settings.preferredLanguage")); //$NON-NLS-1$
    add(lblScraperLanguage, "2, 4, right, default");

    cbScraperLanguage = new JComboBox(MediaLanguages.values());
    add(cbScraperLanguage, "4, 4, fill, default");

    initDataBindings();

    // adjust table columns
    // Checkbox and Logo shall have minimal width
    TableColumnResizer.setMaxWidthForColumn(tableScraper, 0, 2);
    TableColumnResizer.setMaxWidthForColumn(tableScraper, 1, 2);
    TableColumnResizer.adjustColumnPreferredWidths(tableScraper, 5);

    tableScraper.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent arg0) {
            // click on the checkbox
            if (arg0.getColumn() == 0) {
                int row = arg0.getFirstRow();
                SubtitleScraper changedScraper = scrapers.get(row);
                if (changedScraper.active) {
                    settings.addTvShowSubtitleScraper(changedScraper.getScraperId());
                } else {
                    settings.removeTvShowSubtitleScraper(changedScraper.getScraperId());
                }
            }
        }
    });

    // implement selection listener to load settings
    tableScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            int index = tableScraper.convertRowIndexToModel(tableScraper.getSelectedRow());
            if (index > -1) {
                panelScraperOptions.removeAll();
                if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) {
                    panelScraperOptions
                            .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider()));
                }
                panelScraperOptions.revalidate();
            }
        }
    });

    // select default tv show subtitle scraper
    if (selectedIndex < 0) {
        selectedIndex = 0;
    }
    if (counter > 0) {
        tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
    }
}

From source file:org.ut.biolab.medsavant.client.view.component.ListViewTablePanel.java

public ListViewTablePanel(Object[][] data, String[] columnNames, Class[] columnClasses, int[] hiddenColumns,
        boolean allowSearch, boolean allowSort, boolean allowPages, boolean allowSelection) {

    this.hiddenColumns = hiddenColumns;
    table = new SortableTable() {
        @Override/*from   w  w  w. j a  v  a 2  s. c  o m*/
        public Component prepareRenderer(TableCellRenderer renderer, int Index_row, int Index_col) {
            Component comp = super.prepareRenderer(renderer, Index_row, Index_col);
            //even index, selected or not selected

            if (isRowSelected(Index_row)) {
                comp.setBackground(ViewUtil.detailSelectedBackground);
            } else {
                if (Index_row % 2 == 0) {
                    comp.setBackground(evenRowColor);
                } else {
                    comp.setBackground(oddRowColor);
                }
            }
            comp.setForeground(ViewUtil.detailForeground);

            comp.setFont(comp.getFont().deriveFont(fontSize));

            return comp;
        }
    };

    table.setBorder(null);
    table.setSelectionForeground(Color.darkGray);
    table.setRowHeight(30);
    table.setClearSelectionOnTableDataChanges(true);
    table.setOptimized(true);
    table.setColumnAutoResizable(true);
    table.setAutoResort(false);
    //table.setDragEnabled(false);
    //table.setRowHeight(20);
    table.setSortable(allowSort);
    table.setSortingEnabled(allowSort);
    table.setFocusable(allowSelection);
    table.setCellSelectionEnabled(allowSelection);
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    table.setAutoResizeMode(SortableTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

    //table.setMinimumSize(new Dimension(500,999));
    //table.setPreferredSize(new Dimension(500,999));

    //column chooser
    TableHeaderPopupMenuInstaller installer = new TableHeaderPopupMenuInstaller(table);
    installer.addTableHeaderPopupMenuCustomizer(new AutoResizePopupMenuCustomizer());
    columnChooser = new ColumnChooser(table);
    installer.addTableHeaderPopupMenuCustomizer(columnChooser);

    AutoFilterTableHeader header = new AutoFilterTableHeader(table);
    header.setAutoFilterEnabled(true);
    header.setShowFilterIcon(true);
    header.setShowFilterName(true);
    table.setTableHeader(header);

    filterField = new QuickTableFilterField(model);
    filterField.setHintText("Type to search");

    setLayout(new BorderLayout(3, 3));
    fieldPanel = ViewUtil.getClearPanel();
    fieldPanel.setLayout(new GridBagLayout());
    setOpaque(false);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    //gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.fill = GridBagConstraints.BOTH;
    if (allowSearch) {
        fieldPanel.add(filterField, gbc);
    }
    if (columnNames.length > 1) {
        JButton chooseColumnButton = new JButton("Fields");
        chooseColumnButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseReleased(MouseEvent e) {
                columnChooser.showDialog();
            }
        });
        gbc.weightx = 0.0;
        gbc.fill = GridBagConstraints.NONE;
        fieldPanel.add(chooseColumnButton, gbc);
    }

    setTableModel(data, columnNames, columnClasses);

    if (allowSort) {
        add(fieldPanel, BorderLayout.NORTH);
    }

    JScrollPane jsp = new JScrollPane(table);
    jsp.setBorder(null);
    add(jsp, BorderLayout.CENTER);

    updateData(data);
    updateView();
}

From source file:org.ut.biolab.medsavant.client.view.component.SearchableTablePanel.java

public SearchableTablePanel(String pageName, String[] columnNames, Class[] columnClasses, int[] hiddenColumns,
        boolean allowSearch, boolean allowSort, int defaultRows, boolean allowPages,
        TableSelectionType selectionType, int defaultRowsRetrieved, DataRetriever<Object[]> retriever) {

    this.pageName = pageName;
    this.rowsPerPageX = defaultRows;
    this.defaultRowsRetrieved = defaultRowsRetrieved;

    this.retriever = retriever;
    this.hiddenColumns = hiddenColumns;
    table = new SortableTable() {
        @Override/*w w w . jav a  2  s .c o m*/
        public Component prepareRenderer(TableCellRenderer renderer, int row, int col) {
            synchronized (SearchableTablePanel.this) {
                JComponent comp = (JComponent) super.prepareRenderer(renderer, row, col);

                // Even index, selected or not selected
                if (isRowToggled(TableModelWrapperUtils.getActualRowAt(this.getSortableTableModel(), row))) { //this.getActualRowAt(this.getSortedRowAt(row)))) {
                    comp.setBackground(new Color(178, 225, 92));
                } else if (isCellSelected(row, col)) {
                    //comp.setBackground(new Color(75, 149, 229));
                    comp.setBackground(SELECTED_COLOUR);
                } else if (selectedRows != null
                        && selectedRows.contains(TableModelWrapperUtils.getActualRowAt(getModel(), row))) {
                    //comp.setBackground(SELECTED_COLOUR);
                } else if (row % 2 == 0 && !isCellSelected(row, col)) {
                    comp.setBackground(Color.WHITE);
                } else {
                    comp.setBackground(DARK_COLOUR);
                }

                comp.setBorder(BorderFactory.createEmptyBorder(0, 7, 0, 7));
                return comp;
            }
        }

        @Override
        public String getToolTipText(MouseEvent e) {
            return getToolTip(
                    TableModelWrapperUtils.getActualRowAt(table.getModel(), table.rowAtPoint(e.getPoint())));
        }
    };

    table.setToolTipText(""); //necessary to force check for tooltip text

    table.setClearSelectionOnTableDataChanges(true);
    table.setOptimized(true);
    table.setColumnAutoResizable(true);
    table.setAutoResort(false);
    table.setRowHeight(20);
    table.setSortable(allowSort);
    table.setSortingEnabled(allowSort);
    table.setFocusable(selectionType != TableSelectionType.DISABLED);
    //table.setCellSelectionEnabled(allowSelection);
    table.setCellSelectionEnabled(selectionType == TableSelectionType.CELL);
    table.setRowSelectionAllowed(selectionType == TableSelectionType.ROW);

    table.setAutoResizeMode(SortableTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

    //column chooser
    TableHeaderPopupMenuInstaller installer = new TableHeaderPopupMenuInstaller(table);
    installer.addTableHeaderPopupMenuCustomizer(new AutoResizePopupMenuCustomizer());
    columnChooser = new ColumnChooser(table);
    installer.addTableHeaderPopupMenuCustomizer(columnChooser);

    AutoFilterTableHeader header = new AutoFilterTableHeader(table);
    header.setAutoFilterEnabled(true);
    header.setShowFilterIcon(true);
    header.setShowFilterName(true);
    table.setTableHeader(header);

    filterField = new QuickTableFilterField(model);

    if (allowPages) {
        filterField.setHintText("Search for anything on the page");
    } else {
        filterField.setHintText("Search for anything");
    }

    setLayout(new BorderLayout(3, 3));
    fieldPanel = ViewUtil.getClearPanel();

    if (allowSearch) {
        fieldPanel.add(filterField);
    }

    chooseColumnButton = new JButton("Columns");
    chooseColumnButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            columnChooser.showDialog();
        }
    });

    helpButton = ViewUtil.getHelpButton("About Variant List",
            "Variants are sorted first by DNA ID, then by position.  The list of variants within each page can be sorted by various fields by clicking the corresponding column name, but note that this will only sort the current page.");
    exportButton = new JButton("Export");
    exportButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            try {
                ExportTable.exportTable(table);
            } catch (Exception ex) {
                LOG.error("Error while exporting.", ex);
                DialogUtils.displayException("MedSavant",
                        "<HTML>A problem occurred while exporting.<BR>Make sure the output file is not already in use.</HTML>",
                        ex);
            }
        }
    });

    fieldPanel.add(helpButton);
    fieldPanel.add(chooseColumnButton);
    fieldPanel.add(exportButton);

    bottomPanel = ViewUtil.getClearPanel();
    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS));

    gotoFirst = niceButton();
    gotoPrevious = niceButton();
    gotoNext = niceButton();
    gotoLast = niceButton();

    gotoFirst.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.FIRST));
    gotoPrevious.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.PREVIOUS));
    gotoNext.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.NEXT));
    gotoLast.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.LAST));

    gotoFirst.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            goToFirstPage();
        }
    });
    gotoPrevious.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            goToPreviousPage();
        }
    });
    gotoNext.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            goToNextPage();
        }
    });
    gotoLast.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            goToLastPage();
        }
    });

    pageText = new JTextField();
    ViewUtil.makeSmall(pageText);
    pageText.setColumns(5);
    pageText.setMaximumSize(new Dimension(50, 20));
    pageText.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            int key = e.getKeyCode();
            if (key == KeyEvent.VK_ENTER) {
                try {
                    setPageNumber(Integer.parseInt(pageText.getText()));
                } catch (NumberFormatException ex) {
                    setPageNumber(0);
                }
            }
        }
    });

    amountLabel = new JLabel();
    ViewUtil.makeSmall(amountLabel);
    bottomPanel.add(amountLabel);

    pageLabel1 = new JLabel("Page ");
    ViewUtil.makeSmall(pageLabel1);
    pageLabel2 = new JLabel();
    ViewUtil.makeSmall(pageLabel2);

    bottomPanel.add(Box.createHorizontalGlue());
    bottomPanel.add(gotoFirst);
    bottomPanel.add(gotoPrevious);
    strut(bottomPanel);
    bottomPanel.add(pageLabel1);
    bottomPanel.add(pageText);
    bottomPanel.add(pageLabel2);
    strut(bottomPanel);
    bottomPanel.add(gotoNext);
    bottomPanel.add(gotoLast);
    bottomPanel.add(Box.createHorizontalGlue());

    strut(bottomPanel);

    JLabel perpageL = new JLabel("Per page:");
    ViewUtil.makeSmall(perpageL);
    bottomPanel.add(perpageL);

    strut(bottomPanel);

    boolean hasDefaultRowsPerPage = true;
    if (rowsPerPageX == ROWSPERPAGE_1 || rowsPerPageX == ROWSPERPAGE_2 || rowsPerPageX == ROWSPERPAGE_3) {
        hasDefaultRowsPerPage = false;
    }
    ArrayList<Integer> rowsList = new ArrayList<Integer>();
    rowsList.add(ROWSPERPAGE_1);
    rowsList.add(ROWSPERPAGE_2);
    rowsList.add(ROWSPERPAGE_3);
    Integer[] finalList = new Integer[3];
    if (hasDefaultRowsPerPage) {
        rowsList.add(rowsPerPageX);
        Collections.sort(rowsList);
    }
    finalList = rowsList.toArray(finalList);

    rowsPerPageDropdown = new JComboBox(finalList);
    ViewUtil.makeSmall(rowsPerPageDropdown);
    rowsPerPageDropdown.setPrototypeDisplayValue(ROWSPERPAGE_3);
    if (hasDefaultRowsPerPage) {
        rowsPerPageDropdown.setSelectedIndex(rowsList.indexOf(rowsPerPageX));
    } else {
        rowsPerPageDropdown.setSelectedIndex(1);
    }
    rowsPerPageDropdown.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JComboBox cb = (JComboBox) e.getSource();
            int rowsPerPage = (Integer) cb.getSelectedItem();
            setNumRowsPerPage(rowsPerPage);
        }
    });
    rowsPerPageDropdown.setPreferredSize(new Dimension(100, 25));
    rowsPerPageDropdown.setMaximumSize(new Dimension(100, 25));
    bottomPanel.add(rowsPerPageDropdown);

    setTableModel(data, columnNames, columnClasses);

    JPanel tablePanel = new JPanel(new BorderLayout(3, 3));
    JScrollPane jsp = new JScrollPane(table);
    jsp.setBorder(null);
    tablePanel.add(jsp);

    if (allowSort) {
        add(fieldPanel, BorderLayout.NORTH);
    }

    if (allowPages) {
        add(bottomPanel, BorderLayout.SOUTH);
    }

    add(tablePanel, BorderLayout.CENTER);

    initEmpty();
}

From source file:org.zaproxy.zap.extension.ascan.CustomScanDialog.java

private JPanel getTechPanel() {
    if (techPanel == null) {
        techPanel = new JPanel(new GridBagLayout());

        JScrollPane scrollPane = new JScrollPane();
        scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
        scrollPane.setViewportView(getTechTree());
        scrollPane.setBorder(
                javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        techPanel.add(scrollPane, LayoutHelper.getGBC(0, 0, 1, 1, 1.0D, 1.0D));
    }/*  w  w w. j  a v a2s.c  o  m*/

    return techPanel;
}

From source file:org.zaproxy.zap.extension.customFire.CustomFireDialog.java

private JPanel getTechPanel() {
    //if (techPanel == null) {
    techPanel = new JPanel(new GridBagLayout());

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setViewportView(getTechTree());
    scrollPane.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

    techPanel.add(scrollPane, LayoutHelper.getGBC(0, 0, 1, 1, 1.0D, 1.0D));
    //}//  w w w. j ava2 s . c  o  m

    return techPanel;
}

From source file:org.zaproxy.zap.extension.customFire.CustomFireDialog.java

/**
 * Not used as of now//  ww w  .  j av  a  2  s.  c o m
 * @return JPanel 
 */
private JPanel getScriptPanel() {
    //if (sPanel == null) {
    sPanel = new JPanel(new GridBagLayout());

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setViewportView(getSTree());
    scrollPane.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

    sPanel.add(scrollPane, LayoutHelper.getGBC(0, 0, 1, 1, 1.0D, 1.0D));
    //}

    return sPanel;
}

From source file:org.zaproxy.zap.extension.customFire.TechnologyTreePanel.java

public TechnologyTreePanel(String nameRootNode) {
    setLayout(new BorderLayout());

    techToNodeMap = new HashMap<>();
    techTree = new JCheckBoxScriptsTree() {

        private static final long serialVersionUID = 1L;

        @Override//  ww w  .j  a  va  2 s .  c o  m
        protected void setExpandedState(TreePath path, boolean state) {
            // Ignore all collapse requests; collapse events will not be fired
            if (state) {
                super.setExpandedState(path, state);
            }
        }

    };
    // Initialise the structure based on all the tech we know about
    TechSet ts = new TechSet(Tech.builtInTech);
    Iterator<Tech> iter = ts.getIncludeTech().iterator();

    DefaultMutableTreeNode root = new DefaultMutableTreeNode(nameRootNode);
    Tech tech;
    DefaultMutableTreeNode parent;
    DefaultMutableTreeNode node;
    while (iter.hasNext()) {
        tech = iter.next();
        if (tech.getParent() != null) {
            parent = techToNodeMap.get(tech.getParent());
        } else {
            parent = null;
        }
        if (parent == null) {
            parent = root;
        }
        node = new DefaultMutableTreeNode(tech.getUiName());
        parent.add(node);
        techToNodeMap.put(tech, node);
    }

    techTree.setModel(new DefaultTreeModel(root));
    techTree.expandAll();
    techTree.setCheckBoxEnabled(new TreePath(root), false);
    reset();

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setViewportView(techTree);
    scrollPane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));

    add(scrollPane, BorderLayout.CENTER);
}

From source file:org.zaproxy.zap.extension.encoder2.EncodeDecodeDialog.java

private void addField(JPanel parent, int index, JComponent c, String title) {
    final java.awt.GridBagConstraints gbc = new GridBagConstraints();

    gbc.gridx = 0;//from  w w  w  .  j  a v  a2 s  .c o  m
    gbc.gridy = index;
    gbc.insets = new java.awt.Insets(1, 1, 1, 1);
    gbc.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gbc.fill = java.awt.GridBagConstraints.BOTH;
    gbc.weightx = 0.5D;
    gbc.weighty = 0.5D;

    final JScrollPane jsp = new JScrollPane();
    jsp.setViewportView(c);
    jsp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    jsp.setBorder(BorderFactory.createTitledBorder(null, title, TitledBorder.DEFAULT_JUSTIFICATION,
            javax.swing.border.TitledBorder.DEFAULT_POSITION, FontUtils.getFont(FontUtils.Size.standard),
            java.awt.Color.black));

    parent.add(jsp, gbc);
}

From source file:org.zaproxy.zap.extension.encoder2.EncodeDecodeDialog.java

/**
 * This method initializes jPanel// w  w w. j av a2  s  . c o m
 *
 * @return javax.swing.JPanel
 */
private JPanel getJTabbed() {
    if (jPanel == null) {
        /*
        jPanel = new JPanel();
        jPanel.setPreferredSize(new java.awt.Dimension(800,600));
                
        jPanel.setLayout(new GridBagLayout());
        */

        // jPanel is the outside one
        jPanel = new JPanel();
        jPanel.setPreferredSize(new java.awt.Dimension(800, 600));
        jPanel.setLayout(new GridBagLayout());

        jTabbed = new JTabbedPane();
        jTabbed.setPreferredSize(new java.awt.Dimension(800, 500));

        final JPanel jPanel1 = new JPanel();
        jPanel1.setLayout(new GridBagLayout());

        final JPanel jPanel2 = new JPanel();
        //jPanel2.setPreferredSize(new java.awt.Dimension(800,500));
        jPanel2.setLayout(new GridBagLayout());

        final JPanel jPanel3 = new JPanel();

        //jPanel3.setPreferredSize(new java.awt.Dimension(800,500));
        jPanel3.setLayout(new GridBagLayout());

        final JPanel jPanel4 = new JPanel();
        jPanel4.setLayout(new GridBagLayout());

        // 3 tabs - Encode, Decode, Hash??
        addField(jPanel1, 1, getBase64EncodeField(), Constant.messages.getString("enc2.label.b64Enc"));
        addField(jPanel1, 2, getUrlEncodeField(), Constant.messages.getString("enc2.label.urlEnc"));
        addField(jPanel1, 3, getAsciiHexEncodeField(), Constant.messages.getString("enc2.label.asciiEnc"));
        addField(jPanel1, 4, getHTMLEncodeField(), Constant.messages.getString("enc2.label.HTMLEnc"));
        addField(jPanel1, 5, getJavaScriptEncodeField(),
                Constant.messages.getString("enc2.label.JavaScriptEnc"));

        addField(jPanel2, 1, getBase64DecodeField(), Constant.messages.getString("enc2.label.b64Dec"));
        addField(jPanel2, 2, getUrlDecodeField(), Constant.messages.getString("enc2.label.urlDec"));
        addField(jPanel2, 3, getAsciiHexDecodeField(), Constant.messages.getString("enc2.label.asciiDec"));
        addField(jPanel2, 4, getHTMLDecodeField(), Constant.messages.getString("enc2.label.HTMLDec"));
        addField(jPanel2, 5, getJavaScriptDecodeField(),
                Constant.messages.getString("enc2.label.JavaScriptDec"));

        addField(jPanel3, 1, getSha1HashField(), Constant.messages.getString("enc2.label.sha1Hash"));
        addField(jPanel3, 2, getMd5HashField(), Constant.messages.getString("enc2.label.md5Hash"));

        addField(jPanel4, 1, getIllegalUTF82ByteField(),
                Constant.messages.getString("enc2.label.illegalUTF8.2byte"));
        addField(jPanel4, 2, getIllegalUTF83ByteField(),
                Constant.messages.getString("enc2.label.illegalUTF8.3byte"));
        addField(jPanel4, 3, getIllegalUTF84ByteField(),
                Constant.messages.getString("enc2.label.illegalUTF8.4byte"));

        jTabbed.addTab(Constant.messages.getString("enc2.tab.encode"), jPanel1);
        jTabbed.addTab(Constant.messages.getString("enc2.tab.decode"), jPanel2);
        jTabbed.addTab(Constant.messages.getString("enc2.tab.hash"), jPanel3);
        jTabbed.addTab(Constant.messages.getString("enc2.tab.illegalUTF8"), jPanel4);

        final java.awt.GridBagConstraints gbc1 = new GridBagConstraints();
        gbc1.gridx = 0;
        gbc1.gridy = 1;
        gbc1.insets = new java.awt.Insets(1, 1, 1, 1);
        gbc1.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gbc1.fill = java.awt.GridBagConstraints.BOTH;
        gbc1.weightx = 1.0D;
        gbc1.weighty = 0.25D;

        final java.awt.GridBagConstraints gbc2 = new GridBagConstraints();
        gbc2.gridx = 0;
        gbc2.gridy = 2;
        gbc2.insets = new java.awt.Insets(1, 1, 1, 1);
        gbc2.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gbc2.fill = java.awt.GridBagConstraints.BOTH;
        gbc2.weightx = 1.0D;
        gbc2.weighty = 1.0D;

        final JScrollPane jsp = new JScrollPane();
        jsp.setViewportView(getInputField());
        jsp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jsp.setBorder(BorderFactory.createTitledBorder(null, Constant.messages.getString("enc2.label.text"),
                TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION,
                FontUtils.getFont(FontUtils.Size.standard), java.awt.Color.black));

        //addField(jPanel, 1, getInputField(), "Text to be encoded/decoded/hashed");
        //addField(jPanel, 2, jTabbed, "Text to be encoded/decoded/hashed");

        jPanel.add(jsp, gbc1);
        jPanel.add(jTabbed, gbc2);

        jPanel2.requestFocus();

    }
    return jPanel;
}

From source file:org.zaproxy.zap.view.TechnologyTreePanel.java

public TechnologyTreePanel(String nameRootNode) {
    setLayout(new BorderLayout());

    techToNodeMap = new HashMap<>();
    techTree = new JCheckBoxTree() {

        private static final long serialVersionUID = 1L;

        @Override/*from w w  w.j  a va2 s  . com*/
        protected void setExpandedState(TreePath path, boolean state) {
            // Ignore all collapse requests; collapse events will not be fired
            if (state) {
                super.setExpandedState(path, state);
            }
        }
    };
    // Initialise the structure based on all the tech we know about
    TechSet ts = new TechSet(Tech.builtInTech);
    Iterator<Tech> iter = ts.getIncludeTech().iterator();

    DefaultMutableTreeNode root = new DefaultMutableTreeNode(nameRootNode);
    Tech tech;
    DefaultMutableTreeNode parent;
    DefaultMutableTreeNode node;
    while (iter.hasNext()) {
        tech = iter.next();
        if (tech.getParent() != null) {
            parent = techToNodeMap.get(tech.getParent());
        } else {
            parent = null;
        }
        if (parent == null) {
            parent = root;
        }
        node = new DefaultMutableTreeNode(tech.getUiName());
        parent.add(node);
        techToNodeMap.put(tech, node);
    }

    techTree.setModel(new DefaultTreeModel(root));
    techTree.expandAll();
    techTree.setCheckBoxEnabled(new TreePath(root), false);
    reset();

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setViewportView(techTree);
    scrollPane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));

    add(scrollPane, BorderLayout.CENTER);
}