2 GNU Lesser General Public License
5 Copyright (C) 2000 Howard Kistler
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 package com
.hexidec
.ekit
.component
;
24 import java
.awt
.Frame
;
25 import java
.awt
.event
.WindowAdapter
;
26 import java
.awt
.event
.WindowEvent
;
27 import java
.beans
.PropertyChangeEvent
;
28 import java
.beans
.PropertyChangeListener
;
29 import javax
.swing
.JDialog
;
30 import javax
.swing
.JOptionPane
;
31 import javax
.swing
.JTextField
;
33 import com
.hexidec
.util
.Translatrix
;
35 /** Class for providing a dialog that lets the user specify values for tag attributes
37 public class TableInputDialog
extends JDialog
39 private String inputRows
= new String();
40 private String inputCols
= new String();
41 private String inputBorder
= new String();
42 private String inputSpace
= new String();
43 private String inputPad
= new String();
44 private JOptionPane jOptionPane
;
46 public TableInputDialog(Frame parent
, String title
, boolean bModal
)
48 super(parent
, title
, bModal
);
49 final JTextField jtxfRows
= new JTextField(3);
50 final JTextField jtxfCols
= new JTextField(3);
51 final JTextField jtxfBorder
= new JTextField(3);
52 final JTextField jtxfSpace
= new JTextField(3);
53 final JTextField jtxfPad
= new JTextField(3);
54 final Object
[] buttonLabels
= { Translatrix
.getTranslationString("DialogAccept"), Translatrix
.getTranslationString("DialogCancel") };
55 Object
[] panelContents
= {
56 Translatrix
.getTranslationString("TableRows"), jtxfRows
,
57 Translatrix
.getTranslationString("TableColumns"), jtxfCols
,
58 Translatrix
.getTranslationString("TableBorder"), jtxfBorder
,
59 Translatrix
.getTranslationString("TableCellSpacing"), jtxfSpace
,
60 Translatrix
.getTranslationString("TableCellPadding"), jtxfPad
62 jOptionPane
= new JOptionPane(panelContents
, JOptionPane
.QUESTION_MESSAGE
, JOptionPane
.OK_CANCEL_OPTION
, null
, buttonLabels
, buttonLabels
[0]);
64 setContentPane(jOptionPane
);
65 setDefaultCloseOperation(DO_NOTHING_ON_CLOSE
);
67 addWindowListener(new WindowAdapter() {
68 public void windowClosing(WindowEvent we
)
70 jOptionPane
.setValue(new Integer(JOptionPane
.CLOSED_OPTION
));
74 jOptionPane
.addPropertyChangeListener(new PropertyChangeListener() {
75 public void propertyChange(PropertyChangeEvent e
)
77 String prop
= e
.getPropertyName();
79 && (e
.getSource() == jOptionPane
)
80 && (prop
.equals(JOptionPane
.VALUE_PROPERTY
) || prop
.equals(JOptionPane
.INPUT_VALUE_PROPERTY
)))
82 Object value
= jOptionPane
.getValue();
83 if(value
== JOptionPane
.UNINITIALIZED_VALUE
)
87 jOptionPane
.setValue(JOptionPane
.UNINITIALIZED_VALUE
);
88 if(value
.equals(buttonLabels
[0]))
90 inputRows
= jtxfRows
.getText();
91 inputCols
= jtxfCols
.getText();
92 inputBorder
= jtxfBorder
.getText();
93 inputSpace
= jtxfSpace
.getText();
94 inputPad
= jtxfPad
.getText();
116 return Integer
.parseInt(inputRows
);
118 catch(NumberFormatException nfe
)
128 return Integer
.parseInt(inputCols
);
130 catch(NumberFormatException nfe
)
136 public int getBorder()
140 return Integer
.parseInt(inputBorder
);
142 catch(NumberFormatException nfe
)
148 public int getSpacing()
152 return Integer
.parseInt(inputSpace
);
154 catch(NumberFormatException nfe
)
160 public int getPadding()
164 return Integer
.parseInt(inputPad
);
166 catch(NumberFormatException nfe
)