Sorry to bother everyone yet again but I have a problem that is really annoying me. Our teacher wants us to make a calculator, which I have done, and wants us to put as many different features into it as possible. As a suggestion he said we should have an "About" thing with stuff like Version Number, Creator, etc and a picture. Now I am trying to use a JLabel as an icon, which apparently you can do with its constructor "JLabel(Icon image)", I have looked all over for how you acomplish this but I have had no luck.
Short version: How do you put an image into your java app?
My code if it will help:
package mycalculator;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class AboutForm extends JFrame implements ActionListener{
public AboutForm(){
super("About");
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setSize(300, 300);
Font f = new Font("Trebuchet MS", Font.PLAIN, 13);
Font f2 = new Font("Trebuchet MS", Font.BOLD, 16);
this.setFont(f);
BorderLayout b1 = new BorderLayout();
GridLayout g = new GridLayout(4, 1);
JButton btn1 = new JButton("CLICK HERE");
btn1.setFont(f);
JButton btn2 = new JButton("CLICK HERE ALSO");
JPanel panel = new JPanel();
JLabel lbl = new JLabel();
JLabel lbl2 = new JLabel();
ImageIcon icon = new ImageIcon("images/b.gif");
JLabel lblImg = new JLabel(icon);
panel.setSize(100,100);
panel.setLayout(g);
panel.add(lblImg);
panel.add(lbl2);
this.getContentPane().add(panel, BorderLayout.CENTER);
}
I have my image in a folder in NetBeansProjects\myCalculator\src\mycalculator\images, is this the right place to put it?
Any help is greatly appreciated.