1 19 20 28 29 package org.netbeans.modules.xml.schema.abe; 30 31 import java.awt.Component ; 32 import java.awt.LayoutManager ; 33 import javax.swing.JFrame ; 34 import javax.swing.JPanel ; 35 36 40 public class NBGlassPaneAccessSupport { 41 42 private static JPanel NB_GLASS_PANE = null; 43 private static JPanel glass ; 44 private static LayoutManager previousLayout; 45 private static JFrame NBFRAME; 46 47 private static JPanel _getGlassPane(Component leaf){ 48 if(NB_GLASS_PANE == null){ 49 Component current = leaf; 51 while( (current != null) && !(current instanceof JFrame ) ) 52 current = current.getParent(); 53 if(current == null) 54 return null; 55 NB_GLASS_PANE = (JPanel ) ((JFrame ) current).getGlassPane(); 56 NBFRAME = (JFrame ) current; 57 return NB_GLASS_PANE; 58 }else{ 59 if(NB_GLASS_PANE.getParent() instanceof JFrame ){ 61 return NB_GLASS_PANE; 63 }else{ 64 NB_GLASS_PANE = null; 66 return _getGlassPane(leaf); 67 } 68 } 69 } 70 71 72 public static JPanel getNBGlassPane(Component leaf){ 73 glass = _getGlassPane(leaf); 74 if(glass == null) 75 return null; 76 previousLayout = glass.getLayout(); 77 glass.setLayout(null); 78 return glass; 79 } 80 81 public static JPanel getCleanNBGlassPane(Component leaf){ 82 forceDisposeNBGlassPane(); 83 return getNBGlassPane(leaf); 84 } 85 86 public static void disposeNBGlassPane(){ 87 if(glass == null) 88 return; 89 glass.setVisible(false); 90 for(Component comp: glass.getComponents()){ 91 glass.remove(comp); 92 } 93 glass.setLayout(previousLayout); 94 } 95 96 public static void forceDisposeNBGlassPane(){ 97 JPanel glass = NB_GLASS_PANE; 98 if(glass == null) 99 return; 100 glass.setVisible(false); 101 for(Component comp: glass.getComponents()){ 102 glass.remove(comp); 103 } 104 glass.setLayout(previousLayout); 105 } 106 107 public static JPanel getCurrentShowingPane(){ 108 return glass; 109 } 110 111 public static JFrame getNBFRAME(Component leaf){ 112 if(NBFRAME != null) 113 return NBFRAME; 114 _getGlassPane(leaf); 115 return NBFRAME; 116 } 117 118 } 119 | Popular Tags |