📄 jappletwithbuttons.java
字号:
import java.net.*;
import java.awt.event.*;
import java.awt.FlowLayout;
import javax.swing.*;
public class JAppletWithButtons extends JApplet implements ActionListener
{
JButton windLook = new JButton("Windows");
JButton unixLook = new JButton("Unix");
JButton javaLook = new JButton("Java");
JLabel label = new JLabel("Welcome to swing", SwingConstants.CENTER);
public void init()
{
try
{
URL windURL = new URL(getCodeBase(), "Icons/windows.gif");
URL unixURL = new URL(getCodeBase(), "Icons/xwin.gif");
URL javaURL = new URL(getCodeBase(), "Icons/java.gif");
URL newURL = new URL(getCodeBase(), "Icons/new.gif");
windLook.setIcon(new ImageIcon(windURL));
unixLook.setIcon(new ImageIcon(unixURL));
javaLook.setIcon(new ImageIcon(javaURL));
label.setIcon(new ImageIcon(newURL));
}
catch (MalformedURLException murle)
{
System.err.println("error loading button images: " + murle);
}
getContentPane().setLayout(new FlowLayout());
getContentPane().add(label);
getContentPane().add(windLook);
getContentPane().add(unixLook);
getContentPane().add(javaLook);
}
public void actionPerformed(ActionEvent ae)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -