Java Code Examples for javax.swing.JScrollPane#getViewport()
The following examples show how to use
javax.swing.JScrollPane#getViewport() .
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: JTreeViewTable.java From pcgen with GNU Lesser General Public License v2.1 | 7 votes |
@Override protected void configureEnclosingScrollPane() { super.configureEnclosingScrollPane(); 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.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, wrappedCornerButton); } } }
Example 2
Source File: JViewPortBackingStoreImageTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private static JComponent createComponent() { createStyles(); for (int i = 0; i < data.length; i++) { Paragraph p = data[i]; addParagraph(p); } JTextPane textPane = new JTextPane(doc); JScrollPane scroller = new JScrollPane(); JViewport port = scroller.getViewport(); port.setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE); port.add(textPane); return scroller; }
Example 3
Source File: JDynamicTable.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void configureEnclosingScrollPane() { super.configureEnclosingScrollPane(); 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.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.setCorner( ScrollPaneConstants.UPPER_TRAILING_CORNER, wrappedCornerButton); } } }
Example 4
Source File: HttpFuzzerErrorsTable.java From zap-extensions with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} * * <p>Overridden to take into account for possible parent {@code JLayer}s. * * @see javax.swing.JLayer */ // Note: Same implementation as in JXTable#getEnclosingScrollPane() but changed to get the // parent and viewport view using // the methods SwingUtilities#getUnwrappedParent(Component) and // SwingUtilities#getUnwrappedView(JViewport) respectively. @Override protected JScrollPane getEnclosingScrollPane() { Container p = SwingUtilities.getUnwrappedParent(this); 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 || SwingUtilities.getUnwrappedView(viewport) != this) { return null; } return scrollPane; } } return null; }
Example 5
Source File: JTreeViewTable.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
@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 6
Source File: JTreeViewTable.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void configureEnclosingScrollPane() { super.configureEnclosingScrollPane(); 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.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, wrappedCornerButton); } } }
Example 7
Source File: JDynamicTable.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
@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 8
Source File: JDynamicTable.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void configureEnclosingScrollPane() { super.configureEnclosingScrollPane(); 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.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.setCorner( ScrollPaneConstants.UPPER_TRAILING_CORNER, wrappedCornerButton); } } }
Example 9
Source File: SheetDockable.java From gcs with Mozilla Public License 2.0 | 6 votes |
/** Creates a new {@link SheetDockable}. */ public SheetDockable(GURPSCharacter character) { super(character); GURPSCharacter dataFile = getDataFile(); mSheet = new CharacterSheet(dataFile); createToolbar(); JScrollPane scroller = new JScrollPane(mSheet); scroller.setBorder(null); JViewport viewport = scroller.getViewport(); viewport.setBackground(Color.LIGHT_GRAY); viewport.addChangeListener(mSheet); add(scroller, BorderLayout.CENTER); mSheet.rebuild(); mSheet.getCharacter().processFeaturesAndPrereqs(); dataFile.setModified(false); StdUndoManager undoManager = getUndoManager(); undoManager.discardAllEdits(); dataFile.setUndoManager(undoManager); dataFile.addTarget(this, Profile.ID_BODY_TYPE); }
Example 10
Source File: JViewPortBackingStoreImageTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static JComponent createComponent() { createStyles(); for (int i = 0; i < data.length; i++) { Paragraph p = data[i]; addParagraph(p); } JTextPane textPane = new JTextPane(doc); JScrollPane scroller = new JScrollPane(); JViewport port = scroller.getViewport(); port.setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE); port.add(textPane); return scroller; }
Example 11
Source File: ZoomManager.java From netbeans with Apache License 2.0 | 6 votes |
public void actionPerformed(ActionEvent e) { Scene scene = manager.getScene(); JScrollPane pane = (JScrollPane) SwingUtilities.getAncestorOfClass( JScrollPane.class, scene.getView()); if (pane == null) { // Unlikely, but we cannot assume it exists. return; } JViewport viewport = pane.getViewport(); Rectangle visRect = viewport.getViewRect(); Rectangle compRect = scene.getPreferredBounds(); int zoomX = visRect.width * 100 / compRect.width; int zoomY = visRect.height * 100 / compRect.height; int zoom = Math.min(zoomX, zoomY); manager.setZoom(zoom); }
Example 12
Source File: ETable.java From netbeans with Apache License 2.0 | 6 votes |
/** * This method update mouse listener on the scrollPane if it is needed. * It also recomputes the model of searchCombo. Both actions are needed after * the set of visible columns is changed. */ void updateColumnSelectionMouseListener() { 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.removeMouseListener(columnSelectionMouseListener); if (getColumnModel().getColumnCount() == 0) { scrollPane.addMouseListener(columnSelectionMouseListener); } } } if (searchCombo != null) { searchCombo.setModel(getSearchComboModel()); } }
Example 13
Source File: JDynamicTable.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
@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: PSheet.java From netbeans with Apache License 2.0 | 5 votes |
private JScrollPane createScrollPane(Component inner) { JScrollPane result = new JScrollPane(inner); JViewport vp = result.getViewport(); vp.addMouseListener(this); MarginViewportUI ui = (MarginViewportUI) MarginViewportUI.createUI(vp); vp.setUI(ui); ui.setMarginPainted(marginPainted); ui.setMarginColor(marginColor); ui.setEmptyString(emptyString); result.setBorder(BorderFactory.createEmptyBorder()); result.setViewportBorder(result.getBorder()); return result; }
Example 15
Source File: ZoomManager.java From netbeans with Apache License 2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { Scene scene = manager.getScene(); JScrollPane pane = (JScrollPane) SwingUtilities.getAncestorOfClass( JScrollPane.class, scene.getView()); if (pane == null) { // Unlikely, but we cannot assume it exists. return; } JViewport viewport = pane.getViewport(); Rectangle visRect = viewport.getViewRect(); Rectangle compRect = scene.getPreferredBounds(); int zoom = visRect.width * 100 / compRect.width; manager.setZoom(zoom); }
Example 16
Source File: FontBoxRenderer.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
private void manItemInCombo() { if (comboBox.getItemCount() > 0) { final Object comp = comboBox.getUI().getAccessibleChild(comboBox, 0); if ((comp instanceof JPopupMenu)) { final JList list = new JList(comboBox.getModel()); final JPopupMenu popup = (JPopupMenu) comp; final JScrollPane scrollPane = (JScrollPane) popup.getComponent(0); final JViewport viewport = scrollPane.getViewport(); final Rectangle rect = popup.getVisibleRect(); final Point pt = viewport.getViewPosition(); row = list.locationToIndex(pt); } } }
Example 17
Source File: DetailsPanel.java From visualvm with GNU General Public License v2.0 | 4 votes |
private void initComponents() { table = new DetailsTable(); table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JViewport viewport = new Viewport(table); final JScrollPane tableScroll = new JScrollPane( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); tableScroll.setViewport(viewport); tableScroll.setBorder(BorderFactory.createEmptyBorder()); tableScroll.setViewportBorder(BorderFactory.createEmptyBorder()); tableScroll.setCorner(JScrollPane.UPPER_RIGHT_CORNER, new HeaderPanel()); scrollBar = new ScrollBar(JScrollBar.VERTICAL) { public int getUnitIncrement(int direction) { JViewport vp = tableScroll.getViewport(); Scrollable view = (Scrollable)(vp.getView()); Rectangle vr = vp.getViewRect(); return view.getScrollableUnitIncrement(vr, getOrientation(), direction); } public int getBlockIncrement(int direction) { JViewport vp = tableScroll.getViewport(); Scrollable view = (Scrollable)(vp.getView()); Rectangle vr = vp.getViewRect(); return view.getScrollableBlockIncrement(vr, getOrientation(), direction); } public void setValues(int newValue, int newExtent, int newMin, int newMax) { setEnabled(newExtent < newMax); if (isEnabled() && !isSelectionChanging() && isTrackingEnd()) newValue = newMax - newExtent; super.setValues(newValue, newExtent, newMin, newMax); } }; tableScroll.setVerticalScrollBar(scrollBar); dataContainer = tableScroll; JLabel noDataLabel = new JLabel("<No probe selected>", JLabel.CENTER); noDataLabel.setEnabled(false); noDataContainer = new JPanel(new BorderLayout()); noDataContainer.setOpaque(false); noDataContainer.add(noDataLabel, BorderLayout.CENTER); setOpaque(false); setLayout(new BorderLayout()); add(noDataContainer, BorderLayout.CENTER); }
Example 18
Source File: DetailsPanel.java From visualvm with GNU General Public License v2.0 | 4 votes |
private void initComponents() { table = new DetailsTable(); table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JViewport viewport = new Viewport(table); final JScrollPane tableScroll = new JScrollPane( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); tableScroll.setViewport(viewport); tableScroll.setBorder(BorderFactory.createEmptyBorder()); tableScroll.setViewportBorder(BorderFactory.createEmptyBorder()); tableScroll.setCorner(JScrollPane.UPPER_RIGHT_CORNER, new HeaderPanel()); scrollBar = new ScrollBar(JScrollBar.VERTICAL) { public int getUnitIncrement(int direction) { JViewport vp = tableScroll.getViewport(); Scrollable view = (Scrollable)(vp.getView()); Rectangle vr = vp.getViewRect(); return view.getScrollableUnitIncrement(vr, getOrientation(), direction); } public int getBlockIncrement(int direction) { JViewport vp = tableScroll.getViewport(); Scrollable view = (Scrollable)(vp.getView()); Rectangle vr = vp.getViewRect(); return view.getScrollableBlockIncrement(vr, getOrientation(), direction); } public void setValues(int newValue, int newExtent, int newMin, int newMax) { setEnabled(newExtent < newMax); if (isEnabled() && !isSelectionChanging() && isTrackingEnd()) newValue = newMax - newExtent; super.setValues(newValue, newExtent, newMin, newMax); } }; tableScroll.setVerticalScrollBar(scrollBar); dataContainer = tableScroll; JLabel noDataLabel = new JLabel("<No probe selected>", JLabel.CENTER); noDataLabel.setEnabled(false); noDataContainer = new JPanel(new BorderLayout()); noDataContainer.setOpaque(false); noDataContainer.add(noDataLabel, BorderLayout.CENTER); setOpaque(false); setLayout(new BorderLayout()); add(noDataContainer, BorderLayout.CENTER); }
Example 19
Source File: GuideWindow.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void init() { guideURL = getClass().getResource(Msg.getString("doc.guide")); //$NON-NLS-1$ homeButton.setToolTipText(Msg.getString("GuideWindow.tooltip.home")); //$NON-NLS-1$ homeButton.setSize(16, 16); homeButton.addActionListener(this); backButton.setToolTipText(Msg.getString("GuideWindow.tooltip.back")); //$NON-NLS-1$ backButton.addActionListener(this); forwardButton.setToolTipText(Msg.getString("GuideWindow.tooltip.forward")); //$NON-NLS-1$ forwardButton.addActionListener(this); // Create the main panel JPanel mainPane = new JPanel(new BorderLayout()); // mainPane.setBorder(new MarsPanelBorder()); setContentPane(mainPane); JPanel topPanel = new JPanel(new BorderLayout()); mainPane.add(topPanel, BorderLayout.NORTH); // A toolbar to hold all our buttons JPanel homePanel = new JPanel(new FlowLayout(3, 3, FlowLayout.CENTER)); topPanel.add(homePanel, BorderLayout.CENTER); homePanel.add(backButton); homePanel.add(homeButton); homePanel.add(forwardButton); JPanel linkPanel = new JPanel(new FlowLayout(3, 3, FlowLayout.TRAILING)); topPanel.add(linkPanel, BorderLayout.EAST); // link = new WebLink(StyleId.linkShadow, new SvgIcon("github19"), WIKI_TEXT, new UrlLinkAction(WIKI_URL)); link = new WebLink(StyleId.linkShadow, new UrlLinkAction(WIKI_URL)); // link = new WebLink(StyleId.linkShadow, WIKI_TEXT, new UrlLinkAction(WIKI_URL)); link.setAlignmentY(1f); link.setText(WIKI_TEXT); // link.setIcon(new SvgIcon("github.svg")); // github19 TooltipManager.setTooltip(link, "Open mars-sim wiki in GitHub", TooltipWay.down); linkPanel.add(link); // Initialize the status bar mainPane.add(initializeStatusBar(), BorderLayout.SOUTH); htmlPane = new HTMLContentPane(); htmlPane.addHyperlinkListener(this); htmlPane.goToURL(guideURL); htmlPane.setContentType("text/html"); htmlPane.setBackground(Color.lightGray); htmlPane.setBorder(new EmptyBorder(2, 2, 2, 2)); JScrollPane scrollPane = new JScrollPane(htmlPane); // scrollPane.setBorder(new MarsPanelBorder()); viewPort = (JViewport) scrollPane.getViewport(); // viewPort.addComponentListener(this); viewPort.setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE); mainPane.add(scrollPane, BorderLayout.CENTER); updateButtons(); setResizable(false); setMaximizable(true); setVisible(true); setSize(new Dimension(800, 600)); // setMinimumSize(new Dimension(320, 320)); // setPreferredSize(new Dimension(800, 600)); // setMaximumSize(new Dimension(1280, 600)); Dimension desktopSize = desktop.getMainWindow().getFrame().getSize(); Dimension windowSize = getSize(); // System.out.println("desktopSize.width : " + desktopSize.width); // System.out.println("desktopSize.height : " + desktopSize.height); int width = (desktopSize.width - windowSize.width) / 2; int height = (desktopSize.height - windowSize.height - 100) / 2; setLocation(width, height); // Pack window. // WARNING: this will shrink the window to one line tall in swing mode // pack(); }
Example 20
Source File: DetailsPanel.java From netbeans with Apache License 2.0 | 4 votes |
private void initComponents() { table = new DetailsTable(); table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JViewport viewport = new Viewport(table); final JScrollPane tableScroll = new JScrollPane( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); tableScroll.setViewport(viewport); tableScroll.setBorder(BorderFactory.createEmptyBorder()); tableScroll.setViewportBorder(BorderFactory.createEmptyBorder()); tableScroll.setCorner(JScrollPane.UPPER_RIGHT_CORNER, new HeaderPanel()); scrollBar = new ScrollBar(JScrollBar.VERTICAL) { public int getUnitIncrement(int direction) { JViewport vp = tableScroll.getViewport(); Scrollable view = (Scrollable)(vp.getView()); Rectangle vr = vp.getViewRect(); return view.getScrollableUnitIncrement(vr, getOrientation(), direction); } public int getBlockIncrement(int direction) { JViewport vp = tableScroll.getViewport(); Scrollable view = (Scrollable)(vp.getView()); Rectangle vr = vp.getViewRect(); return view.getScrollableBlockIncrement(vr, getOrientation(), direction); } public void setValues(int newValue, int newExtent, int newMin, int newMax) { setEnabled(newExtent < newMax); if (isEnabled() && !isSelectionChanging() && isTrackingEnd()) newValue = newMax - newExtent; super.setValues(newValue, newExtent, newMin, newMax); } }; tableScroll.setVerticalScrollBar(scrollBar); dataContainer = tableScroll; JLabel noDataLabel = new JLabel("<No probe selected>", JLabel.CENTER); noDataLabel.setEnabled(false); noDataContainer = new JPanel(new BorderLayout()); noDataContainer.setOpaque(false); noDataContainer.add(noDataLabel, BorderLayout.CENTER); setOpaque(false); setLayout(new BorderLayout()); add(noDataContainer, BorderLayout.CENTER); }