呵呵,重绘按钮就是了啊:
import javax.swing.*;
import java.applet.*;
import java.awt.*;
public class Paint extends Applet {
JPanel pnl=new JPanel();
JButton b1 = new JButton("开始");
public void init()
{
//b1.setBounds(100,100,80,40);
b1.setPreferredSize(new Dimension(100,50));
b1.setVisible(true);
//this.setLayout(null);
pnl.add(b1);
this.add(pnl);
this.setSize(300,200);
this.setVisible(true);
this.setLocation(400, 350);
//this.repaint();
}
public void paint(Graphics g)
{
g.drawString("跟我加高分哦",120,120);
pnl.repaint();
}
}
取消
评论