Java Code Examples for javax.swing.SwingUtilities#getUnwrappedParent()

The following examples show how to use javax.swing.SwingUtilities#getUnwrappedParent() . 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: HttpFuzzerErrorsTable.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * {@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 2
Source File: CustomTextPane.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean getScrollableTracksViewportWidth() {
  if (lineWrap)
    return super.getScrollableTracksViewportWidth();
  else {
    Container parent = SwingUtilities.getUnwrappedParent(this);
    return parent == null || getUI().getPreferredSize(this).width <= parent.getSize().width;
  }
}
 
Example 3
Source File: NbEditorUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean getScrollableTracksViewportWidth() {
    Container parent = SwingUtilities.getUnwrappedParent(this);
    if (parent instanceof JViewport) {
        return parent.getWidth() > getPreferredSize().width;
    }
    return false;
}
 
Example 4
Source File: NbEditorUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean getScrollableTracksViewportHeight() {
    Container parent = SwingUtilities.getUnwrappedParent(this);
    if (parent instanceof JViewport) {
        return parent.getHeight() > getPreferredSize().height;
    }
    return false;
}
 
Example 5
Source File: CustomTextPane.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean getScrollableTracksViewportWidth() {
  if (lineWrap)
    return super.getScrollableTracksViewportWidth();
  else {
    Container parent = SwingUtilities.getUnwrappedParent(this);
    return parent == null || getUI().getPreferredSize(this).width <= parent.getSize().width;
  }
}
 
Example 6
Source File: ProfilerTable.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private JScrollPane getEnclosingScrollPane() {
    Container parent = SwingUtilities.getUnwrappedParent(this);
    if (!(parent instanceof JViewport)) return null;
    Container scroll = ((JViewport)parent).getParent();
    return scroll instanceof JScrollPane ? (JScrollPane)scroll : null;
}
 
Example 7
Source File: ProfilerTable.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private JScrollPane getEnclosingScrollPane() {
    Container parent = SwingUtilities.getUnwrappedParent(this);
    if (!(parent instanceof JViewport)) return null;
    Container scroll = ((JViewport)parent).getParent();
    return scroll instanceof JScrollPane ? (JScrollPane)scroll : null;
}