本题程序通过URL链接获取网站提供的HTML文档,显示在界面中文本域内,如题图,请按注释要求补充完整程序代码。程序代码如下: package showtxtsample; import java.awt.*; import java.awt.event.*; import java.io.*; import java.net.*; import javax.swing.*; public class ShowTXTSample extends JFrame { private static final long serialVersionUID = 1L; BorderLayout borderLayout = new BorderLayout(); JTextArea jTextArea = new JTextArea(); JScrollPane jScrollPane = new JScrollPane(jTextArea); JToolBar jToolBar = new JToolBar(); JLabel jLabel = new JLabel("地址:"); JTextField jTextField = new JTextField("输入协议以及IP地址"); String url_adr = null; URL url = null; InputStream in = null; BufferedReader br = null; String txt = null; public ShowTXTSample() { try { showInit(); } catch (Exception exception) { exception.printStackTrace(); } } private void showInit() throws Exception { getContentPane().setLayout(borderLayout); jTextField.addKeyListener(new KeyAdapter(){ public void keyTyped(KeyEvent e) { jTextField_keyTyped(e); } }); jToolBar.add(jLabel); jToolBar.add(jTextField); getContentPane().add(jToolBar,BorderLayout.NORTH); getContentPane().add(jScrollPane,BorderLayout.CENTER); } public void jTextField_keyTyped(KeyEvent e) { if(e.getKeyChar() == KeyEvent.VK_ENTER){ try { url_adr = jTextField.getText(); url = new URL(url_adr); in = url.openStream(); //创建读缓冲区,并以utf-8字符编码绑定输入流。 br = new BufferedReader(__________________________________________); while( (txt = br.readLine()) != null ) { //将读取的文本显示到文本域中。 __________________________________; jTextArea.append("\n"); } } catch( MalformedURLException mue ) { mue.printStackTrace(); } catch( UnknownHostException uhe ) { uhe.printStackTrace(); } catch( IOException ioe ) { ioe.printStackTrace(); } } } public static void main(String[] args) { ShowTXTSample showtxtsample = new ShowTXTSample(); showtxtsample.setTitle("显示网络文本数据"); showtxtsample.setSize(600,300); showtxtsample.setVisible(true); showtxtsample.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }