1
/* ========================================================================
2
* JCommon : a free general purpose class library for the Java(tm) platform
3
* ========================================================================
5
* (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
7
* Project Info: http://www.jfree.org/jcommon/index.html
9
* This library is free software; you can redistribute it and/or modify it
10
* under the terms of the GNU Lesser General Public License as published by
11
* the Free Software Foundation; either version 2.1 of the License, or
12
* (at your option) any later version.
14
* This library is distributed in the hope that it will be useful, but
15
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17
* License for more details.
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with this library; if not, write to the Free Software
21
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
24
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
25
* in the United States and other countries.]
27
* --------------------
28
* InsetsTextField.java
29
* --------------------
30
* (C) Copyright 2000-2004, by Andrzej Porebski.
32
* Original Author: Andrzej Porebski;
33
* Contributor(s): Arnaud Lelievre;
35
* $Id: InsetsTextField.java,v 1.2 2005/10/18 13:18:34 mungady Exp $
37
* Changes (from 7-Nov-2001)
38
* -------------------------
39
* 07-Nov-2001 : Added to com.jrefinery.ui package (DG);
40
* 08-Sep-2003 : Added internationalization via use of properties resourceBundle (RFE 690236) (AL);
46
import java.awt.Insets;
47
import java.util.ResourceBundle;
49
import javax.swing.JTextField;
52
* A JTextField for displaying insets.
54
* @author Andrzej Porebski
56
public class InsetsTextField extends JTextField {
58
/** The resourceBundle for the localization. */
59
protected static ResourceBundle localizationResources =
60
ResourceBundle.getBundle("org.jfree.ui.LocalizationBundle");
63
* Default constructor. Initializes this text field with formatted string describing
66
* @param insets the insets.
68
public InsetsTextField(final Insets insets) {
75
* Returns a formatted string describing provided insets.
77
* @param insets the insets.
81
public String formatInsetsString(Insets insets) {
82
insets = (insets == null) ? new Insets(0, 0, 0, 0) : insets;
84
localizationResources.getString("T") + insets.top + ", "
85
+ localizationResources.getString("L") + insets.left + ", "
86
+ localizationResources.getString("B") + insets.bottom + ", "
87
+ localizationResources.getString("R") + insets.right;
91
* Sets the text of this text field to the formatted string
92
* describing provided insets. If insets is null, empty insets
95
* @param insets the insets.
97
public void setInsets(final Insets insets) {
98
setText(formatInsetsString(insets));