I want to load an image for each different shoe and I'm using JLabel to help me do this.
I put the image's path in the JLabel constructor but when the code runs, it doesn't display any image. Instead of an image, the image path is written.
appreciate any help and suggestion
package badmintonstore;
/**
*
* @author TaimooR
*/
import java.awt.GridLayout;
import javax.swing.*;
/*
* The class displays shoes
*/
public class Shoes extends JPanel
{
//Class Fields
private JLabel icon;
private JLabel price;
private JTextField qtyInput;
private double priceS = 0.0;
public Shoes (String showPrice,String path)
{
setLayout(new GridLayout(2,2));
// Constructing shoes
icon = new JLabel(path);
price = new JLabel(showPrice);
qtyInput = new JTextField(2);
priceS = Double.valueOf(showPrice);
add(icon);
add(price);
add(qtyInput);
}
/*
* Method getShowPrice
* Return the price of the shows
*/
public double getShoePrice()
{
double finalShoePrice;
double quantity = Double.valueOf(qtyInput.getText());
finalShoePrice = quantity*priceS;
return finalShoePrice;
}
}