/Users/lyon/j4p/src/ip/hak/QuestionDialog.java

1    package ip.hak; 
2     
3    import java.awt.*; 
4    import java.awt.event.ActionEvent; 
5    import java.awt.event.ActionListener; 
6     
7     
8    public class QuestionDialog extends ClosableDialog implements ActionListener { 
9     
10       Label cLabel; // colum Label 
11       Label rLabel; // row Label 
12       TextField cTextField; 
13       TextField rTextField; 
14       Button oKButton; 
15       int colum = 3; 
16       int row = 3; 
17    
18       public QuestionDialog(Frame parent, String title) { 
19           super(parent, title, true); 
20       } 
21    
22       public void makeDialog() { 
23           init(); 
24           setVisible(true); 
25       } 
26    
27       private void init() { 
28           setLayout(null); 
29           Insets in = getInsets(); 
30           setSize(in.left + in.right + 154, in.top + in.bottom + 132); 
31    
32           cLabel = new Label("Colums : "); 
33           cLabel.setBounds(in.left + 30, in.top + 30, 60, 12); 
34           add(cLabel); 
35    
36           cTextField = new TextField("3"); 
37           cTextField.setBounds(in.left + 100, in.top + 30, 30, 20); 
38           add(cTextField); 
39    
40           rLabel = new Label("Rows : "); 
41           rLabel.setBounds(in.left + 40, in.top + 60, 40, 12); 
42           add(rLabel); 
43    
44           rTextField = new TextField("3"); 
45           rTextField.setBounds(in.left + 100, in.top + 60, 30, 20); 
46           add(rTextField); 
47    
48           oKButton = new Button("OK"); 
49           oKButton.setBounds(in.left + 30, in.top + 100, 88, 20); 
50           oKButton.addActionListener(this); 
51    
52           add(oKButton); 
53       } 
54    
55       public int getColum() { 
56           return colum; 
57       } 
58    
59       public int getRow() { 
60           return row; 
61       } 
62    
63       public void actionPerformed(ActionEvent e) { 
64           if (e.getSource() == oKButton) { 
65               // get Colums 
66               String temp = cTextField.getText(); 
67    
68               try { 
69                   Integer itemp = null; 
70                   itemp = itemp.valueOf(temp); 
71                   colum = itemp.intValue(); 
72               } catch (NumberFormatException nfe) { 
73                   System.out.println("Input Number!!!"); 
74               } 
75    
76    
77               // get rows 
78               temp = rTextField.getText(); 
79               try { 
80                   Integer itemp = null; 
81                   itemp = itemp.valueOf(temp); 
82                   row = itemp.intValue(); 
83               } catch (NumberFormatException nfe) { 
84                   System.out.println("Input Number!!!"); 
85               } 
86    
87    
88               setVisible(false); 
89               return; 
90           } 
91       } 
92   }