My java code below uses a JFRAME to display a image. The image is displaying but is taking up like 3000 pixels width. So I can see the entire image being display. I want my java code to display the image in a frame that is 500 by 500. The image has to fit within that frame.
1. With Swing you override the paintComponent() method of a JPanel
2. A painting method should NOT do I/O. You want the method to be efficient since you can't control when the component will be repainted.
3. Read the Graphics API. There is a drawImage(…) method that allows you to specify the size of the image to be painted. So you would use the getWidth() and getHeight() methods of the JPanel to determine the image size.
Destroy anything that stands in your way. Except this tiny ad:
Try Free Java/.NET Libraries for Word Excel PowerPoint and PDF