Java Code Examples for javax.swing.ScrollPaneConstants

The following examples show how to use javax.swing.ScrollPaneConstants. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: pcgen   Source File: NoteInfoPane.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
private void initComponents()
{
	setLayout(new BorderLayout());

	Box hbox = Box.createHorizontalBox();
	hbox.add(Box.createRigidArea(new Dimension(5, 0)));
	hbox.add(new JLabel(LanguageBundle.getString("in_descNoteName"))); //$NON-NLS-1$
	hbox.add(Box.createRigidArea(new Dimension(5, 0)));
	hbox.add(nameField);
	nameField.setText(name);
	hbox.add(Box.createRigidArea(new Dimension(5, 0)));
	hbox.add(removeButton);
	hbox.add(Box.createHorizontalGlue());

	noteField.setLineWrap(true);
	noteField.setWrapStyleWord(true);

	add(hbox, BorderLayout.NORTH);
	JScrollPane pane = new JScrollPane(noteField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
		ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	add(pane, BorderLayout.CENTER);
}
 
Example 2
Source Project: constellation   Source File: BasicFindPanel.java    License: Apache License 2.0 6 votes vote down vote up
private void setupComboBox() {

        Dimension dropdownSize = new Dimension(INITIAL_DROPDOWN_WIDTH, INITIAL_DROPDOWN_HEIGHT);

        BoxLayout layout = new BoxLayout(dropDownPanel, BoxLayout.Y_AXIS);
        dropDownPanel.setLayout(layout);
        dropDownPanel.setMaximumSize(new Dimension(dropdownSize.width, Integer.MAX_VALUE));

        scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        scrollPane.setMaximumSize(dropdownSize);
        scrollPane.setPreferredSize(dropdownSize);
        scrollPane.setViewportView(dropDownPanel);

        attributeDropDownMenu.setMaximumSize(dropdownSize);
        attributeDropDownMenu.setPreferredSize(dropdownSize);
        attributeDropDownMenu.add(scrollPane);
        resetComboBox();

    }
 
Example 3
Source Project: javamelody   Source File: Utilities.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Fixe la taille exacte d'une JTable à celle nécessaire pour afficher les données.
 * @param table JTable
 */
public static void adjustTableHeight(final JTable table) {
	table.setPreferredScrollableViewportSize(
			new Dimension(-1, table.getPreferredSize().height));
	// on utilise invokeLater pour configurer le scrollPane car lors de l'exécution ce cette méthode
	// la table n'est pas encore dans son scrollPane parent
	SwingUtilities.invokeLater(new Runnable() {
		@Override
		public void run() {
			final JScrollPane scrollPane = MSwingUtilities.getAncestorOfClass(JScrollPane.class,
					table);
			scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
			// Puisqu'il n'y a pas d'ascenceur sur ce scrollPane,
			// il est inutile que la mollette de souris serve à bouger cet ascenseur,
			// mais il est très utile en revanche que ce scrollPane ne bloque pas l'utilisation
			// de la mollette de souris pour le scrollPane global de l'onglet principal.
			// On commence par enlever le listener au cas où la méthode soit appelée deux fois sur la même table.
			scrollPane.removeMouseWheelListener(DELEGATE_TO_PARENT_MOUSE_WHEEL_LISTENER);
			scrollPane.addMouseWheelListener(DELEGATE_TO_PARENT_MOUSE_WHEEL_LISTENER);
		}
	});
}
 
Example 4
Source Project: PacketProxy   Source File: GUIDataAll.java    License: Apache License 2.0 6 votes vote down vote up
private RawTextPane createTextPane(String label_name) throws Exception {
	JPanel panel = new JPanel();
	panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

	JLabel label = new JLabel(label_name);
	label.setAlignmentX(0.5f);

	RawTextPane text = new RawTextPane();
	text.setEditable(false);
	panel.add(label);
	JScrollPane scroll = new JScrollPane(text);
	scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
	scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	panel.add(scroll);
	main_panel.add(panel);
	return text;
}
 
Example 5
private void setScrollBarVisibility(final int visibility) {
    final ScrollableJTextArea pane = getDelegate();
    final JTextArea view = pane.getView();
    view.setLineWrap(false);

    switch (visibility) {
        case TextArea.SCROLLBARS_NONE:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            view.setLineWrap(true);
            break;
        case TextArea.SCROLLBARS_VERTICAL_ONLY:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            view.setLineWrap(true);
            break;
        case TextArea.SCROLLBARS_HORIZONTAL_ONLY:
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
            break;
        default:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            break;
    }
}
 
Example 6
Source Project: TencentKona-8   Source File: LWTextAreaPeer.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public Dimension getMinimumSize(final int rows, final int columns) {
    final Dimension size = super.getMinimumSize(rows, columns);
    synchronized (getDelegateLock()) {
        // JScrollPane insets
        final Insets pi = getDelegate().getInsets();
        size.width += pi.left + pi.right;
        size.height += pi.top + pi.bottom;
        // Take scrollbars into account.
        final int vsbPolicy = getDelegate().getVerticalScrollBarPolicy();
        if (vsbPolicy == ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS) {
            final JScrollBar vbar = getDelegate().getVerticalScrollBar();
            size.width += vbar != null ? vbar.getMinimumSize().width : 0;
        }
        final int hsbPolicy = getDelegate().getHorizontalScrollBarPolicy();
        if (hsbPolicy == ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS) {
            final JScrollBar hbar = getDelegate().getHorizontalScrollBar();
            size.height += hbar != null ? hbar.getMinimumSize().height : 0;
        }
    }
    return size;
}
 
Example 7
Source Project: TencentKona-8   Source File: LWTextAreaPeer.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void setScrollBarVisibility(final int visibility) {
    final ScrollableJTextArea pane = getDelegate();
    final JTextArea view = pane.getView();
    view.setLineWrap(false);

    switch (visibility) {
        case TextArea.SCROLLBARS_NONE:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            view.setLineWrap(true);
            break;
        case TextArea.SCROLLBARS_VERTICAL_ONLY:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            view.setLineWrap(true);
            break;
        case TextArea.SCROLLBARS_HORIZONTAL_ONLY:
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
            break;
        default:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            break;
    }
}
 
Example 8
Source Project: jdk8u60   Source File: LWTextAreaPeer.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public Dimension getMinimumSize(final int rows, final int columns) {
    final Dimension size = super.getMinimumSize(rows, columns);
    synchronized (getDelegateLock()) {
        // JScrollPane insets
        final Insets pi = getDelegate().getInsets();
        size.width += pi.left + pi.right;
        size.height += pi.top + pi.bottom;
        // Take scrollbars into account.
        final int vsbPolicy = getDelegate().getVerticalScrollBarPolicy();
        if (vsbPolicy == ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS) {
            final JScrollBar vbar = getDelegate().getVerticalScrollBar();
            size.width += vbar != null ? vbar.getMinimumSize().width : 0;
        }
        final int hsbPolicy = getDelegate().getHorizontalScrollBarPolicy();
        if (hsbPolicy == ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS) {
            final JScrollBar hbar = getDelegate().getHorizontalScrollBar();
            size.height += hbar != null ? hbar.getMinimumSize().height : 0;
        }
    }
    return size;
}
 
Example 9
Source Project: jdk8u60   Source File: LWTextAreaPeer.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void setScrollBarVisibility(final int visibility) {
    final ScrollableJTextArea pane = getDelegate();
    final JTextArea view = pane.getView();
    view.setLineWrap(false);

    switch (visibility) {
        case TextArea.SCROLLBARS_NONE:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            view.setLineWrap(true);
            break;
        case TextArea.SCROLLBARS_VERTICAL_ONLY:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            view.setLineWrap(true);
            break;
        case TextArea.SCROLLBARS_HORIZONTAL_ONLY:
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
            break;
        default:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            break;
    }
}
 
Example 10
Source Project: DominionSim   Source File: DomGameFrame.java    License: MIT License 6 votes vote down vote up
private JPanel getLogPanel() {
	JPanel theLogPanel = new JPanel();
	theLogPanel.setLayout(new BorderLayout());
	myLogPane = new JTextPane();
	myLogPane.setPreferredSize(new Dimension(400,300));
	editorKit = new HTMLEditorKit();
	gameLog = (HTMLDocument) editorKit.createDefaultDocument();;
	myLogPane.setEditorKit(editorKit);
	myLogPane.setDocument(gameLog);
	myLogScroll = new JScrollPane(myLogPane);
    myLogScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
//	theScrollPane.setPreferredSize(new Dimension(400,400));
	theLogPanel.add(myLogScroll,BorderLayout.CENTER);
    Font font = new Font("Times New Roman", Font.PLAIN, 14);
    String bodyRule = "body { font-family: " + font.getFamily() + "; " +
            "font-size: " + font.getSize() + "pt; }";
    ((HTMLDocument)myLogPane.getDocument()).getStyleSheet().addRule(bodyRule);//	myLogPane.revalidate();
	return theLogPanel;
}
 
Example 11
Source Project: SproutLife   Source File: StatsPanel.java    License: MIT License 6 votes vote down vote up
/**
 * Create the panel.
 */
public void buildPanel() {

    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] {10, 100, 10};
    gridBagLayout.rowHeights = new int[]{20, 0, 0};
    gridBagLayout.columnWeights = new double[]{0.0, 1.0, 0.0};
    gridBagLayout.rowWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
    setLayout(gridBagLayout);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    GridBagConstraints gbc_scrollPane = new GridBagConstraints();
    gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
    gbc_scrollPane.fill = GridBagConstraints.BOTH;
    gbc_scrollPane.gridx = 1;
    gbc_scrollPane.gridy = 1;
    add(scrollPane, gbc_scrollPane);

    statsTextPane = new JTextPane();
    scrollPane.setViewportView(statsTextPane);
    statsTextPane.setText("Start game to see statistics.");

}
 
Example 12
Source Project: openjdk-jdk8u   Source File: LWTextAreaPeer.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void setScrollBarVisibility(final int visibility) {
    final ScrollableJTextArea pane = getDelegate();
    final JTextArea view = pane.getView();
    view.setLineWrap(false);

    switch (visibility) {
        case TextArea.SCROLLBARS_NONE:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            view.setLineWrap(true);
            break;
        case TextArea.SCROLLBARS_VERTICAL_ONLY:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            view.setLineWrap(true);
            break;
        case TextArea.SCROLLBARS_HORIZONTAL_ONLY:
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
            break;
        default:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            break;
    }
}
 
Example 13
Source Project: pcgen   Source File: JDynamicTable.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected void unconfigureEnclosingScrollPane()
{
	super.unconfigureEnclosingScrollPane();
	Container p = getParent();
	if (p instanceof JViewport)
	{
		Container gp = p.getParent();
		if (gp instanceof JScrollPane)
		{
			JScrollPane scrollPane = (JScrollPane) gp;
			// Make certain we are the viewPort's view and not, for
			// example, the rowHeaderView of the scrollPane -
			// an implementor of fixed columns might do this.
			JViewport viewport = scrollPane.getViewport();
			if (viewport == null || viewport.getView() != this)
			{
				return;
			}
			scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, null);
		}
	}
}
 
Example 14
Source Project: SmartIM   Source File: ChatInputPane.java    License: Apache License 2.0 6 votes vote down vote up
public ChatInputPane() {
    setLayout(new BorderLayout(0, 0));

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    add(scrollPane, BorderLayout.CENTER);

    textPane = new JTextPane();
    scrollPane.setViewportView(textPane);

    JPanel panel_1 = new JPanel();
    add(panel_1, BorderLayout.EAST);

    btnSend = new JButton("Send");
    panel_1.add(btnSend);
}
 
Example 15
Source Project: Shuffle-Move   Source File: EditTeamService.java    License: GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("serial")
private Component makeRosterPanel() {
   rosterPanel = new JPanel(new WrapLayout()) {
      // Fix to make it play nice with the scroll bar.
      @Override
      public Dimension getPreferredSize() {
         Dimension d = super.getPreferredSize();
         d.width = (int) (d.getWidth() - 20);
         return d;
      }
   };
   rosterScrollPane = new JScrollPane(rosterPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
         ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
   rosterScrollPane.addComponentListener(new ComponentAdapter() {
      @Override
      public void componentResized(ComponentEvent e) {
         rosterScrollPane.revalidate();
      }
   });
   rosterScrollPane.getVerticalScrollBar().setUnitIncrement(27);
   return rosterScrollPane;
}
 
Example 16
Source Project: openjdk-jdk9   Source File: LWTextAreaPeer.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public Dimension getMinimumSize(final int rows, final int columns) {
    final Dimension size = super.getMinimumSize(rows, columns);
    synchronized (getDelegateLock()) {
        // JScrollPane insets
        final Insets pi = getDelegate().getInsets();
        size.width += pi.left + pi.right;
        size.height += pi.top + pi.bottom;
        // Take scrollbars into account.
        final int vsbPolicy = getDelegate().getVerticalScrollBarPolicy();
        if (vsbPolicy == ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS) {
            final JScrollBar vbar = getDelegate().getVerticalScrollBar();
            size.width += vbar != null ? vbar.getMinimumSize().width : 0;
        }
        final int hsbPolicy = getDelegate().getHorizontalScrollBarPolicy();
        if (hsbPolicy == ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS) {
            final JScrollBar hbar = getDelegate().getHorizontalScrollBar();
            size.height += hbar != null ? hbar.getMinimumSize().height : 0;
        }
    }
    return size;
}
 
Example 17
Source Project: openjdk-jdk9   Source File: LWTextAreaPeer.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void setScrollBarVisibility(final int visibility) {
    final ScrollableJTextArea pane = getDelegate();
    final JTextArea view = pane.getView();
    view.setLineWrap(false);

    switch (visibility) {
        case TextArea.SCROLLBARS_NONE:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            view.setLineWrap(true);
            break;
        case TextArea.SCROLLBARS_VERTICAL_ONLY:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            view.setLineWrap(true);
            break;
        case TextArea.SCROLLBARS_HORIZONTAL_ONLY:
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
            break;
        default:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            break;
    }
}
 
Example 18
Source Project: pcgen   Source File: JTreeViewTable.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected void unconfigureEnclosingScrollPane()
{
	super.unconfigureEnclosingScrollPane();
	Container p = getParent();
	if (p instanceof JViewport)
	{
		Container gp = p.getParent();
		if (gp instanceof JScrollPane)
		{
			JScrollPane scrollPane = (JScrollPane) gp;
			// Make certain we are the viewPort's view and not, for
			// example, the rowHeaderView of the scrollPane -
			// an implementor of fixed columns might do this.
			JViewport viewport = scrollPane.getViewport();
			if (viewport == null || viewport.getView() != this)
			{
				return;
			}
			scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, null);
		}
	}
}
 
