- package bbs.istak.org.tw;
- import java.awt.BorderLayout;
- import java.awt.EventQueue;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.border.EmptyBorder;
- import javax.swing.JLabel;
- import javax.swing.SwingConstants;
- import javax.swing.JTextField;
- import javax.swing.JButton;
- import javax.swing.ImageIcon;
- import java.awt.Toolkit;
- import java.awt.event.MouseAdapter;
- import java.awt.event.MouseEvent;
- public class Main extends JFrame {
- private JPanel contentPane;
- private JTextField Food1Num;
- private JTextField Food2Num;
- private JTextField Food3Num;
- private JTextField Food4Num;
- private JTextField food1lc;
- private JTextField food2lc;
- private JTextField food3lc;
- private JTextField food4lc;
- private JTextField AllMoney;
- private JTextField Pay;
- private JTextField Change;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- Main frame = new Main();
- frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the frame.
- */
- public Main() {
- setTitle("\u5712\u904A\u6703\u5C0F\u5E6B\u624B");
- setIconImage(Toolkit.getDefaultToolkit().getImage(Main.class.getResource("/bbs/istak/org/tw/icon.png")));
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(100, 100, 567, 343);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
- JLabel NameLb = new JLabel("\u54C1\u540D");
- NameLb.setBounds(46, 10, 46, 15);
- contentPane.add(NameLb);
- JLabel MoneyLb = new JLabel("\u55AE\u50F9");
- MoneyLb.setBounds(126, 10, 46, 15);
- contentPane.add(MoneyLb);
- JLabel NumLb = new JLabel("\u6578\u91CF");
- NumLb.setBounds(201, 10, 57, 15);
- contentPane.add(NumLb);
- JLabel UDLb = new JLabel("\u589E / \u6E1B");
- UDLb.setBounds(312, 10, 67, 15);
- contentPane.add(UDLb);
- JLabel LcLb = new JLabel("\u5C0F\u8A08");
- LcLb.setBounds(443, 10, 46, 15);
- contentPane.add(LcLb);
- AllMoney = new JTextField();
- AllMoney.setEditable(false);
- AllMoney.setText("0");
- AllMoney.setHorizontalAlignment(SwingConstants.RIGHT);
- AllMoney.setColumns(10);
- AllMoney.setBounds(83, 169, 149, 29);
- contentPane.add(AllMoney);
- int All = Integer.valueOf(AllMoney.getText());
- JLabel AllMoney = new JLabel("\u7E3D\u91D1\u984D");
- AllMoney.setBounds(23, 176, 46, 15);
- contentPane.add(AllMoney);
- JLabel PayLb = new JLabel("\u6536");
- PayLb.setBounds(23, 218, 46, 15);
- contentPane.add(PayLb);
- Pay = new JTextField();
- Pay.setText("0");
- Pay.setHorizontalAlignment(SwingConstants.RIGHT);
- Pay.setColumns(10);
- Pay.setBounds(83, 211, 149, 29);
- contentPane.add(Pay);
- Change = new JTextField();
- Change.setText("0");
- Change.setHorizontalAlignment(SwingConstants.RIGHT);
- Change.setEditable(false);
- Change.setColumns(10);
- Change.setBounds(80, 261, 152, 29);
- contentPane.add(Change);
- JLabel ChangeLb = new JLabel("\u627E");
- ChangeLb.setBounds(23, 268, 46, 15);
- contentPane.add(ChangeLb);
- JButton Count = new JButton("");
- Count.setIcon(new ImageIcon(Main.class.getResource("/bbs/istak/org/tw/checkout.png")));
- Count.setBounds(276, 176, 114, 107);
- contentPane.add(Count);
- JButton Clear = new JButton("");
- Clear.setIcon(new ImageIcon(Main.class.getResource("/bbs/istak/org/tw/clear.png")));
- Clear.setBounds(404, 176, 114, 107);
- contentPane.add(Clear);
- JPanel FoodListPanel = new JPanel();
- FoodListPanel.setBounds(23, 32, 495, 124);
- contentPane.add(FoodListPanel);
- FoodListPanel.setLayout(null);
- JLabel food1Lb = new JLabel("QQ\u86CB");
- food1Lb.setBounds(14, 8, 89, 15);
- FoodListPanel.add(food1Lb);
- JLabel food2Lb = new JLabel("\u78B3\u70E4\u4E09\u660E\u6CBB");
- food2Lb.setBounds(14, 36, 89, 15);
- FoodListPanel.add(food2Lb);
- JLabel food3Lb = new JLabel("\u73CD\u73E0\u5976\u8336");
- food3Lb.setBounds(14, 66, 89, 15);
- FoodListPanel.add(food3Lb);
- JLabel food4Lb = new JLabel("\u5F48\u73E0\u6C7D\u6C34");
- food4Lb.setBounds(14, 94, 89, 15);
- FoodListPanel.add(food4Lb);
- JLabel Food1MoneyLb = new JLabel("22\u5143");
- Food1MoneyLb.setBounds(103, 8, 46, 15);
- FoodListPanel.add(Food1MoneyLb);
- Food1MoneyLb.setHorizontalAlignment(SwingConstants.LEFT);
- JLabel Food2MoneyLb = new JLabel("49\u5143");
- Food2MoneyLb.setBounds(103, 36, 46, 15);
- FoodListPanel.add(Food2MoneyLb);
- JLabel Food3MoneyLb = new JLabel("29\u5143");
- Food3MoneyLb.setBounds(103, 66, 46, 15);
- FoodListPanel.add(Food3MoneyLb);
- JLabel Food4MoneyLb = new JLabel("12\u5143");
- Food4MoneyLb.setBounds(103, 94, 46, 15);
- FoodListPanel.add(Food4MoneyLb);
- Food1Num = new JTextField();
- Food1Num.setBounds(163, 6, 73, 19);
- FoodListPanel.add(Food1Num);
- Food1Num.setEditable(false);
- Food1Num.setHorizontalAlignment(SwingConstants.RIGHT);
- Food1Num.setText("0");
- Food1Num.setColumns(10);
- Food2Num = new JTextField();
- Food2Num.setBounds(163, 34, 73, 19);
- FoodListPanel.add(Food2Num);
- Food2Num.setEditable(false);
- Food2Num.setText("0");
- Food2Num.setHorizontalAlignment(SwingConstants.RIGHT);
- Food2Num.setColumns(10);
- Food3Num = new JTextField();
- Food3Num.setBounds(163, 64, 73, 19);
- FoodListPanel.add(Food3Num);
- Food3Num.setEditable(false);
- Food3Num.setText("0");
- Food3Num.setHorizontalAlignment(SwingConstants.RIGHT);
- Food3Num.setColumns(10);
- Food4Num = new JTextField();
- Food4Num.setBounds(163, 92, 73, 19);
- FoodListPanel.add(Food4Num);
- Food4Num.setEditable(false);
- Food4Num.setText("0");
- Food4Num.setHorizontalAlignment(SwingConstants.RIGHT);
- Food4Num.setColumns(10);
- JButton food1up = new JButton("+");
- food1up.setBounds(250, 4, 56, 23);
- FoodListPanel.add(food1up);
- JButton food1down = new JButton("-");
- food1down.setBounds(320, 4, 58, 23);
- FoodListPanel.add(food1down);
- JButton food2up = new JButton("+");
- food2up.setBounds(250, 32, 56, 23);
- FoodListPanel.add(food2up);
- JButton food2down = new JButton("-");
- food2down.setBounds(320, 32, 58, 23);
- FoodListPanel.add(food2down);
- JButton food3up = new JButton("+");
- food3up.setBounds(250, 62, 56, 23);
- FoodListPanel.add(food3up);
- JButton food3down = new JButton("-");
- food3down.setBounds(320, 62, 58, 23);
- FoodListPanel.add(food3down);
- JButton food4up = new JButton("+");
- food4up.setBounds(250, 90, 56, 23);
- FoodListPanel.add(food4up);
- JButton food4down = new JButton("-");
- food4down.setBounds(320, 90, 58, 23);
- FoodListPanel.add(food4down);
- food1lc = new JTextField();
- food1lc.setBounds(392, 6, 73, 19);
- FoodListPanel.add(food1lc);
- food1lc.setEditable(false);
- food1lc.setText("0");
- food1lc.setHorizontalAlignment(SwingConstants.RIGHT);
- food1lc.setColumns(10);
- food2lc = new JTextField();
- food2lc.setBounds(392, 34, 73, 19);
- FoodListPanel.add(food2lc);
- food2lc.setEditable(false);
- food2lc.setText("0");
- food2lc.setHorizontalAlignment(SwingConstants.RIGHT);
- food2lc.setColumns(10);
- food3lc = new JTextField();
- food3lc.setBounds(392, 64, 73, 19);
- FoodListPanel.add(food3lc);
- food3lc.setEditable(false);
- food3lc.setText("0");
- food3lc.setHorizontalAlignment(SwingConstants.RIGHT);
- food3lc.setColumns(10);
- food4lc = new JTextField();
- food4lc.setBounds(392, 92, 73, 19);
- FoodListPanel.add(food4lc);
- food4lc.setEditable(false);
- food4lc.setText("0");
- food4lc.setHorizontalAlignment(SwingConstants.RIGHT);
- food4lc.setColumns(10);
- }
複製代碼 |