... ); 56      setSize(400, 300); // set size of window
57      setVisible(true); // show window
58    } 
59
60    // load document
61    private void getThePage(String location)
62    { 
63       try // load document and display location
64       { 
65          contentsArea.setPage(location); // set the page
66          enterField.setText(location); // set the text
67       } 
68       catch (IOException ioException) 
69       { 
70          JOptionPane.showMessageDialog(this, 
71             “Error retrieving specified URL”, “Bad URL”, 
72             JOptionPane.ERROR_MESSAGE); 
73        } 
74     } 
75    }

Fig. 28.2 Test class for ReadServerFile.


1    // Fig. 28.2: ReadServerFileTest.java
2    // Create and start a ReadServerFile.
3    import javax.swing.JFrame;
4
5    public class ReadServerFileTest
6    {
7          public static void main(String[] args)
8          {
9 ReadServerFile application ...

Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.