1 7 package javax.swing; 8 9 import java.awt.*; 10 11 import javax.swing.plaf.*; 12 import javax.accessibility.*; 13 14 import java.io.Serializable ; 15 import java.io.ObjectOutputStream ; 16 import java.io.ObjectInputStream ; 17 import java.io.IOException ; 18 19 20 43 public class JPanel extends JComponent implements Accessible 44 { 45 49 private static final String uiClassID = "PanelUI"; 50 51 60 public JPanel(LayoutManager layout, boolean isDoubleBuffered) { 61 setLayout(layout); 62 setDoubleBuffered(isDoubleBuffered); 63 setUIProperty("opaque", Boolean.TRUE); 64 updateUI(); 65 } 66 67 72 public JPanel(LayoutManager layout) { 73 this(layout, true); 74 } 75 76 86 public JPanel(boolean isDoubleBuffered) { 87 this(new FlowLayout(), isDoubleBuffered); 88 } 89 90 94 public JPanel() { 95 this(true); 96 } 97 98 103 public void updateUI() { 104 setUI((PanelUI)UIManager.getUI(this)); 105 } 106 107 113 public PanelUI getUI() { 114 return (PanelUI)ui; 115 } 116 117 118 130 public void setUI(PanelUI ui) { 131 super.setUI(ui); 132 } 133 134 145 public String getUIClassID() { 146 return uiClassID; 147 } 148 149 150 154 private void writeObject(ObjectOutputStream s) throws IOException { 155 s.defaultWriteObject(); 156 if (getUIClassID().equals(uiClassID)) { 157 byte count = JComponent.getWriteObjCounter(this); 158 JComponent.setWriteObjCounter(this, --count); 159 if (count == 0 && ui != null) { 160 ui.installUI(this); 161 } 162 } 163 } 164 165 166 175 protected String paramString() { 176 return super.paramString(); 177 } 178 179 183 192 public AccessibleContext getAccessibleContext() { 193 if (accessibleContext == null) { 194 accessibleContext = new AccessibleJPanel(); 195 } 196 return accessibleContext; 197 } 198 199 214 protected class AccessibleJPanel extends AccessibleJComponent { 215 216 222 public AccessibleRole getAccessibleRole() { 223 return AccessibleRole.PANEL; 224 } 225 } 226 } 227 228 | Popular Tags |