Example usage for javax.swing JScrollPane setVerticalScrollBarPolicy

List of usage examples for javax.swing JScrollPane setVerticalScrollBarPolicy

Introduction

In this page you can find the example usage for javax.swing JScrollPane setVerticalScrollBarPolicy.

Prototype

@BeanProperty(preferred = true, enumerationValues = { "ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED",
        "ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER",
        "ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS" }, description = "The scrollpane vertical scrollbar policy")
public void setVerticalScrollBarPolicy(int policy) 

Source Link

Document

Determines when the vertical scrollbar appears in the scrollpane.

Usage

From source file:ome.formats.importer.gui.GuiCommonElements.java

/**
 * Add a TextArea that has scrolling functionality
 * /*from  w ww . j a  v  a  2 s  .  c om*/
 * @param container - parent container
 * @param name - name of text area
 * @param text - text to put in text area
 * @param mnemonic - mnemonic key
 * @param placement - TableLayout placement in parent container
 * @param debug - turn on/off red debug borders
 * @return JTextArea
 */
public static JTextArea addScrollingTextArea(Container container, String name, String text, int mnemonic,
        String placement, boolean debug) {
    JPanel panel = new JPanel();
    panel.setOpaque(false);

    double size[][] = { { TableLayout.FILL }, { 20, TableLayout.FILL } };
    TableLayout layout = new TableLayout(size);
    panel.setLayout(layout);

    JTextArea textArea = new JTextArea();
    textArea.setLineWrap(true);
    textArea.setOpaque(true);

    JScrollPane areaScrollPane = new JScrollPane(textArea);
    areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

    if (debug == true)
        panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red),
                panel.getBorder()));

    if (!name.equals("")) {
        JLabel label = new JLabel(name);
        label.setOpaque(false);
        label.setDisplayedMnemonic(mnemonic);
        panel.add(label, "0, 0, l, c");
        panel.add(areaScrollPane, "0, 1, f, f");
    } else {
        panel.add(areaScrollPane, "0, 0, 0, 1");
    }

    container.add(panel, placement);

    return textArea;
}

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

/**
 * Layout components.//from w  w w. ja  va 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.docx4all.swing.ExternalHyperlinkDialog.java

private void fillRow5(JPanel host, GridBagConstraints c) {
    c.gridx = 0;/*from   www.j  a  va  2 s. c o m*/
    c.gridy = 4;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.insets = gridCellInsets;
    c.ipadx = 0;
    c.ipady = 0;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.fill = GridBagConstraints.NONE;

    JPanel directoryPathPanel = new JPanel();
    directoryPathPanel.setBorder(BorderFactory.createEtchedBorder());

    this.directoryPathField = new JTextArea();
    this.directoryPathField.setEditable(false);
    this.directoryPathField.setEnabled(false);
    this.directoryPathField.setLineWrap(true);

    JScrollPane sp = new JScrollPane(this.directoryPathField);
    sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    sp.setMinimumSize(new Dimension(350, 100));
    sp.setPreferredSize(new Dimension(350, 100));
    directoryPathPanel.add(sp);
    host.add(directoryPathPanel, c);

    c.gridx = 2;
    c.gridy = 4;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.insets = gridCellInsets;
    c.ipadx = 0;
    c.ipady = 0;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.fill = GridBagConstraints.NONE;

    this.selectButton = new JButton("Select...");
    this.selectButton.addActionListener(new SelectButtonActionListener());
    this.selectButton.setSize(100, 50);
    host.add(this.selectButton, c);
}

From source file:org.drugis.addis.gui.wizard.AddStudyWizard.java

private static JComponent buildTip(String tip) {
    JTextPane area = new JTextPane();
    StyledDocument doc = area.getStyledDocument();
    addStylesToDoc(doc);/*from w w  w.  j a va 2 s . c o  m*/

    area.setBackground(new Color(255, 180, 180));

    try {
        doc.insertString(0, "x", doc.getStyle("tip"));
        doc.insertString(doc.getLength(), " Tip: \n", doc.getStyle("bold"));
        doc.insertString(doc.getLength(), tip, doc.getStyle("regular"));
    } catch (BadLocationException e) {
        e.printStackTrace();
    }

    area.setEditable(false);

    JScrollPane pane = new JScrollPane(area);
    pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    pane.setPreferredSize(TextComponentFactory.textPaneDimension(area, 270, 70));

    pane.setWheelScrollingEnabled(true);
    pane.getVerticalScrollBar().setValue(0);

    return pane;
}

From source file:org.dwfa.ace.classifier.CNFormsLabelPanel.java

