I'm using NetBeans 7.1 to code in Java. I have already created a JFrame filled with some labels, textbox and buttons. How can I do to import some image (JPG,PNG,etc...) from my PC into the same JFrame? On an specific location of the frame.
- Open the form in NetBeans form editor.
- Add a
JLabelfrom the pallete to the form - Select the label you just added and click the "..." button next to the
iconproperty - Fill out the properties.
It's normally best that the images reside within the project folder, makes deployment easier in the long run.
Make sure when you add the JLabel to use it from Swing Controls not AWT.
来源:https://stackoverflow.com/questions/15400371/adding-images-on-java-jframe-netbeans
