View Javadoc
1   // ////////////////////////////////////////////////////////////////////////////
2   // dexterIM - Instant Messaging Framework
3   // Copyright (C) 2003 Christoph Walcher
4   //
5   // This program is free software; you can redistribute it and/or modify
6   // it under the terms of the GNU General Public License as published by
7   // the Free Software Foundation; either version 2 of the License, or
8   // (at your option) any later version.
9   //
10  // This program is distributed in the hope that it will be useful,
11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  // GNU General Public License for more details.
14  //
15  // You should have received a copy of the GNU General Public License
16  // along with this program; if not, write to the Free Software
17  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  //////////////////////////////////////////////////////////////////////////////
19  package net.sf.dexterim.ui;
20  
21  import java.text.NumberFormat;
22  
23  import javax.swing.JFormattedTextField;
24  import javax.swing.JPanel;
25  
26  
27  /***
28   * @author christoph
29   *
30   */
31  public class JIndexPanel extends JPanel {
32  
33  	private JFormattedTextField startIndexField;
34  	private JFormattedTextField endIndexField;
35  	
36  	public JIndexPanel() {
37  		this(0, 0);
38  	}
39  	
40  	public JIndexPanel(int startIndex, int endIndex) {
41  		super();
42  		
43  		startIndexField = new JFormattedTextField(NumberFormat.getIntegerInstance());
44  		startIndexField.setValue(new Integer(startIndex));
45  		add(startIndexField);
46  		
47  		endIndexField = new JFormattedTextField(NumberFormat.getIntegerInstance());
48  		endIndexField.setValue(new Integer(endIndex));
49  		add(endIndexField);
50  	}
51  	
52  	/***
53  	 * @return Returns the endIndex.
54  	 */
55  	public int getEndIndex() {
56  		return new Integer(endIndexField.getValue().toString()).intValue();
57  	}
58  	
59  	/***
60  	 * @param endIndex The endIndex to set.
61  	 */
62  	public void setEndIndex(int endIndex) {
63  		endIndexField.setValue(new Integer(endIndex));
64  	}
65  	
66  	/***
67  	 * @return Returns the startIndex.
68  	 */
69  	public int getStartIndex() {
70  		return new Integer(startIndexField.getValue().toString()).intValue();
71  	}
72  	
73  	/***
74  	 * @param startIndex The startIndex to set.
75  	 */
76  	public void setStartIndex(int startIndex) {
77  		startIndexField.setValue(new Integer(startIndex));
78  	}
79  }