01: /*
02: * Copyright (C) 2005 Jeff Tassin
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package com.jeta.swingbuilder.gui.dimension;
20:
21: import java.awt.BorderLayout;
22: import java.awt.Dimension;
23:
24: import com.jeta.forms.components.panel.FormPanel;
25: import com.jeta.open.gui.framework.JETAPanel;
26: import com.jeta.swingbuilder.gui.components.IntegerDocument;
27:
28: public class DimensionView extends JETAPanel {
29: private FormPanel m_view;
30:
31: public DimensionView() {
32: this (null);
33: }
34:
35: public DimensionView(Dimension dim) {
36: setLayout(new BorderLayout());
37: m_view = new FormPanel(
38: "com/jeta/swingbuilder/gui/dimension/dimension.jfrm");
39: add(m_view, BorderLayout.CENTER);
40:
41: m_view.getTextField(DimensionNames.ID_WIDTH_FIELD).setDocument(
42: new IntegerDocument(false));
43: m_view.getTextField(DimensionNames.ID_HEIGHT_FIELD)
44: .setDocument(new IntegerDocument(false));
45:
46: if (dim != null) {
47: m_view.setText(DimensionNames.ID_WIDTH_FIELD, String
48: .valueOf(dim.width));
49: m_view.setText(DimensionNames.ID_HEIGHT_FIELD, String
50: .valueOf(dim.height));
51: }
52:
53: }
54:
55: public Dimension getDimension() {
56: Dimension d = new Dimension(m_view.getInteger(
57: DimensionNames.ID_WIDTH_FIELD, 20), m_view.getInteger(
58: DimensionNames.ID_HEIGHT_FIELD, 20));
59: return d;
60: }
61: }
|