62,616
社区成员
发帖
与我相关
我的任务
分享
public class ExFrame extends JFrame{
ExFrame() throws IOException{
super("ExFrame");
Container content = getContentPane();
content.add(new ExPanel());
setVisible(true);
}
public static void main(String[] args) throws IOException
{
Image bi = ImageIO.read(new File("file.png"));
JFrame jf = new BigToSmall();
jf.setSize(bi.getWidth(null), bi.getHeight(null));
}
}
class ExPanel extends JPanel{
public BsPanel() throws IOException{
bi = ImageIO.read(new File("file.png"));
}
public void paint(Graphics g){
g.drawImage(bi, 0, 0, this);
System.out.println(bi.getWidth(this) + " " + bi.getHeight(this));
}
Image bi;
}