List of utility methods to do JScrollPane
JScrollPane | findScrollPane(Component component) find Scroll Pane if (component instanceof JScrollPane) return (JScrollPane) component; if (component instanceof Container) { Container c = (Container) component; for (int i = 0; i < c.getComponentCount(); i++) { JScrollPane result = findScrollPane(c.getComponent(i)); if (result != null) return result; ... |
JScrollPane | getContainingScroll(Component comp) Returns the scrolpane where the provided component is contained. JScrollPane scroll = null; Container parent = comp.getParent(); while (scroll == null && parent != null) { if (parent instanceof JScrollPane) { scroll = (JScrollPane) parent; } else { parent = parent.getParent(); return scroll; |
JScrollPane | getMessageScrollPane(String message) get Message Scroll Pane JTextArea ta = new JTextArea(message); ta.setBorder(new EmptyBorder(0, 0, 0, 0)); ta.setLineWrap(true); ta.setWrapStyleWord(true); ta.setCaretPosition(0); ta.setEditable(false); JScrollPane sp = new JScrollPane(ta); sp.setBorder(new EmptyBorder(5, 5, 5, 5)); ... |
JFrame | getNoScrollPaletteWindow(Component gui, String windowName, ComponentListener cl) Get a layer's associated palette as a top-level window JPanel pane = new JPanel(); pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); pane.setAlignmentX(Component.CENTER_ALIGNMENT); pane.setAlignmentY(Component.BOTTOM_ALIGNMENT); pane.add(gui); JFrame paletteWindow = new JFrame(windowName); paletteWindow.addComponentListener(cl); paletteWindow.getContentPane().add(pane); ... |
JScrollPane | getScrollableMessage(String msg) get Scrollable Message JTextArea textArea = new JTextArea(msg); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.setEditable(false); textArea.setMargin(new Insets(5, 5, 5, 5)); textArea.setFont(new JTextField().getFont()); JScrollPane scrollPane = new JScrollPane(); scrollPane.setPreferredSize(new Dimension(700, 150)); ... |
int | getScrollBarWidth(BasicComboPopup popup, JScrollPane scrollPane) get Scroll Bar Width return 0;
|
Rectangle | getScrollPaneViewportSize(JScrollPane panel) get Scroll Pane Viewport Size Rectangle viewRect = panel.getViewportBorderBounds(); JScrollBar vbar = panel.getVerticalScrollBar(); if (vbar.isVisible()) { viewRect.width = viewRect.width + vbar.getWidth(); JScrollBar hbar = panel.getHorizontalScrollBar(); if (hbar.isVisible()) { viewRect.height = viewRect.height + hbar.getHeight(); ... |
boolean | hasParentScrollPane(JComponent component) has Parent Scroll Pane return component.getParent() != null && component.getParent() instanceof JViewport && component.getParent().getParent() instanceof JScrollPane; |
GridBagConstraints | initScrollPane(JScrollPane scrollPane) init Scroll Pane scrollPane.setLayout(new ScrollPaneLayout()); scrollPane.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); GridBagConstraints gb = new GridBagConstraints(); gb.gridx = 0; gb.gridy = 0; gb.insets = new Insets(2, 2, 2, 2); return gb; |
boolean | isHorizontalScrollBarHiddenAlways(JScrollPane pane) is Horizontal Scroll Bar Hidden Always return (pane != null) && (pane.getHorizontalScrollBarPolicy() == JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|