主题:想要在面板上显示一条信息 可是什么也没显示出来
public class test extends javax.swing.JFrame{
public test(){
getContentPane().add(new DrawMessage());
}
public static void main(String[]args){
test frame=new test();
frame.setSize(100,200);
frame.setVisible(true);
}
}
class DrawMessage extends javax.swing.JPanel{
protected void PaintComponent(java.awt.Graphics g){
super.paintComponent(g);
g.drawString("Welcome to Java",20,20);
}
}
想要在面板上显示一条信息 可是什么也没显示出来
public test(){
getContentPane().add(new DrawMessage());
}
public static void main(String[]args){
test frame=new test();
frame.setSize(100,200);
frame.setVisible(true);
}
}
class DrawMessage extends javax.swing.JPanel{
protected void PaintComponent(java.awt.Graphics g){
super.paintComponent(g);
g.drawString("Welcome to Java",20,20);
}
}
想要在面板上显示一条信息 可是什么也没显示出来