请前辈评论applet编码风格,还能否优化
请前辈评论applet编码风格,还能否优化
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Button extends JApplet {
private static final long serialVersionUID=123456L
JButton b1 = new JButton("向左走");
JButton b2 = new JButton("向右走");
public void init() {
this.getContentPane();
run(this);
this.setVisible(true);
}
public void run(JApplet applet) {
container();
JFrame frame = new JFrame();
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
//响应关闭按钮
}
private void container() {
Container cp = getContentPane();
cp.setLayout(new FlowLayout());
cp.add(b1);
cp.add(b2);
}
}