myfirstapplet.java

来自「ssd3的教程 是我们老师给我们的 纯英文 有兴趣的可以」· Java 代码 · 共 47 行

JAVA
47
字号
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;

public class MyFirstApplet extends JApplet
{
	public void init()
	{
		Container contentPane = getContentPane();
		contentPane.setLayout(new BorderLayout());

		JLabel label1 = new JLabel(getParameter("greeting"),SwingConstants.CENTER);
		label1.setFont(new Font("Serif",Font.BOLD,18));
		contentPane.add(label1,BorderLayout.CENTER);

		JPanel panel = new JPanel();

		JButton SWButton = new JButton("School of Software");
		SWButton.addActionListener(makeURLActionListener("http://cs.scu.edu.cn"));
		panel.add(SWButton);

		JButton RSHButton = new JButton("Please Contact me!");
		RSHButton.addActionListener(makeURLActionListener("mailto:ruanshuhua@cs.scu.edu.cn"));
		panel.add(RSHButton);

		contentPane.add(panel,BorderLayout.SOUTH);
	}
	private ActionListener makeURLActionListener(final String u)
	{
		return new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				try
				{
					getAppletContext().showDocument(new URL(u));
				}
				catch(MalformedURLException e)
				{
					e.printStackTrace();
				}
			}
		};
	}
}

⌨️ 快捷键说明

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