Example 19
@SuppressWarnings("serial")
private Component makeCenterPanel() {
   rosterEntryPanel = new JPanel(new WrapLayout()) {
      // Fix to make it play nice with the scroll bar.
      @Override
      public Dimension getPreferredSize() {
         Dimension d = super.getPreferredSize();
         d.width = (int) (d.getWidth() - 20);
         return d;
      }
   };
   final JScrollPane ret = new JScrollPane(rosterEntryPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
         ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
   ret.addComponentListener(new ComponentAdapter() {
      @Override
      public void componentResized(ComponentEvent e) {
         ret.revalidate();
      }
   });
   ret.getVerticalScrollBar().setUnitIncrement(27);
   return ret;
}
 
Example 20
Source Project: ET_Redux   Source File: AbstractRatiosDataView.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *
 */
protected void initializeMatrixTabs() {
    matrixTabs.removeAll();

    correlationMatrixViewScrollPane = new JScrollPane(correlationVarUnctMatrixView);
    correlationMatrixViewScrollPane.setBorder(null);
    correlationMatrixViewScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    correlationMatrixViewScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

    matrixTabs.add("Correlations", correlationMatrixViewScrollPane);

    covarianceMatrixViewScrollPane = new JScrollPane(covarianceVarUnctMatrixView);
    covarianceMatrixViewScrollPane.setBorder(null);
    covarianceMatrixViewScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    covarianceMatrixViewScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

    matrixTabs.add("Covariances", covarianceMatrixViewScrollPane);

    updateModelView();
}
 
Example 21
Source Project: pcgen   Source File: EquipmentModels.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
private static JScrollPane prepareScrollPane(JTable table)
{
	JScrollPane pane = new JScrollPane(table);
	Dimension size = table.getPreferredSize();
	size.height += 30; // account for the header which has not been prepared yet
	final int decorationHeight = 80;
	final int decorationWidth = 70;
	Rectangle screenBounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
	if (size.height > screenBounds.height - decorationHeight)
	{
		size.height = screenBounds.height - decorationHeight;
	}
	if (size.width > screenBounds.width - decorationWidth)
	{
		size.width = screenBounds.width - decorationWidth;
	}
	pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
	pane.setPreferredSize(size);
	return pane;
}
 
Example 22
Source Project: pcgen   Source File: JTreeViewTable.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected void unconfigureEnclosingScrollPane()
{
	super.unconfigureEnclosingScrollPane();
	Container p = getParent();
	if (p instanceof JViewport)
	{
		Container gp = p.getParent();
		if (gp instanceof JScrollPane)
		{
			JScrollPane scrollPane = (JScrollPane) gp;
			// Make certain we are the viewPort's view and not, for
			// example, the rowHeaderView of the scrollPane -
			// an implementor of fixed columns might do this.
			JViewport viewport = scrollPane.getViewport();
			if (viewport == null || viewport.getView() != this)
			{
				return;
			}
			scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, null);
		}
	}
}
 
