1 19 20 package org.apache.excalibur.instrument.client; 21 22 import java.awt.Component ; 23 import java.net.MalformedURLException ; 24 import java.net.URL ; 25 26 import javax.swing.JOptionPane ; 27 import javax.swing.JTextField ; 28 29 35 class ConnectDialog 36 extends AbstractTabularOptionDialog 37 { 38 private JTextField m_urlField; 39 private URL m_url; 40 41 44 49 ConnectDialog( InstrumentClientFrame frame ) 50 { 51 super( frame, "Connect to Remote Instrument Manager", 52 AbstractOptionDialog.BUTTON_OK | AbstractOptionDialog.BUTTON_CANCEL ); 53 } 54 55 58 63 protected String getMessage() 64 { 65 return "Please enter the url of the InstrumentManager to connect to."; 66 } 67 68 73 protected boolean validateFields() 74 { 75 URL url; 77 try 78 { 79 url = new URL ( m_urlField.getText().trim() ); 80 } 81 catch ( MalformedURLException e ) 82 { 83 JOptionPane.showMessageDialog( this, "Please enter a valid url: " + e.getMessage(), 84 "Invalid URL", JOptionPane.ERROR_MESSAGE ); 85 return false; 86 } 87 m_url = url; 88 89 return true; 90 } 91 92 95 101 protected String [] getMainPanelLabels() 102 { 103 return new String [] 104 { 105 "URL:" 106 }; 107 } 108 109 114 protected Component [] getMainPanelComponents() 115 { 116 m_urlField = new JTextField (); 117 m_urlField.setColumns( 30 ); 118 119 return new Component [] 120 { 121 m_urlField 122 }; 123 } 124 125 128 133 void setURL( URL url ) 134 { 135 m_url = url; 136 m_urlField.setText( url.toExternalForm() ); 137 } 138 139 144 URL getURL() 145 { 146 return m_url; 147 } 148 } 149 150 | Popular Tags |