javax.swing.ScrollPaneConstants Java Examples

The following examples show how to use javax.swing.ScrollPaneConstants. 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 File: LWTextAreaPeer.java    From openjdk-jdk9 with 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 #2
Source File: BasicFindPanel.java    From constellation with 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 File: LWTextAreaPeer.java    From TencentKona-8 with 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 #4
Source File: LWTextAreaPeer.java    From TencentKona-8 with 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 #5
Source File: LWTextAreaPeer.java    From dragonwell8_jdk with 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 #6
Source File: LWTextAreaPeer.java    From jdk8u60 with 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 File: GUIDataAll.java    From PacketProxy with 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 #8
Source File: Utilities.java    From javamelody with 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 #9
Source File: LWTextAreaPeer.java    From jdk8u60 with 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 File: DomGameFrame.java    From DominionSim with 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 File: StatsPanel.java    From SproutLife with 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 File: LWTextAreaPeer.java    From openjdk-jdk8u with 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 File: JDynamicTable.java    From pcgen with 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 File: ChatInputPane.java    From SmartIM with 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 File: EditTeamService.java    From Shuffle-Move with 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 File: NoteInfoPane.java    From pcgen with 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 #17
Source File: LWTextAreaPeer.java    From openjdk-jdk9 with 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 File: JTreeViewTable.java    From pcgen with 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
Source File: EditRosterService.java    From Shuffle-Move with GNU General Public License v3.0 6 votes vote down vote up
@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 File: AbstractRatiosDataView.java    From ET_Redux with 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 File: EquipmentModels.java    From pcgen with 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 File: JTreeViewTable.java    From pcgen with 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
Source File: EditSpeciesService.java    From Shuffle-Move with GNU General Public License v3.0 6 votes vote down vote up
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
Source File: LWTextAreaPeer.java    From openjdk-8-source with 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 #25
Source File: LWTextAreaPeer.java    From openjdk-8-source with 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 #26
Source File: AboutDialogFactory.java    From lucene-solr with 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 File: LWTextAreaPeer.java    From openjdk-8 with 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 File: LWTextAreaPeer.java    From jdk8u_jdk with 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 File: ThemeReaderCrashTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
ThemeReaderCrashTest() {
    JPanel panel = new JPanel();
    JScrollPane pane =
        new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    panel.setSize(300, 200);

    panel.add(pane);
}
 
Example #30
Source File: SkinEditorMainGUI.java    From megamek with 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);
}