编写一个Java JApplet小应用程序,实现在窗口上添加一个红色的按钮,标题为"你好"。
展开全部
import java.awt.*;
import javax.swing.*;
/**
* @author Hardneedl
*/
public class ButtonApplet extends JApplet {
private final static Dimension SIZE = new Dimension(300, 200);
public Dimension getSize() {return SIZE;}
public Dimension getMinimumSize() {return SIZE;}
public Dimension getPreferredSize() {return SIZE;}
public void init() {
super.init();
getContentPane().add( new JButton("你好"){
public Color getBackground() {return Color.RED;}
} ,BorderLayout.NORTH);
}
}
import javax.swing.*;
/**
* @author Hardneedl
*/
public class ButtonApplet extends JApplet {
private final static Dimension SIZE = new Dimension(300, 200);
public Dimension getSize() {return SIZE;}
public Dimension getMinimumSize() {return SIZE;}
public Dimension getPreferredSize() {return SIZE;}
public void init() {
super.init();
getContentPane().add( new JButton("你好"){
public Color getBackground() {return Color.RED;}
} ,BorderLayout.NORTH);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |