can't do this.. can anyone check it out pleaseeee? thank you =)
import javax.swing.*;
import java.awt.event.*;
publicclass Cookingimplements ActionListener{
JFrame frame;
JPanel contentPane;
JLabel label;
JButton button;
public Cooking(){
frame =new JFrame("Cooking");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPane =new JPanel();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
contentPane.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
button =new JButton(new ImageIcon("spaghetti.jpg"));
button.setAlignmentX(JButton.LEFT_ALIGNMENT);
button.addActionListener(this);
contentPane.add(button);
label =new JLabel(" ");
label.setAlignmentX(JLabel.LEFT_ALIGNMENT);
label.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
contentPane.add(label);
frame.setContentPane(contentPane);
frame.pack();
frame.setVisible(true);
}
publicvoid actionPerformed(ActionEvent event){
String eventName = event.getActionCommand();
if (eventName.equals("spaghetti.jpg")){
label.setText("Recipe: (for 10 servings)");
label.setText("500 g of magaroni, 100 g of garlic, 500 g of chopped chicken, 250 g of tomato sauce, 1 kg of tomatoes, 250 g of onions, 500 g of mushroom, 100 g of olive oil, 50 g of butter");
}
}
privatestaticvoid runGUI(){
JFrame.setDefaultLookAndFeelDecorated(true);
Cooking food =new Cooking();
}
publicstaticvoid main(String[] args){
javax.swing.SwingUtilities.invokeLater(new Runnable(){
publicvoid run(){
runGUI();
}
});
}
}

