1 76 77 78 package swingwtx.swing; 79 80 import org.eclipse.swt.SWT; 81 import org.eclipse.swt.widgets.Composite; 82 83 public class JPanel extends JComponent { 84 85 86 protected Composite ppeer = null; 87 protected boolean opaque = true; 88 89 90 public JPanel() {this(false);} 91 94 public JPanel(boolean isDoubleBuffered) { this(new swingwt.awt.FlowLayout(), false); } 95 98 public JPanel(swingwt.awt.LayoutManager layout) { setLayout(layout); } 99 103 public JPanel(swingwt.awt.LayoutManager layout, boolean isDoubleBuffered) { setLayout(layout); } 104 107 public JPanel(swingwt.awt.LayoutManager2 layout) { setLayout(layout); } 108 112 public JPanel(swingwt.awt.LayoutManager2 layout, boolean isDoubleBuffered) { setLayout(layout); } 113 116 protected swingwt.awt.Dimension calculatePreferredSize() { 117 swingwt.awt.Dimension size = new swingwt.awt.Dimension(300, 200); 119 setSize(size); 120 return size; 121 } 122 123 126 public void setSwingWTParent(swingwt.awt.Container parent) throws Exception { 127 descendantHasPeer = true; 128 ppeer = new Composite(parent.getComposite(), SWT.NONE); 129 peer = ppeer; 130 composite = ppeer; 131 this.parent = parent; 132 super.setSwingWTParent(parent); 133 } 134 135 138 public void setBorder(swingwtx.swing.border.Border b) { 139 border = b; 140 } 141 142 149 public swingwt.awt.Dimension getSize() { 150 if (parent instanceof JScrollPane) 151 return getPreferredSize(); 152 else 153 return super.getSize(); 154 } 155 158 public int getWidth() { return getSize().width; } 159 162 public int getHeight() { return getSize().height; } 163 164 } 165 | Popular Tags |