/Users/lyon/j4p/src/net/dns/SearchDNS.java

1    package net.dns; 
2     
3    import java.applet.Applet; 
4    import java.awt.*; 
5    import java.awt.event.ActionEvent; 
6    import java.awt.event.ActionListener; 
7     
8     
9    public class SearchDNS extends Applet implements ActionListener { 
10    
11     //-------------------------------------------------------------- 
12    
13     private TextField searchField; 
14     private Button searchButton = new Button("Use DNS"); 
15    
16     //-------------------------------------------------------------- 
17    
18     public void init() { 
19    
20       Label title = new Label("Enter a name to get an IP addBk.address"); 
21       title.setFont(new Font("Helvetica", Font.BOLD, 18)); 
22       title.setBackground(Color.red); 
23       title.setForeground(Color.yellow); 
24       add(title); 
25    
26       add(searchButton); 
27       searchButton.addActionListener(this); 
28       searchField = new TextField(20); 
29       add(searchField); 
30     } 
31    
32    
33     public void actionPerformed(ActionEvent e) { 
34    
35       if (e.getSource() == searchButton) { 
36    
37         String searchString = searchField.getText(); 
38         if (searchString.equals("")) searchString = "cse.bridgeport.edu"; 
39    
40         try { 
41           Dns.getHostName(searchString); 
42    
43         } catch (Exception ex) { 
44         } 
45         ; 
46    
47         return; 
48       } 
49     } 
50    
51     public TextField getSearchField() { 
52       return searchField; 
53     } 
54    
55     public void setSearchField(TextField searchField) { 
56       this.searchField = searchField; 
57     } 
58    
59     public Button getSearchButton() { 
60       return searchButton; 
61     } 
62    
63     public void setSearchButton(Button searchButton) { 
64       this.searchButton = searchButton; 
65     } 
66   } 
67