I have a JPanel (which I created using netbeans)and I need to load image in it, based on selection on previous page. Could anyone suggest how to do that. Also is JPanel the best way to do what I am trying to do, or I could do something else ?
Efforts appreciated thanks!!
The easiest way to display an image is to use a JLabel and call its setIcon method (or its constructor). The icon can be loaded using one of the constructors of the ImageIcon class.
See http://download.oracle.com/javase/tutorial/uiswing/components/label.html for an example.
There are number of ways to read/load images in Java. Take a look at this tutorial.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With