import java.awt.*;
import javax.swing.*;
public class awt extends JFrame{
public awt(String s){super(s);}
/**
* @param args
*/
public static void main(String[] args) {
awt frame = new awt("farme1");
frame.setLayout(null);
frame.setSize(500,500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel1 jp = new panel1();
frame.add(jp);
//frame.add(xx);
frame.setVisible(true);
}
}
class panel1 extends JPanel{
public void paintComponent(Graphics g)
{
this.setLayout(null);
this.setSize(255, 333);
g.setColor(Color.red);
//g.drawImage("d:/123.gif", 88, 77, 66, 55, 44, 33, 22, 11, Color.BLACK, 1);
g.drawString("12345678",30,50);
//g.drawImage("d:/123.gif",33,44);
g.drawRect(22,33, 200, 100);
g.fillRect(11, 22, 155, 111);
}
}
如果屏蔽掉 frame.setLayout(null);就可以显示出来了,为什么????