Java Reference
In-Depth Information
public AlaCarte()
{
super ("Welcome to Java Kiosk");
//Get the content pane and set its background color
//and layout manager.
pane = getContentPane();
pane.setBackground( new Color(0, 200, 200));
pane.setLayout( new BorderLayout(5, 5));
//Create a label and place it at NORTH. Also
//set the font of this label.
JLabel yourChoicesJLabel = new JLabel("A LA CARTE MENU");
pane.add(yourChoicesJLabel,BorderLayout.NORTH);
yourChoicesJLabel.setFont( new Font("Dialog",Font.BOLD,20));
//Create a list and place it at WEST. Also
//set the font of this list.
yourChoices = new JList(yourChoicesItems);
pane.add( new JScrollPane (yourChoices),BorderLayout.WEST);
yourChoices.setFont( new Font("Courier",Font.BOLD,14));
//Create a text area and place it at EAST. Also
//set the font of this text area.
bill = new JTextArea();
pane.add(bill,BorderLayout.EAST);
bill.setFont( new Font("Courier",Font.PLAIN,12));
//Create a button and place it in the SOUTH region
//and add an action listener.
JButton button = new JButton("Selection Completed");
pane.add(button,BorderLayout.SOUTH);
button.addActionListener( this );
setSize(500, 360);
setVisible( true );
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
1
2
//method to display the order and the total cost
private void displayBill()
{
int [] listArray = yourChoices.getSelectedIndices();
double localTax = 0.065;
double tax;
double subTotal = 0;
double total;
//Set the text area to nonedit mode and start
//with an empty string.
bill.setEditable( false );
bill.setText("");
Search WWH ::




Custom Search