1 7 package org.enhydra.base.tool; 8 9 import javax.swing.JPanel ; 10 11 import javax.swing.JLabel ; 12 import javax.swing.JOptionPane ; 13 import javax.swing.JTextField ; 14 20 public class ServerShutdownConfigurationPanel extends JPanel { 21 22 private JLabel head = null; 23 private JLabel serverPortLabel = null; 24 private JTextField serverPortText = null; 25 private JLabel serverStringLabel = null; 26 private JTextField serverStringText = null; 27 private JLabel jLabel = null; 28 31 public ServerShutdownConfigurationPanel() { 32 super(); 33 initialize(); 34 } 35 40 private void initialize() { 41 head = new JLabel (); 42 serverPortLabel = new JLabel (); 43 serverStringLabel = new JLabel (); 44 jLabel = new JLabel (); 45 this.setPreferredSize(new java.awt.Dimension (300,150)); 46 this.setSize(300, 150); 47 head.setText(""); 48 head.setName("head"); 49 head.setPreferredSize(new java.awt.Dimension (300,45)); 50 serverPortLabel.setText("Server Shutdown Port:"); 51 serverPortLabel.setName("serverPortLabel"); 52 serverPortLabel.setPreferredSize(new java.awt.Dimension (150,16)); 53 serverStringLabel.setText("Server Shutdown String:"); 54 serverStringLabel.setName("serverStringLabel"); 55 serverStringLabel.setPreferredSize(new java.awt.Dimension (150,16)); 56 jLabel.setText(""); 57 jLabel.setPreferredSize(new java.awt.Dimension (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 70 private JTextField getServerPortText() { 71 if (serverPortText == null) { 72 serverPortText = new JTextField (); 73 serverPortText.setPreferredSize(new java.awt.Dimension (75,20)); 74 serverPortText.setName("serverPortText"); 75 serverPortText.setText("8005"); 76 } 77 return serverPortText; 78 } 79 84 private JTextField getServerStringText() { 85 if (serverStringText == null) { 86 serverStringText = new JTextField (); 87 serverStringText.setPreferredSize(new java.awt.Dimension (125,20)); 88 serverStringText.setName("serverStringText"); 89 serverStringText.setText("SHUTDOWN"); 90 } 91 return serverStringText; 92 } 93 94 public void setServerPort (String port){ 95 getServerPortText().setText(port); 96 } 97 98 public String getServerPort (){ 99 return getServerPortText().getText(); 100 } 101 102 public void setServerString (String str){ 103 getServerStringText().setText(str); 104 } 105 106 public String 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 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 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 |