public CNFormsLabelPanel(I_GetConceptData conceptIn, List<I_Position> cEditPathPos,
        List<I_Position> cClassPathPos, SnoTable cSnoTable) {
    super();//from ww  w  . ja va2s .  c  om
    this.theCBean = conceptIn;
    this.cEditPathPos = cEditPathPos;
    this.cClassPathPos = cClassPathPos;
    this.cSnoTable = cSnoTable;

    setLayout(new GridBagLayout()); // CNFormsLabelPanel LayoutManager
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.NORTHWEST; // Place
    // CNFormsLabelPanel

    // TOP ROW
    c.gridy = 0; // first row
    c.gridx = 0; // reset at west side of row
    c.weightx = 0.0; // no extra space
    c.weighty = 0.0; // no extra space
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;

    // ADD CHECK BOXES
    c.gridy++;// next row
    c.gridx = 0;
    c.gridwidth = 5;
    JLabel label = new JLabel("Normal Forms Expanded View:");
    label.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 0));
    add(label, c);
    c.gridx++;
    add(showDistFormCB, c);
    c.gridx++;
    add(showAuthFormCB, c);
    c.gridx++;
    add(showLongFormCB, c);
    c.gridx++;
    add(showShortFormCB, c);

    // FORM SELECTION CHECKBOX ROW
    c.gridy++; // next row
    c.gridx = 0; // first cell in row
    c.gridwidth = 1;
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;

    label = new JLabel("Information:");
    label.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 0));
    add(label, c);

    c.gridx++;
    add(showDetailCB, c);
    c.gridx++;
    add(showStatusCB, c);

    // SETUP CHECKBOX VALUES & LISTENER
    showStatusCB.setSelected(false);
    showStatusCB.addActionListener(this);
    showDetailCB.setSelected(false);
    showDetailCB.addActionListener(this);
    showDistFormCB.setSelected(false);
    showDistFormCB.addActionListener(this);
    showAuthFormCB.setSelected(false);
    showAuthFormCB.addActionListener(this);
    showLongFormCB.setSelected(false);
    showLongFormCB.addActionListener(this);
    showShortFormCB.setSelected(false);
    showShortFormCB.addActionListener(this);

    // COMMON & DIFFERENT PANELS ROW
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 0;
    commonJPanel = newMinMaxJPanel();
    commonJPanel.setLayout(new GridLayout(0, 1));
    commonJPanel.setName("Common Panel");
    commonJPanel.setBorder(BorderFactory.createTitledBorder("Common: "));
    add(commonJPanel, c);

    c.gridx = c.gridx + 1;
    deltaJPanel = newMinMaxJPanel();
    deltaJPanel.setLayout(new GridLayout(0, 1));
    deltaJPanel.setName("Differences Panel");
    deltaJPanel.setBorder(BorderFactory.createTitledBorder("Different: "));
    add(deltaJPanel, c);

    // FORMS PANEL ROW
    c.gridy++;// next row
    c.gridx = 0; // reset at west side of row
    c.gridwidth = 2; // number of cells in row
    c.fill = GridBagConstraints.BOTH;
    formsJPanel = new JPanel(new GridBagLayout());
    formsJPanel.setName("Forms Panel");
    formsJPanel.setBorder(BorderFactory.createTitledBorder("Forms: "));
    JScrollPane formJScrollPane = new JScrollPane(formsJPanel);
    formJScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
    add(formJScrollPane, c);

}

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.executequery.gui.importexport.ImportExportPanelThree.java

private void init() {

    table = new DefaultTable();
    table.setRowHeight(23);//ww w . java2 s. c  o m
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setColumnSelectionAllowed(false);
    table.getTableHeader().setReorderingAllowed(false);

    JScrollPane scroller = new JScrollPane(table);
    scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(5, 5, 5, 5);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    add(new JLabel(getString("ImportExportPanelThree.label")), gbc);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridy = 1;
    gbc.insets.top = 0;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    add(scroller, gbc);

}

From source file:org.jajuk.ui.views.ArtistView.java

