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

The following examples show how to use javax.swing.SwingUtilities#getUnwrappedParent() . These examples are extracted from open source projects. 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
/**
 * {@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
@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 Project: netbeans   File: NbEditorUI.java    License: 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 Project: netbeans   File: NbEditorUI.java    License: 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
@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 Project: netbeans   File: ProfilerTable.java    License: 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
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;
}