⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viewwebpage.java

📁 一个十分好的java基础学习的课件
💻 JAVA
字号:
// ViewingWebPagesViewWebPage.java: Access HTML pages through applets
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;

public class ViewWebPage extends JApplet implements ActionListener
{
  // Button to display an HTML page on the applet
  private JButton jbtGo = new JButton("Go");

  // Text field for receiving the URL of the HTML page
  private JTextField jtfURL = new JTextField(20);

  // Initialize the applet
  public void init()
  {
    // Add URL text field and Go button
    getContentPane().setLayout(new FlowLayout());
    getContentPane().add(new JLabel("URL"));
    getContentPane().add(jtfURL);
    getContentPane().add(jbtGo);

    // Register listener
    jbtGo.addActionListener(this);
  }

  // Handle the ActionEvent
  public void actionPerformed(ActionEvent evt)
  {
    if (evt.getSource() == jbtGo)
      try
      {
        AppletContext context = getAppletContext();

        // Get the URL from text field
        URL url = new URL(jtfURL.getText());
        context.showDocument(url);
      }
      catch(Exception ex)
      {
        showStatus("Error " + ex);
      }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -