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