KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > base > tool > ServerShutdownConfigurationPanel


1 /*
2  * Created on Jul 19, 2005
3  *
4  * TODO To change the template for this generated file go to
5  * Window - Preferences - Java - Code Style - Code Templates
6  */

7 package org.enhydra.base.tool;
8
9 import javax.swing.JPanel JavaDoc;
10
11 import javax.swing.JLabel JavaDoc;
12 import javax.swing.JOptionPane JavaDoc;
13 import javax.swing.JTextField JavaDoc;
14 /**
15  * @author slobodan
16  *
17  * TODO To change the template for this generated type comment go to
18  * Window - Preferences - Java - Code Style - Code Templates
19  */

20 public class ServerShutdownConfigurationPanel extends JPanel JavaDoc {
21
22     private JLabel JavaDoc head = null;
23     private JLabel JavaDoc serverPortLabel = null;
24     private JTextField JavaDoc serverPortText = null;
25     private JLabel JavaDoc serverStringLabel = null;
26     private JTextField JavaDoc serverStringText = null;
27     private JLabel JavaDoc jLabel = null;
28     /**
29      * This is the default constructor
30      */

31     public ServerShutdownConfigurationPanel() {
32         super();
33         initialize();
34     }
35     /**
36      * This method initializes this
37      *
38      * @return void
39      */

40     private void initialize() {
41         head = new JLabel JavaDoc();
42         serverPortLabel = new JLabel JavaDoc();
43         serverStringLabel = new JLabel JavaDoc();
44         jLabel = new JLabel JavaDoc();
45         this.setPreferredSize(new java.awt.Dimension JavaDoc(300,150));
46         this.setSize(300, 150);
47         head.setText("");
48         head.setName("head");
49         head.setPreferredSize(new java.awt.Dimension JavaDoc(300,45));
50         serverPortLabel.setText("Server Shutdown Port:");
51         serverPortLabel.setName("serverPortLabel");
52         serverPortLabel.setPreferredSize(new java.awt.Dimension JavaDoc(150,16));
53         serverStringLabel.setText("Server Shutdown String:");
54         serverStringLabel.setName("serverStringLabel");
55         serverStringLabel.setPreferredSize(new java.awt.Dimension JavaDoc(150,16));
56         jLabel.setText("");
57         jLabel.setPreferredSize(new java.awt.Dimension JavaDoc(44,16));
58         this.add(head, null);
59         this.add(serverPortLabel, null);
60         this.add(getServerPortText(), null);
61         this.add(jLabel, null);
62         this.add(serverStringLabel, null);
63         this.add(getServerStringText(), null);
64     }
65     /**
66      * This method initializes jTextField
67      *
68      * @return javax.swing.JTextField
69      */

70     private JTextField JavaDoc getServerPortText() {
71         if (serverPortText == null) {
72             serverPortText = new JTextField JavaDoc();
73             serverPortText.setPreferredSize(new java.awt.Dimension JavaDoc(75,20));
74             serverPortText.setName("serverPortText");
75             serverPortText.setText("8005");
76         }
77         return serverPortText;
78     }
79     /**
80      * This method initializes jTextField
81      *
82      * @return javax.swing.JTextField
83      */

84     private JTextField JavaDoc getServerStringText() {
85         if (serverStringText == null) {
86             serverStringText = new JTextField JavaDoc();
87             serverStringText.setPreferredSize(new java.awt.Dimension JavaDoc(125,20));
88             serverStringText.setName("serverStringText");
89             serverStringText.setText("SHUTDOWN");
90         }
91         return serverStringText;
92     }
93     
94     public void setServerPort (String JavaDoc port){
95         getServerPortText().setText(port);
96     }
97     
98     public String JavaDoc getServerPort (){
99         return getServerPortText().getText();
100     }
101     
102     public void setServerString (String JavaDoc str){
103         getServerStringText().setText(str);
104     }
105     
106     public String JavaDoc getServerString (){
107         return getServerStringText().getText();
108     }
109     
110     public boolean checkEntries() {
111         boolean valid = true;
112         if ("".equals(serverPortText.getText())||serverPortText.getText()==null){
113             displayErrorMessage("Server Shutdown Port");
114             valid = false;
115         } else {
116             try {
117                 int temp = Integer.parseInt(serverPortText.getText());
118             } catch (NumberFormatException JavaDoc ex){
119                 displayErrorMessage("Server Shutdown Port");
120                 valid = false;
121             }
122         }
123         
124         if ("".equals(serverStringText.getText())||serverStringText.getText()==null){
125             displayErrorMessage("Server Shutdown String");
126             valid = false;
127         }
128         
129         return valid;
130     }
131
132     private void displayErrorMessage(String JavaDoc field) {
133         JOptionPane.showMessageDialog(null, "Check '" + field
134                 + "' Field Setting!",
135                 "Enhydra Configuration Tool - Houston, we have a problem!",
136                 JOptionPane.ERROR_MESSAGE);
137     }
138   }
139
Popular Tags