皮皮学,免费搜题
登录
搜题
【简答题】
本题程序通过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); } }
拍照语音搜题,微信中搜索"皮皮学"使用
参考答案:
参考解析:
知识点:
.
..
皮皮学刷刷变学霸
举一反三
【单选题】以下哪个是美国常用的购物网站:
A.
www.amazon.com
B.
www.overstock.cn
C.
www.kohls.ru
D.
www.blufly.ru
【简答题】I Choose the correct form of the words to complete the following sentences. 1. advertise, advertisement, advertising a. Nowadays, Internet _________ is a rapidly developing industry in China. b. Many ...
【简答题】For most people, the word“fashion” means “clothes”. But people may ask the question, “What 1 are in fashion?” And they use the adjective“fashionable” in the same way: “She was wearing a fashionable ...
【简答题】“fashion” means “clothes” For most people,the word “fashion” means “clothes”。 But people may ask the question,“What clothes are in fashion?”And they use the adjective “fashionable” in the same way: “S...
【判断题】无论制动鼓正向还是反向旋转时,领从蹄式制动器的前蹄都是领蹄,从蹄都是从蹄。( )
A.
正确
B.
错误
【简答题】For most people,the word “fashion” means “clothes”。 But people may ask the question,“What clothes are in fashion?”And they use the adjective “fashionable” in the same way: “She was wearing a fashionab...
【简答题】I. Complete the following sentences withthe words given below. personal popularity self-control treatment appearance management inheritance possibility national ...
【判断题】当多个线朝同一个方向的点聚集时,有出现了一种透视的存在,即可在平面中表现出三维空间的视觉美感
A.
正确
B.
错误
【判断题】领从蹄式制动器制动时,无论制动鼓正转还是反转,其前蹄都是领蹄,后蹄都是从蹄。
A.
正确
B.
错误
【单选题】Many fashions are _________ on the website.
A.
advertise
B.
advertisement
C.
advertising
D.
advertised
相关题目: