JFrame frame1 = new JFrame("test");
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = frame1.getContentPane();
c.setSize(20,20);
c.setLayout(new FlowLayout(FlowLayout.CENTER, 3, 3));Image img = Toolkit.getDefaultToolkit().createImage("image/wink.gif");想要把 Image显示在 窗口中,如何做?
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = frame1.getContentPane();
c.setSize(20,20);
c.setLayout(new FlowLayout(FlowLayout.CENTER, 3, 3));Image img = Toolkit.getDefaultToolkit().createImage("image/wink.gif");想要把 Image显示在 窗口中,如何做?
c.getGraphics().drawImage(img, ...
能给例子吗? 后面的参数怎么填
private ImageIcon image = null;
public NewPanel(ImageIcon image){
this.image = image;
}
protected void paintComponent(Graphics g) {
setOpaque(true);
super.paintComponent(g);
g.drawImage( image.getImage(), 0,0, null, null );
}
}