Here's the part of the program:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Test extends JFrame implements ActionListener
{
static String[] yourChoicesItems =
{"Blueberry Muffin 1.45",
"Strawberry Bagel 0.80",
"Lite Yogurt 0.75",
"Vannila Ice Cream 2.75",
"Hash Browns 2.50",
"Toast 2.00",
"French Fries 1.50",
"Onion Soup 3.00",
"Coffee 0.90",
"Iced Tea 1.00",
"Hot Chocolate 1.75"};
static double[] yourChoicesPrices = {1.45, 0.80, 0.75, 2.75,
2.50, 2.00, 1.50, 3.00,
0.90, 1.00, 1.75};
private JList<String> yourChoices;
private JTextArea bill;
private JFrame myFrame;
private JPanel pane1;
private JPanel pane2;
public Test()
{
super("Welcome to Java Kiosk");
myFrame.setLayout(new GridLayout(2,1));
myFrame.setBackground(new Color(0, 200, 200));
pane1.setLayout(new BorderLayout(5, 5));
pane2.setLayout(new GridLayout(2,1));
JLabel yourChoicesJLabel = new JLabel("MENU");
pane1.add(yourChoicesJLabel, BorderLayout.NORTH);
yourChoicesJLabel.setFont(new Font("Dialog",Font.BOLD,20));
yourChoices = new JList<>(yourChoicesItems);
pane1.add(new JScrollPane(yourChoices), BorderLayout.WEST);
yourChoices.setFont(new Font("Courier",Font.BOLD+Font.ITALIC,14));
bill = new JTextArea();
pane1.add(bill, BorderLayout.EAST);
bill.setFont(new Font("Courier",Font.PLAIN,12));
JButton button1 = new JButton("Selection Completed");
pane1.add(button1, BorderLayout.SOUTH);
button1.addActionListener(this);
JButton button2 = new JButton("Add");
pane2.add(button2);
button2.addActionListener(this);
JButton button3 = new JButton("Delete");
pane2.add(button3);
button3.addActionListener(this);
myFrame.add(pane1);
myFrame.add(pane2);
setSize(500, 360);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}

New Topic/Question
Reply



MultiQuote




|