26.07.2013 Views

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

988 Networking Chapter 17<br />

71<br />

72 // load document; change mouse cursor <strong>to</strong> indicate status<br />

73 private void getThePage( String location )<br />

74 {<br />

75 // change mouse cursor <strong>to</strong> WAIT_CURSOR<br />

76 setCursor( Cursor.getPredefinedCursor(<br />

77 Cursor.WAIT_CURSOR ) );<br />

78<br />

79 // load document in<strong>to</strong> contentsArea and display location in<br />

80 // enterField<br />

81 try {<br />

82 contentsArea.setPage( location );<br />

83 enterField.setText( location );<br />

84 }<br />

85<br />

86 // process problems loading document<br />

87 catch ( IOException ioException ) {<br />

88 JOptionPane.showMessageDialog( this,<br />

89 "Error retrieving specified URL",<br />

90 "Bad URL", JOptionPane.ERROR_MESSAGE );<br />

91 }<br />

92<br />

93 setCursor( Cursor.getPredefinedCursor(<br />

94 Cursor.DEFAULT_CURSOR ) );<br />

95 }<br />

96<br />

97 // begin application execution<br />

98 public static void main( String args[] )<br />

99 {<br />

100 ReadServerFile application = new ReadServerFile();<br />

101<br />

102 application.setDefaultCloseOperation(<br />

103 JFrame.EXIT_ON_CLOSE );<br />

104 }<br />

105<br />

106 } // end class ReadServerFile<br />

Fig. Fig. 17.3 17.3 Reading a file by opening a connection through a URL (part 3 of 4)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!