So, I wanna display a little image of a register at the top of each column to display a checkout line. I can't seem to get the Icon to show. What's wrong here? I've followed the example in my book and the icon won't show up at all.
I'm using eclipse and I put the icon in the same directory as the .java files which is the src folder under the project name inside the workspace folder.
So here is my view so far:
import java.awt.Component; import java.awt.Container; import java.awt.GridLayout; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class StoreView extends JFrame{ private JPanel topPanel; private JPanel checkoutPanel; private JButton createCustomer; // private JPanel checkoutPanel = new JPanel(); private JLabel totalServiceTime; private ImageIcon registerIcon; private JLabel iconLabel; // private FlowLayout flow = new FlowLayout(); private StoreModel model; public StoreView(StoreModel model){ this.model = model; setTitle("Checkout Simulator"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new GridLayout()); buildTopPanel(); buildCheckoutPanel(); add(topPanel); add(checkoutPanel); pack(); setVisible(true); } public void buildTopPanel(){ topPanel = new JPanel(); createCustomer = new JButton("CreateCustomer"); topPanel.add(createCustomer); } public void buildCheckoutPanel(){ checkoutPanel = new JPanel(); iconLabel = new JLabel(); registerIcon = new ImageIcon("register.png"); iconLabel.setIcon(registerIcon); checkoutPanel.add(iconLabel); } }