问题描述
importjavax.swing.JComponent;importjava.awt.*;importjava.io.*;importjavax.imageio.*;/****@authoracer*/publicclassConnectComponetextendsJComponent{privateStringpath;privateImageimage;privatefinalintpathnumber=14;privatefinalintpathfirstnumber=6;publicConnectComponet(){this.setBackgroundPicture();}@OverrideprotectedvoidpaintComponent(Graphicsg){super.paintComponent(g);System.out.print("abc");if(image==null){return;}g.drawImage(image,0,0,null);}voidsetBackgroundPicture(){path=this.getClass().getResource("").toString();path=path.substring(pathfirstnumber,path.length()-pathnumber)+"resource/";System.out.print("ad");try{image=ImageIO.read(newFile(path+"connnectbackground.png"));}catch(IOExceptione){e.printStackTrace();}this.repaint();}}这个程序(部分),其中paintComponent()没有自动调用,后用repaint(),paint()方法均无效!!!求助。。。。