Example usage for javax.swing SwingUtilities getUnwrappedView

List of usage examples for javax.swing SwingUtilities getUnwrappedView

Introduction

In this page you can find the example usage for javax.swing SwingUtilities getUnwrappedView.

Prototype

public static Component getUnwrappedView(JViewport viewport) 

Source Link

Document

Returns the first JViewport 's descendant which is not an instance of JLayer .

Usage

From source file:pipeline.GUI_utils.ListOfPointsView.java

private static JViewport getTableViewPort(JTable table) {
    Container parent = SwingUtilities.getUnwrappedParent(table);
    if (parent instanceof JViewport) {
        JViewport port = (JViewport) parent;
        Container gp = port.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) != table) {
                return null;
            }//from w ww .  j a  v a 2s .c om
            return viewPort;
        }
    }
    return null;
}