问题描述
初学者,遇到问题了,求大神解决,运行后,显示出来的窗口是空白的importjava.awt.Color;importjava.awt.Graphics;importjava.awt.Image;importjavax.annotation.Generated;importjavax.swing.ImageIcon;importjavax.swing.JFrame;importjavax.swing.JPanel;publicclassFrame{publicstaticvoidmain(String[]args){JFramefa=newJFrame();fa.setBounds(0,0,800,600);fa.setVisible(true);fa.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);Hbfb=newHb();fa.add(fb);}}classHbextendsJPanel{publicvoidpaint(Graphicsg){Imageimg=newImageIcon("aa.jpg").getImage();g.drawImage(img,400,400,this);}}
时间: 2024-11-05 20:37:19