View Javadoc

1   /*
2    * XMLCV - Gestion de CV sous forme XML
3    * 
4    * Copyright (C) 2004-2005, Damien Raude-Morvan
5    * 
6    * This file is part of XMLCV.
7    *
8    * XMLCV is free software; you can redistribute it and/or modify
9    * it under the terms of the GNU General Public License as published by
10   * the Free Software Foundation; either version 2 of the License, or
11   * (at your option) any later version.
12   *
13   * XMLCV is distributed in the hope that it will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   * GNU General Public License for more details.
17   *
18   * You should have received a copy of the GNU General Public License
19   * along with XMLCV; if not, write to the Free Software
20   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21   * 
22   * Contacts :
23   * - Sébastien Mathy <smathy@tuxfamily.org>
24   * - Emmanuel Berre <eberre@tuxfamily.org>
25   * - Damien Raude-Morvan <drazzib@drazzib.com>
26   */
27  package org.xmlcv.gui.tabs;
28  
29  import javax.swing.JFormattedTextField;
30  import javax.swing.JLabel;
31  import javax.swing.JPanel;
32  import javax.swing.JTextField;
33  import javax.swing.SwingConstants;
34  import javax.swing.JFormattedTextField.AbstractFormatter;
35  
36  /***
37   * 
38   * @version $Revision: 114 $
39   * @author <a href="mailto:drazzib@drazzib.com">Damien Raude-Morvan </a>
40   */
41  public abstract class AbstractTab extends JPanel {
42  
43  	protected JTextField createField(String labelTitle) {
44  		return createField(labelTitle, 15);
45  	}
46  
47  	protected JFormattedTextField createFormattedField(String labelTitle,
48  			AbstractFormatter formater) {
49  		JFormattedTextField field = new JFormattedTextField(formater);
50  		JLabel label = new JLabel(labelTitle, SwingConstants.TRAILING); //$NON-NLS-1$
51  		label.setLabelFor(field);
52  
53  		this.add(label);
54  		this.add(field);
55  
56  		return field;
57  	}
58  
59  	protected JTextField createField(String labelTitle, int fieldSize) {
60  		JTextField field = new JTextField(fieldSize);
61  		JLabel label = new JLabel(labelTitle, SwingConstants.TRAILING);
62  		label.setLabelFor(field);
63  
64  		this.add(label);
65  		this.add(field);
66  
67  		return field;
68  	}
69  
70  }