importjavax.swing.*;importjava.awt.*;importjava.awt.event.*;publicclassTupianextendsJFrame{publicstaticvoidmain(String[]args){newTupian();}publicTupian(){JPanelpanel=newJ...
import javax.swing.*;import java.awt.*;import java.awt.event.*;public class Tupian extends JFrame { public static void main(String[] args) { new Tupian(); } public Tupian() { JPanel panel = new JPanel() { @Override protected void paintComponent(Graphics g) { super.paintComponent(g); Image image = new ImageIcon("D:\tuan\5830.png").getImage(); int width = Tupian.getFrames()[0].getWidth(); int heigh = Tupian.getFrames()[0].getHeight(); g.drawImage(image, 0, 0, width, heigh, null); } }; add(panel); setBounds(500, 100, 480, 320); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); }}
只显示一个界面没有图片怎么回事?
展开