Here you can find the source of getParentPanel(JComponent jc)
Parameter | Description |
---|---|
jc | a parameter |
public static Container getParentPanel(JComponent jc)
//package com.java2s; //License from project: Apache License import javax.swing.*; import java.awt.*; public class Main { /**/*from w w w . j a v a2 s .c o m*/ * go to parent that is not a scroll pane * @param jc * @return */ public static Container getParentPanel(JComponent jc) { Container parent = jc.getParent(); while (parent != null) { if (parent instanceof JPanel) return parent; if (parent instanceof JFrame) return parent; if (parent instanceof JDialog) return parent; if (parent instanceof JRootPane) return parent; parent = parent.getParent(); } return null; } }