Java Code Examples for javax.swing.ScrollPaneConstants#VERTICAL_SCROLLBAR_ALWAYS
The following examples show how to use
javax.swing.ScrollPaneConstants#VERTICAL_SCROLLBAR_ALWAYS .
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: ClientGui.java From logging-log4j2 with Apache License 2.0 | 6 votes |
private JScrollPane scroll(final JTextArea text) { final JToggleButton toggleButton = new JToggleButton(); toggleButton.setAction(new AbstractAction() { private static final long serialVersionUID = -4214143754637722322L; @Override public void actionPerformed(final ActionEvent e) { final boolean wrap = toggleButton.isSelected(); text.setLineWrap(wrap); } }); toggleButton.setToolTipText("Toggle line wrapping"); final JScrollPane scrollStatusLog = new JScrollPane(text, // ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, // ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); scrollStatusLog.setCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER, toggleButton); return scrollStatusLog; }
Example 2
Source File: LWTextAreaPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@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 3
Source File: TerminalPanel.java From beast-mcmc with GNU Lesser General Public License v2.1 | 6 votes |
public TerminalPanel() { // Setup miscallenous setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); // Setup text area textArea = new JTextArea(); textArea.setEditable(true); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); JScrollPane scrollPane = new JScrollPane(textArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); add(scrollPane, BorderLayout.CENTER); }
Example 4
Source File: EditTeamService.java From Shuffle-Move with GNU General Public License v3.0 | 6 votes |
@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 5
Source File: LWTextAreaPeer.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@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 6
Source File: LWTextAreaPeer.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@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: LWTextAreaPeer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@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 8
Source File: LWTextAreaPeer.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@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 File: LWTextAreaPeer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@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 10
Source File: LWTextAreaPeer.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@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 11
Source File: LWTextAreaPeer.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@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 12
Source File: ThemeReaderCrashTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 13
Source File: DataPanel.java From DiskBrowser with GNU General Public License v3.0 | 5 votes |
private JScrollPane setPanel (JTextArea outputPanel, String tabName) // ---------------------------------------------------------------------------------// { outputPanel.setEditable (false); outputPanel.setMargin (new Insets (5, 5, 5, 5)); JScrollPane outputScrollPane = new JScrollPane (outputPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); outputScrollPane.setBorder (null); // remove the ugly default border add (outputScrollPane, tabName); return outputScrollPane; }
Example 14
Source File: AboutWindow.java From wpcleaner with Apache License 2.0 | 5 votes |
/** * Create a JScrollPane. * * @param component Component inside the JScrollPane. * @return JScrollPane. */ private JScrollPane createScrollPane(JComponent component) { JScrollPane scrollPane = new JScrollPane( component, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setPreferredSize(new Dimension(500, 400)); return scrollPane; }
Example 15
Source File: DefaultModulesPanel.java From opt4j with MIT License | 5 votes |
@Override public void startup() { tree = new MyTree(root); tree.setToggleClickCount(1000); // don't expand on double click hack tree.addMouseListener(mouseListener); tree.setCellRenderer(new TreeCellRenderer()); tree.setSelectionModel(null); ToolTipManager.sharedInstance().registerComponent(tree); JScrollPane scroll = new JScrollPane(tree, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); setLayout(new BorderLayout()); add(scroll, BorderLayout.CENTER); Thread thread = new Thread() { @Override public void run() { try { populateTree(); } catch (RejectedExecutionException e) { } } }; thread.setPriority(Thread.MIN_PRIORITY); thread.start(); }
Example 16
Source File: DThrowableDetail.java From portecle with GNU General Public License v2.0 | 4 votes |
/** * Initialize the dialog's GUI components. */ private void initComponents() { // Buttons JPanel jpButtons = new JPanel(new FlowLayout(FlowLayout.CENTER)); JButton jbOK = getOkButton(true); jpButtons.add(jbOK); JButton jbCopy = new JButton(RB.getString("DThrowableDetail.jbCopy.text")); jbCopy.setMnemonic(RB.getString("DThrowableDetail.jbCopy.mnemonic").charAt(0)); jbCopy.setToolTipText(RB.getString("DThrowableDetail.jbCopy.tooltip")); jbCopy.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { copyPressed(); } }); jpButtons.add(jbCopy); JPanel jpThrowable = new JPanel(new BorderLayout()); jpThrowable.setBorder(new EmptyBorder(5, 5, 5, 5)); // Load tree with info on throwable's stack trace JTree jtrThrowable = new JTree(createThrowableNodes()); // Top accommodate node icons with spare space (they are 16 pixels tall) jtrThrowable.setRowHeight(18); jtrThrowable.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); // Allow tool tips in tree ToolTipManager.sharedInstance().registerComponent(jtrThrowable); // Custom tree node renderer jtrThrowable.setCellRenderer(new ThrowableTreeCellRend()); // Expand all nodes in tree /* * ...then again, not. Too much scary detail. TreeNode topNode = (TreeNode)jtrThrowable.getModel().getRoot(); * expandTree(jtrThrowable, new TreePath(topNode)); */ JScrollPane jspThrowable = new JScrollPane(jtrThrowable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); jspThrowable.setPreferredSize(new Dimension(500, 250)); jpThrowable.add(jspThrowable, BorderLayout.CENTER); getContentPane().add(jpThrowable, BorderLayout.CENTER); getContentPane().add(jpButtons, BorderLayout.SOUTH); setTitle(RB.getString("DThrowableDetail.Title")); getRootPane().setDefaultButton(jbOK); initDialog(); setResizable(true); jbOK.requestFocusInWindow(); }
Example 17
Source File: DViewPEM.java From portecle with GNU General Public License v2.0 | 4 votes |
/** * Initialize the dialog's GUI components. * * @throws CryptoException A problem was encountered getting the object's PEM encoding */ private void initComponents() throws CryptoException { if (m_pem == null) { StringWriter encoded = new StringWriter(); try (JcaPEMWriter pw = new JcaPEMWriter(encoded)) { pw.writeObject(m_object); } catch (IOException e) { throw new CryptoException(RB.getString("DViewPEM.exception.message"), e); } m_pem = encoded.toString(); } JPanel jpButtons = new JPanel(new FlowLayout(FlowLayout.CENTER)); JButton jbOK = getOkButton(true); final JButton jbSave = new JButton(RB.getString("DViewPEM.jbSave.text")); jbSave.setMnemonic(RB.getString("DViewPEM.jbSave.mnemonic").charAt(0)); if (m_chooser == null || m_pem == null) { jbSave.setEnabled(false); } else { jbSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { savePressed(); } }); } jpButtons.add(jbOK); jpButtons.add(jbSave); JPanel jpPEM = new JPanel(new BorderLayout()); jpPEM.setBorder(new EmptyBorder(5, 5, 5, 5)); // Load text area with the PEM encoding JTextArea jtaPEM = new JTextArea(m_pem); jtaPEM.setCaretPosition(0); jtaPEM.setEditable(false); jtaPEM.setFont(new Font(Font.MONOSPACED, Font.PLAIN, jtaPEM.getFont().getSize())); JScrollPane jspPEM = new JScrollPane(jtaPEM, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); jspPEM.setPreferredSize(new Dimension(500, 300)); jpPEM.add(jspPEM, BorderLayout.CENTER); getContentPane().add(jpPEM, BorderLayout.CENTER); getContentPane().add(jpButtons, BorderLayout.SOUTH); getRootPane().setDefaultButton(jbOK); initDialog(); setResizable(true); jbOK.requestFocusInWindow(); }
Example 18
Source File: ExpressionTab.java From Logisim with GNU General Public License v3.0 | 4 votes |
public ExpressionTab(AnalyzerModel model) { this.model = model; selector = new OutputSelector(model); model.getOutputExpressions().addOutputExpressionsListener(myListener); selector.addItemListener(myListener); clear.addActionListener(myListener); revert.addActionListener(myListener); enter.addActionListener(myListener); field.setLineWrap(true); field.setWrapStyleWord(true); field.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), myListener); field.getDocument().addDocumentListener(myListener); field.setFont(new Font("sans serif", Font.PLAIN, 14)); JPanel buttons = new JPanel(); buttons.add(clear); buttons.add(revert); buttons.add(enter); GridBagLayout gb = new GridBagLayout(); GridBagConstraints gc = new GridBagConstraints(); setLayout(gb); gc.weightx = 1.0; gc.gridx = 0; gc.gridy = GridBagConstraints.RELATIVE; gc.fill = GridBagConstraints.BOTH; JPanel selectorPanel = selector.createPanel(); gb.setConstraints(selectorPanel, gc); add(selectorPanel); gb.setConstraints(prettyView, gc); add(prettyView); gc.insets = new Insets(10, 10, 0, 10); JScrollPane fieldPane = new JScrollPane(field, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); gb.setConstraints(fieldPane, gc); add(fieldPane); gb.setConstraints(buttons, gc); add(buttons); gc.fill = GridBagConstraints.BOTH; gb.setConstraints(error, gc); add(error); myListener.insertUpdate(null); setError(null); }
Example 19
Source File: SelectionPanel.java From Logisim with GNU General Public License v3.0 | 4 votes |
public SelectionPanel(LogFrame window) { super(window); selector = new ComponentSelector(getModel()); addTool = new JButton(); changeBase = new JButton(); moveUp = new JButton(); moveDown = new JButton(); remove = new JButton(); removeAll = new JButton(); clearComponentLog = new JButton(); list = new SelectionList(); list.setSelection(getSelection()); JPanel buttons = new JPanel(new GridLayout(7, 1)); buttons.add(addTool); buttons.add(changeBase); buttons.add(moveUp); buttons.add(moveDown); buttons.add(remove); buttons.add(removeAll); buttons.add(clearComponentLog); addTool.addActionListener(listener); changeBase.addActionListener(listener); moveUp.addActionListener(listener); moveDown.addActionListener(listener); remove.addActionListener(listener); removeAll.addActionListener(listener); clearComponentLog.addActionListener(listener); selector.addMouseListener(listener); selector.addTreeSelectionListener(listener); list.addListSelectionListener(listener); listener.computeEnabled(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); setLayout(gridbag); JScrollPane explorerPane = new JScrollPane(selector, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); JScrollPane listPane = new JScrollPane(list, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1.0; gbc.weighty = 1.0; gridbag.setConstraints(explorerPane, gbc); add(explorerPane); gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.NORTH; gbc.weightx = 0.0; gridbag.setConstraints(buttons, gbc); add(buttons); gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1.0; gridbag.setConstraints(listPane, gbc); add(listPane); }
Example 20
Source File: TracerDataCompareView.java From pega-tracerviewer with Apache License 2.0 | 3 votes |
private JScrollPane getJScrollPane(TraceTable traceTable) { JScrollPane jscrollpane = new JScrollPane(traceTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); traceTable.setPreferredScrollableViewportSize(jscrollpane.getPreferredSize()); return jscrollpane; }