📄 myfirstapplet.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -