/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package pbl2;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JFrame;
public class Main
{
public static void main(String[] args) {
JFrame f = new JFrame("WELCOME TO ULEQ MAYANG CAFE");
f.setSize(1200, 500);
f.setLocation(0, 0);
f.addWindowListener(new WindowAdapter(){
@Override
public void windowClosing(WindowEvent we){System.exit(0);}
});
JPanel entreePanel = new JPanel();
final ButtonGroup entreeGroup = new ButtonGroup();
JRadioButton radioButton;
System.out.print("Please Select Your Food : \n\n");
entreePanel.add(radioButton = new JRadioButton("Uleq Fried Chicken(2 Pieces) = RM6.00"));
radioButton.setActionCommand("Uleq Fried Chicken(2 Pieces) = RM6.00");
entreeGroup.add(radioButton);
entreePanel.add(radioButton = new JRadioButton("Uleq Fried Chicken(5Pieces) = RM15.00"));
radioButton.setActionCommand("Uleq Fried Chicken(5Pieces) = RM15.00");
entreeGroup.add(radioButton);
entreePanel.add(radioButton = new JRadioButton("Panera Bread = RM3.00"));
radioButton.setActionCommand("Panera Bread = RM3.00");
entreeGroup.add(radioButton);
entreePanel.add(radioButton = new JRadioButton("Hoka Hoka Bento = RM4.50"));
radioButton.setActionCommand("Hoka Hoka Bento = RM4.50");
entreePanel.add(radioButton = new JRadioButton("Special Uleq Burger = RM6.00"));
radioButton.setActionCommand("Special Uleq Burger = RM6.00");
entreeGroup.add(radioButton);
final JPanel condimentsPanel = new JPanel();
condimentsPanel.add(new JCheckBox("Orange Pulpy = RM3.80"));
condimentsPanel.add(new JCheckBox("Coca Cola = RM2.50"));
condimentsPanel.add(new JCheckBox("Pepsi = RM2.50"));
condimentsPanel.add(new JCheckBox("Mineral Water = RM1.00"));
condimentsPanel.add(new JCheckBox("Special Uleq Latte = RM3.50"));
condimentsPanel.add(new JCheckBox("Ribena = RM2.00"));
condimentsPanel.add(new JCheckBox("Mango Juice = RM3.00"));
JPanel orderPanel = new JPanel();
JButton orderButton = new JButton("THANK YOU FOR PURCHASING AT ULEQ MAYANG CAFE,PLEASE CLICK AND WE WILL PROCEED YOUR ORDER");
orderPanel.add(orderButton);
Container content = f.getContentPane();
content.setLayout(new GridLayout(3, 1));
content.add(entreePanel);
content.add(condimentsPanel);
content.add(orderPanel);
orderButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
String entree =
entreeGroup.getSelection().getActionCommand();
System.out.println(entree + " ");
Component[] components = condimentsPanel.getComponents();
for (int i = 0; i < components.length; i++) {
JCheckBox cb = (JCheckBox)components[i];
if (cb.isSelected())
System.out.println("Drinks order:" + cb.getText());
}
}
});
f.setVisible(true);
}
}
가 // ** 것이 나에게 도움이 대신 창 패널의 넷빈즈에 표시 !!!! * // 내가 가격을 계산 싶어하지만 난 잘 모릅니다 .. 자바에 대한 메신저 바보 .. 그리고 "음식 주문"과 "음료 주문"은 창에 표시되지 않지만 그물 콩의 출력에 표시됩니다.계산할 수없고 출력이
가 어디 붙어 있는지? 너 혼란스러워? –