Example 23
private Component makeCenterPanel() {
   speciesSelectPanel = new JPanel(new WrapLayout()) {
      private static final long serialVersionUID = 5094314715314389100L;
      
      // Fix to make it play nice with the scroll bar.
      @Override
      public Dimension getPreferredSize() {
         Dimension d = super.getPreferredSize();
         d.width = (int) (d.getWidth() - 20);
         return d;
      }
   };
   final JScrollPane ret = new JScrollPane(speciesSelectPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
         ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
   ret.addComponentListener(new ComponentAdapter() {
      @Override
      public void componentResized(ComponentEvent e) {
         ret.revalidate();
      }
   });
   ret.getVerticalScrollBar().setUnitIncrement(27);
   return ret;
}
 
Example 24
@Override
public Dimension getMinimumSize(final int rows, final int columns) {
    final Dimension size = super.getMinimumSize(rows, columns);
    synchronized (getDelegateLock()) {
        // JScrollPane insets
        final Insets pi = getDelegate().getInsets();
        size.width += pi.left + pi.right;
        size.height += pi.top + pi.bottom;
        // Take scrollbars into account.
        final int vsbPolicy = getDelegate().getVerticalScrollBarPolicy();
        if (vsbPolicy == ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS) {
            final JScrollBar vbar = getDelegate().getVerticalScrollBar();
            size.width += vbar != null ? vbar.getMinimumSize().width : 0;
        }
        final int hsbPolicy = getDelegate().getHorizontalScrollBarPolicy();
        if (hsbPolicy == ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS) {
            final JScrollBar hbar = getDelegate().getHorizontalScrollBar();
            size.height += hbar != null ? hbar.getMinimumSize().height : 0;
        }
    }
    return size;
}
 
Example 25
private void setScrollBarVisibility(final int visibility) {
    final ScrollableJTextArea pane = getDelegate();
    final JTextArea view = pane.getView();
    view.setLineWrap(false);

    switch (visibility) {
        case TextArea.SCROLLBARS_NONE:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            view.setLineWrap(true);
            break;
        case TextArea.SCROLLBARS_VERTICAL_ONLY:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            view.setLineWrap(true);
            break;
        case TextArea.SCROLLBARS_HORIZONTAL_ONLY:
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
            break;
        default:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            break;
    }
}
 
Example 26
Source Project: lucene-solr   Source File: AboutDialogFactory.java    License: Apache License 2.0 6 votes vote down vote up
private JScrollPane center() {
  JEditorPane editorPane = new JEditorPane();
  editorPane.setOpaque(false);
  editorPane.setMargin(new Insets(0, 5, 2, 5));
  editorPane.setContentType("text/html");
  editorPane.setText(LICENSE_NOTICE);
  editorPane.setEditable(false);
  editorPane.addHyperlinkListener(hyperlinkListener);
  JScrollPane scrollPane = new JScrollPane(editorPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  scrollPane.setBorder(BorderFactory.createLineBorder(Color.gray));
  SwingUtilities.invokeLater(() -> {
    // Set the scroll bar position to top
    scrollPane.getVerticalScrollBar().setValue(0);
  });
  return scrollPane;
}
 
Example 27
Source Project: openjdk-8   Source File: LWTextAreaPeer.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void setScrollBarVisibility(final int visibility) {
    final ScrollableJTextArea pane = getDelegate();
    final JTextArea view = pane.getView();
    view.setLineWrap(false);

    switch (visibility) {
        case TextArea.SCROLLBARS_NONE:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            view.setLineWrap(true);
            break;
        case TextArea.SCROLLBARS_VERTICAL_ONLY:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            view.setLineWrap(true);
            break;
        case TextArea.SCROLLBARS_HORIZONTAL_ONLY:
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
            break;
        default:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            break;
    }
}
 
Example 28
Source Project: jdk8u_jdk   Source File: LWTextAreaPeer.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void setScrollBarVisibility(final int visibility) {
    final ScrollableJTextArea pane = getDelegate();
    final JTextArea view = pane.getView();
    view.setLineWrap(false);

    switch (visibility) {
        case TextArea.SCROLLBARS_NONE:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            view.setLineWrap(true);
            break;
        case TextArea.SCROLLBARS_VERTICAL_ONLY:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            view.setLineWrap(true);
            break;
        case TextArea.SCROLLBARS_HORIZONTAL_ONLY:
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
            break;
        default:
            pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
            pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            break;
    }
}
 
Example 29
Source Project: megamek   Source File: SkinEditorMainGUI.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Pops up a dialog box showing an alert
 */
public void doAlertDialog(String title, String message) {
    JTextPane textArea = new JTextPane();
    ReportDisplay.setupStylesheet(textArea);

    textArea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textArea,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    textArea.setText("<pre>" + message + "</pre>");
    scrollPane.setPreferredSize(new Dimension(
            (int) (getSize().getWidth() / 1.5), (int) (getSize()
                    .getHeight() / 1.5)));
    JOptionPane.showMessageDialog(frame, scrollPane, title,
            JOptionPane.ERROR_MESSAGE);
}
 
Example 30
Source Project: CQL   Source File: SqlLoader.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
private static void doHelp() {
	JTextArea jta = new JTextArea(help);
	jta.setWrapStyleWord(true);
	jta.setLineWrap(true);
	JScrollPane p = new JScrollPane(jta, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
			ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
	p.setPreferredSize(new Dimension(300, 200));

	JOptionPane pane = new JOptionPane(p);
	JDialog dialog = pane.createDialog(null, "Help on SQL Loader");
	dialog.setModal(false);
	dialog.setVisible(true);
	dialog.setResizable(true);
}