1 package org.columba.core.gui.base; 17 18 import java.awt.Component ; 19 import java.awt.LayoutManager ; 20 21 import javax.swing.BorderFactory ; 22 import javax.swing.BoxLayout ; 23 import javax.swing.JPanel ; 24 25 26 27 public class CPanel extends JPanel { 28 static int size = 10; 29 JPanel panel; 30 JPanel innerPanel; 31 32 public CPanel(String title) { 33 super(); 34 setBorder(BorderFactory.createEmptyBorder(size, size, size, size)); 35 36 innerPanel = new JPanel (); 37 innerPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( 38 javax.swing.BorderFactory.createEtchedBorder(), title)); 39 innerPanel.setLayout(new BoxLayout (innerPanel, BoxLayout.Y_AXIS)); 40 41 panel = new JPanel (); 42 panel.setBorder(BorderFactory.createEmptyBorder(size, size, size, size)); 43 panel.setLayout(new BoxLayout (panel, BoxLayout.Y_AXIS)); 44 45 setLayout(new BoxLayout (this, BoxLayout.Y_AXIS)); 46 47 innerPanel.add(panel); 48 49 super.add(innerPanel); 51 } 52 53 public CPanel(String title, boolean b) { 54 super(); 55 setBorder(BorderFactory.createEmptyBorder(size, size, size, size)); 56 57 innerPanel = new JPanel (); 58 innerPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( 59 javax.swing.BorderFactory.createEtchedBorder(), title)); 60 61 if (b == true) { 62 innerPanel.setLayout(new BoxLayout (innerPanel, BoxLayout.Y_AXIS)); 63 } else { 64 innerPanel.setLayout(new BoxLayout (innerPanel, BoxLayout.X_AXIS)); 65 } 66 67 panel = new JPanel (); 68 panel.setBorder(BorderFactory.createEmptyBorder(size, size, size, size)); 69 70 if (b == true) { 71 panel.setLayout(new BoxLayout (panel, BoxLayout.Y_AXIS)); 72 } else { 73 panel.setLayout(new BoxLayout (panel, BoxLayout.X_AXIS)); 74 } 75 76 if (b == true) { 77 setLayout(new BoxLayout (this, BoxLayout.Y_AXIS)); 78 } else { 79 setLayout(new BoxLayout (this, BoxLayout.X_AXIS)); 80 } 81 82 innerPanel.add(panel); 83 84 super.add(innerPanel); 86 } 87 88 public Component add(Component comp) { 89 return panel.add(comp); 90 } 91 92 public Component add(Component comp, int index) { 93 return panel.add(comp, index); 94 } 95 96 public void setInnerLayout(LayoutManager mgr) { 97 panel.setLayout(mgr); 98 } 99 } 100 | Popular Tags |