1 package org.columba.addressbook.gui.util; 17 18 import java.awt.Component ; 19 import java.awt.GridBagConstraints ; 20 import java.awt.GridBagLayout ; 21 import java.awt.Insets ; 22 23 import javax.swing.Box ; 24 import javax.swing.JComponent ; 25 import javax.swing.JPanel ; 26 27 public class LabelTextFieldPanel extends JPanel { 28 29 private GridBagLayout layout; 30 31 private int y = 0; 32 33 public LabelTextFieldPanel() { 34 layout = new GridBagLayout (); 35 setLayout(layout); 36 } 37 38 public void addLabel(JComponent label) { 39 GridBagConstraints c = new GridBagConstraints (); 40 41 c.gridx = 0; 42 c.gridy = y; 43 c.weightx = 0.0; 44 c.anchor = GridBagConstraints.WEST; 45 c.fill = GridBagConstraints.HORIZONTAL; 46 c.insets = new Insets (0, 0, 0, 11); 47 layout.setConstraints(label, c); 48 add(label); 49 } 50 51 public void addTextField(JComponent component) { 52 GridBagConstraints c = new GridBagConstraints (); 53 54 c.gridx = 1; 55 c.weightx = 1.0; 56 c.gridy = y; 57 c.fill = GridBagConstraints.HORIZONTAL; 58 c.insets = new Insets (5, 0, 0, 0); 59 c.anchor = GridBagConstraints.EAST; 60 c.gridwidth = GridBagConstraints.REMAINDER; 61 layout.setConstraints(component, c); 62 add(component); 63 64 y += 1; 65 } 66 67 public void addSeparator() { 68 GridBagConstraints c = new GridBagConstraints (); 69 c.gridx = 0; 70 c.weightx = 1.0; 71 c.gridy = y; 72 c.fill = GridBagConstraints.HORIZONTAL; 73 c.insets = new Insets (0, 0, 0, 0); 74 c.gridwidth = GridBagConstraints.REMAINDER; 75 76 Component component = Box.createVerticalStrut(11); 77 layout.setConstraints(component, c); 78 add(component); 79 80 y += 1; 81 } 82 } 83 | Popular Tags |