返回列表 發帖
  1. package bbs.istak.org.tw;

  2. import java.awt.BorderLayout;
  3. import java.awt.EventQueue;

  4. import javax.swing.JFrame;
  5. import javax.swing.JPanel;
  6. import javax.swing.border.EmptyBorder;
  7. import javax.swing.JLabel;
  8. import javax.swing.SwingConstants;
  9. import javax.swing.JTextField;
  10. import javax.swing.JButton;
  11. import javax.swing.ImageIcon;

  12. import java.awt.Toolkit;
  13. import java.awt.event.MouseAdapter;
  14. import java.awt.event.MouseEvent;

  15. public class Main extends JFrame {

  16.         private JPanel contentPane;
  17.         private JTextField Food1Num;
  18.         private JTextField Food2Num;
  19.         private JTextField Food3Num;
  20.         private JTextField Food4Num;
  21.         private JTextField food1lc;
  22.         private JTextField food2lc;
  23.         private JTextField food3lc;
  24.         private JTextField food4lc;
  25.         private JTextField AllMoney;
  26.         private JTextField Pay;
  27.         private JTextField Change;

  28.         /**
  29.          * Launch the application.
  30.          */
  31.          public static void main(String[] args) {
  32.                  EventQueue.invokeLater(new Runnable() {
  33.                          public void run() {
  34.                                  try {
  35.                                          Main frame = new Main();
  36.                                          frame.setVisible(true);
  37.                                  } catch (Exception e) {
  38.                                          e.printStackTrace();
  39.                                  }
  40.                          }
  41.                  });
  42.          }

  43.          /**
  44.           * Create the frame.
  45.           */
  46.          public Main() {
  47.                  setTitle("\u5712\u904A\u6703\u5C0F\u5E6B\u624B");
  48.                  setIconImage(Toolkit.getDefaultToolkit().getImage(Main.class.getResource("/bbs/istak/org/tw/icon.png")));
  49.                  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  50.                  setBounds(100, 100, 567, 343);
  51.                  contentPane = new JPanel();
  52.                  contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  53.                  setContentPane(contentPane);
  54.                  contentPane.setLayout(null);

  55.                  JLabel NameLb = new JLabel("\u54C1\u540D");
  56.                  NameLb.setBounds(46, 10, 46, 15);
  57.                  contentPane.add(NameLb);

  58.                  JLabel MoneyLb = new JLabel("\u55AE\u50F9");
  59.                  MoneyLb.setBounds(126, 10, 46, 15);
  60.                  contentPane.add(MoneyLb);

  61.                  JLabel NumLb = new JLabel("\u6578\u91CF");
  62.                  NumLb.setBounds(201, 10, 57, 15);
  63.                  contentPane.add(NumLb);

  64.                  JLabel UDLb = new JLabel("\u589E  /  \u6E1B");
  65.                  UDLb.setBounds(312, 10, 67, 15);
  66.                  contentPane.add(UDLb);

  67.                  JLabel LcLb = new JLabel("\u5C0F\u8A08");
  68.                  LcLb.setBounds(443, 10, 46, 15);
  69.                  contentPane.add(LcLb);

  70.                  AllMoney = new JTextField();
  71.                  AllMoney.setEditable(false);
  72.                  AllMoney.setText("0");
  73.                  AllMoney.setHorizontalAlignment(SwingConstants.RIGHT);
  74.                  AllMoney.setColumns(10);
  75.                  AllMoney.setBounds(83, 169, 149, 29);
  76.                  contentPane.add(AllMoney);

  77.                  int All = Integer.valueOf(AllMoney.getText());

  78.                  JLabel AllMoney = new JLabel("\u7E3D\u91D1\u984D");
  79.                  AllMoney.setBounds(23, 176, 46, 15);
  80.                  contentPane.add(AllMoney);

  81.                  JLabel PayLb = new JLabel("\u6536");
  82.                  PayLb.setBounds(23, 218, 46, 15);
  83.                  contentPane.add(PayLb);

  84.                  Pay = new JTextField();
  85.                  Pay.setText("0");
  86.                  Pay.setHorizontalAlignment(SwingConstants.RIGHT);
  87.                  Pay.setColumns(10);
  88.                  Pay.setBounds(83, 211, 149, 29);
  89.                  contentPane.add(Pay);

  90.                  Change = new JTextField();
  91.                  Change.setText("0");
  92.                  Change.setHorizontalAlignment(SwingConstants.RIGHT);
  93.                  Change.setEditable(false);
  94.                  Change.setColumns(10);
  95.                  Change.setBounds(80, 261, 152, 29);
  96.                  contentPane.add(Change);

  97.                  JLabel ChangeLb = new JLabel("\u627E");
  98.                  ChangeLb.setBounds(23, 268, 46, 15);
  99.                  contentPane.add(ChangeLb);

  100.                  JButton Count = new JButton("");
  101.                  Count.setIcon(new ImageIcon(Main.class.getResource("/bbs/istak/org/tw/checkout.png")));
  102.                  Count.setBounds(276, 176, 114, 107);
  103.                  contentPane.add(Count);

  104.                  JButton Clear = new JButton("");
  105.                  Clear.setIcon(new ImageIcon(Main.class.getResource("/bbs/istak/org/tw/clear.png")));
  106.                  Clear.setBounds(404, 176, 114, 107);
  107.                  contentPane.add(Clear);

  108.                  JPanel FoodListPanel = new JPanel();
  109.                  FoodListPanel.setBounds(23, 32, 495, 124);
  110.                  contentPane.add(FoodListPanel);
  111.                  FoodListPanel.setLayout(null);

  112.                  JLabel food1Lb = new JLabel("QQ\u86CB");
  113.                  food1Lb.setBounds(14, 8, 89, 15);
  114.                  FoodListPanel.add(food1Lb);

  115.                  JLabel food2Lb = new JLabel("\u78B3\u70E4\u4E09\u660E\u6CBB");
  116.                  food2Lb.setBounds(14, 36, 89, 15);
  117.                  FoodListPanel.add(food2Lb);

  118.                  JLabel food3Lb = new JLabel("\u73CD\u73E0\u5976\u8336");
  119.                  food3Lb.setBounds(14, 66, 89, 15);
  120.                  FoodListPanel.add(food3Lb);

  121.                  JLabel food4Lb = new JLabel("\u5F48\u73E0\u6C7D\u6C34");
  122.                  food4Lb.setBounds(14, 94, 89, 15);
  123.                  FoodListPanel.add(food4Lb);

  124.                  JLabel Food1MoneyLb = new JLabel("22\u5143");
  125.                  Food1MoneyLb.setBounds(103, 8, 46, 15);
  126.                  FoodListPanel.add(Food1MoneyLb);
  127.                  Food1MoneyLb.setHorizontalAlignment(SwingConstants.LEFT);

  128.                  JLabel Food2MoneyLb = new JLabel("49\u5143");
  129.                  Food2MoneyLb.setBounds(103, 36, 46, 15);
  130.                  FoodListPanel.add(Food2MoneyLb);

  131.                  JLabel Food3MoneyLb = new JLabel("29\u5143");
  132.                  Food3MoneyLb.setBounds(103, 66, 46, 15);
  133.                  FoodListPanel.add(Food3MoneyLb);

  134.                  JLabel Food4MoneyLb = new JLabel("12\u5143");
  135.                  Food4MoneyLb.setBounds(103, 94, 46, 15);
  136.                  FoodListPanel.add(Food4MoneyLb);

  137.                  Food1Num = new JTextField();
  138.                  Food1Num.setBounds(163, 6, 73, 19);
  139.                  FoodListPanel.add(Food1Num);
  140.                  Food1Num.setEditable(false);
  141.                  Food1Num.setHorizontalAlignment(SwingConstants.RIGHT);
  142.                  Food1Num.setText("0");
  143.                  Food1Num.setColumns(10);

  144.                  Food2Num = new JTextField();
  145.                  Food2Num.setBounds(163, 34, 73, 19);
  146.                  FoodListPanel.add(Food2Num);
  147.                  Food2Num.setEditable(false);
  148.                  Food2Num.setText("0");
  149.                  Food2Num.setHorizontalAlignment(SwingConstants.RIGHT);
  150.                  Food2Num.setColumns(10);

  151.                  Food3Num = new JTextField();
  152.                  Food3Num.setBounds(163, 64, 73, 19);
  153.                  FoodListPanel.add(Food3Num);
  154.                  Food3Num.setEditable(false);
  155.                  Food3Num.setText("0");
  156.                  Food3Num.setHorizontalAlignment(SwingConstants.RIGHT);
  157.                  Food3Num.setColumns(10);

  158.                  Food4Num = new JTextField();
  159.                  Food4Num.setBounds(163, 92, 73, 19);
  160.                  FoodListPanel.add(Food4Num);
  161.                  Food4Num.setEditable(false);
  162.                  Food4Num.setText("0");
  163.                  Food4Num.setHorizontalAlignment(SwingConstants.RIGHT);
  164.                  Food4Num.setColumns(10);

  165.                  JButton food1up = new JButton("+");
  166.                  food1up.setBounds(250, 4, 56, 23);
  167.                  FoodListPanel.add(food1up);

  168.                  JButton food1down = new JButton("-");
  169.                  food1down.setBounds(320, 4, 58, 23);
  170.                  FoodListPanel.add(food1down);


  171.                  JButton food2up = new JButton("+");
  172.                  food2up.setBounds(250, 32, 56, 23);
  173.                  FoodListPanel.add(food2up);

  174.                  JButton food2down = new JButton("-");
  175.                  food2down.setBounds(320, 32, 58, 23);
  176.                  FoodListPanel.add(food2down);

  177.                  JButton food3up = new JButton("+");
  178.                  food3up.setBounds(250, 62, 56, 23);
  179.                  FoodListPanel.add(food3up);

  180.                  JButton food3down = new JButton("-");
  181.                  food3down.setBounds(320, 62, 58, 23);
  182.                  FoodListPanel.add(food3down);

  183.                  JButton food4up = new JButton("+");
  184.                  food4up.setBounds(250, 90, 56, 23);
  185.                  FoodListPanel.add(food4up);

  186.                  JButton food4down = new JButton("-");
  187.                  food4down.setBounds(320, 90, 58, 23);
  188.                  FoodListPanel.add(food4down);

  189.                  food1lc = new JTextField();
  190.                  food1lc.setBounds(392, 6, 73, 19);
  191.                  FoodListPanel.add(food1lc);
  192.                  food1lc.setEditable(false);
  193.                  food1lc.setText("0");
  194.                  food1lc.setHorizontalAlignment(SwingConstants.RIGHT);
  195.                  food1lc.setColumns(10);

  196.                  food2lc = new JTextField();
  197.                  food2lc.setBounds(392, 34, 73, 19);
  198.                  FoodListPanel.add(food2lc);
  199.                  food2lc.setEditable(false);
  200.                  food2lc.setText("0");
  201.                  food2lc.setHorizontalAlignment(SwingConstants.RIGHT);
  202.                  food2lc.setColumns(10);

  203.                  food3lc = new JTextField();
  204.                  food3lc.setBounds(392, 64, 73, 19);
  205.                  FoodListPanel.add(food3lc);
  206.                  food3lc.setEditable(false);
  207.                  food3lc.setText("0");
  208.                  food3lc.setHorizontalAlignment(SwingConstants.RIGHT);
  209.                  food3lc.setColumns(10);

  210.                  food4lc = new JTextField();
  211.                  food4lc.setBounds(392, 92, 73, 19);
  212.                  FoodListPanel.add(food4lc);
  213.                  food4lc.setEditable(false);
  214.                  food4lc.setText("0");
  215.                  food4lc.setHorizontalAlignment(SwingConstants.RIGHT);
  216.                  food4lc.setColumns(10);
  217.          }
複製代碼

TOP

返回列表