简体   繁体   中英

Adding images on Java JFrame - Netbeans

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.

  1. Open the form in NetBeans form editor.
  2. Add a JLabel from the pallete to the form
  3. Select the label you just added and click the "..." button next to the icon property
  4. Fill out the properties.

It's normally best that the images reside within the project folder, makes deployment easier in the long run.

  1. Copy Image to your Netbeans project.
  2. Add new label to the frame.
  3. Select the label and Right click->Go to Properties.
  4. In Icon property select image by down arrow as shown in image.

在此处输入图片说明

确保在添加JLabel时从Swing控件而不是AWT中使用它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM