hi all... I am trying to understand how java graphics works.
the problem is NOT showing an image... but WHY it must extend a class!
the following compiles, and displays, then blanks out... why?
Code:JFrame jFrame = new JFrame( "JFrame Only" ) ; java.awt.image.BufferedImage buffImg = null ; try { buffImg = javax.imageio.ImageIO.read( new File( "hal.jpg" ) ); } catch ( Exception ex ) { ; } Dimension dimi = new Dimension( buffImg .getWidth( null ) , buffImg .getHeight( null ) ) ; jFrame.setPreferredSize( dimension ) ; jFrame.setLocation( 200 , 200 ) ; jFrame.pack( ) ; jFrame.setVisible( true ) ; Graphics graphics = jFrame.getGraphics() ; graphics.drawImage( buffImg , 0, 0, dimi.width , dimi.height , jFrame ) ;![]()


Reply With Quote


Bookmarks