@Override
public void shortCall(Object in) {
    removeAll();//from  w  ww  .j  a v a2s .c o m
    jspAlbums = getLastFMSuggestionsPanel(SuggestionType.OTHERS_ALBUMS, true);
    // Artist unknown from last.fm, leave
    if (artistInfo == null
            // If image url is void, last.fm doesn't provide enough data about this
            // artist, we reset the view
            || StringUtils.isBlank(artistInfo.getImageUrl())) {
        reset();
        return;
    }
    artistThumb = new LastFmArtistThumbnail(artistInfo);
    // No known icon next to artist thumb
    artistThumb.setArtistView(true);
    artistThumb.populate();
    jtaArtistDesc = new JTextArea(bio) {
        private static final long serialVersionUID = 9217998016482118852L;

        // We set the margin this way, setMargin() doesn't work due to
        // existing border
        @Override
        public Insets getInsets() {
            return new Insets(2, 4, 0, 4);
        }
    };
    jtaArtistDesc.setBorder(null);
    jtaArtistDesc.setEditable(false);
    jtaArtistDesc.setLineWrap(true);
    jtaArtistDesc.setWrapStyleWord(true);
    jtaArtistDesc.setOpaque(false);
    JScrollPane jspWiki = new JScrollPane(jtaArtistDesc);
    jspWiki.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    jspWiki.setBorder(null);
    jspWiki.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    // Add items, layout is different according wiki text availability
    if (StringUtils.isNotBlank(jtaArtistDesc.getText())) {
        setLayout(new MigLayout("ins 5,gapy 5", "[grow]", "[grow][20%!][grow]"));
        add(artistThumb, "center,wrap");
        // don't add the textarea if no wiki text available
        add(jspWiki, "growx,wrap");
        add(jspAlbums, "grow,wrap");
    } else {
        setLayout(new MigLayout("ins 5,gapy 5", "[grow]"));
        add(artistThumb, "center,wrap");
        // don't add the textarea if no wiki text available
        add(jspAlbums, "grow,wrap");
    }
    revalidate();
    repaint();
}

From source file:org.kepler.gui.ComponentLibraryPreferencesTab.java

/**
 * Initialize the source list table.//from  w ww .ja  va2  s.  c o  m
 */
private void initSourceList() {

    try {

        ComponentSourceTableModel cstm = new ComponentSourceTableModel();
        _sourceList = new JTable(cstm);
        _sourceList.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        _sourceList.setShowGrid(true);
        _sourceList.setShowHorizontalLines(true);
        _sourceList.setShowVerticalLines(true);
        _sourceList.setGridColor(Color.lightGray);
        _sourceList.setIntercellSpacing(new Dimension(5, 5));
        _sourceList.setRowHeight(_sourceList.getRowHeight() + 10);
        _sourceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        if (isDebugging) {
            log.debug("intercellspacing: " + _sourceList.getIntercellSpacing().toString());
            log.debug("getRowHeight(): " + _sourceList.getRowHeight());
        }

        // Search column
        TableColumn c0 = _sourceList.getColumnModel().getColumn(0);
        c0.setMinWidth(50);
        c0.setPreferredWidth(60);
        c0.setMaxWidth(100);
        c0.setResizable(true);

        // Save column
        TableColumn c1 = _sourceList.getColumnModel().getColumn(1);
        c1.setMinWidth(50);
        c1.setPreferredWidth(60);
        c1.setMaxWidth(100);
        c1.setResizable(true);

        // Type column
        TableColumn c2 = _sourceList.getColumnModel().getColumn(2);
        c2.setMinWidth(50);
        c2.setPreferredWidth(60);
        c2.setMaxWidth(100);
        c2.setResizable(true);

        // Name column
        TableColumn c3 = _sourceList.getColumnModel().getColumn(3);
        c3.setMinWidth(50);
        c3.setPreferredWidth(100);
        c3.setMaxWidth(200);
        c3.setResizable(true);

        // Source column
        TableColumn c4 = _sourceList.getColumnModel().getColumn(4);
        c4.setMinWidth(200);
        c4.setPreferredWidth(600);
        c4.setMaxWidth(2000);
        c4.setResizable(true);

        JScrollPane sourceListSP = new JScrollPane(_sourceList);
        sourceListSP.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        sourceListSP.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
        sourceListSP.setBackground(TabManager.BGCOLOR);
        add(sourceListSP);
    } catch (Exception e) {
        System.out.println(e.toString());
    }

}

From source file:org.kepler.gui.DialogGeneralTab.java

/**
 * getCenterPanel/* ww  w .  ja  v a 2s  . co m*/
 * 
 * @return Component
 */
protected Component getCenterPanel() {
    Box centerPanel = Box.createHorizontalBox();

    final Border middlePanelPaddingBorder = BorderFactory.createEmptyBorder( // top, left, bottom, right
            StaticResources.getSize("dialogs.tabPanels.padding.top", 0), 0, 0, 0);

    centerPanel.setBorder(middlePanelPaddingBorder);

    JLabel noteLbl = WidgetFactory.makeJLabel(
            StaticResources.getDisplayString("dialogs." + _targetType + ".general.note", "Note"),
            TabbedDialog.jLabelDims);
    centerPanel.add(noteLbl);

    noteTxtArea = WidgetFactory.makeJTextArea(_target != null ? _target.getName() : "");
    JScrollPane scrollPane = new JScrollPane(noteTxtArea);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(scrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setWheelScrollingEnabled(true);
    centerPanel.add(scrollPane);

    return centerPanel;
}