import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;/****
 * 全局变量:JFrame,JPanel,JButton,JTextField,JLabel
 * 
 * @author GYYue
 * 
 */
public class AnotherLayout implements ActionListener {
private static JFrame frame;
private static JTextField jtxtID = new JTextField(10);
private static JLabel label = new JLabel("ID:"), labelMenu = new JLabel(
"点菜列表:");
// private static JScrollPane sp = new JScrollPane();
private static JTextArea jtxtMenu = new JTextArea(40, 30);
// private static Container Cmenu = new Container();
private static JPanel panel = new JPanel(), panel2 = new JPanel();
private static JButton btnNO, btnComfir = new JButton(""),//确定
btnCancel = new JButton(""); //清除


public void fun() {
frame = new JFrame("点菜系统");
frame.setSize(450, 550);
frame.setLocation(400, 79);
frame.setBackground(Color.WHITE);
frame.setVisible(true);
frame.setResizable(false);
frame.add(panel);
    panel.setLayout(null);
// panel.setBackground(Color.BLUE);
jtxtID.setBounds(60, 5, 250, 30);
label.setFont(new Font("华文细黑", Font.PLAIN, 25));
label.setBounds(25, 5, 50, 30);
// label.setBackground(Color.WHITE);
labelMenu.setFont(new Font("华文细黑", Font.PLAIN, 18));
labelMenu.setBounds(25, 55, 100, 30);


        panel.add(jtxtID);
panel.add(label);
panel.add(labelMenu);

jtxtMenu.setBounds(25, 80, 385, 200);
// sp.setBackground(Color.WHITE);
// sp.setBounds(25, 45, 285, 200);
panel.add(jtxtMenu); panel2.setBounds(15, 300, 408, 196);
panel2.setBackground(Color.WHITE);
panel2.setLayout(new GridLayout(4, 3));
for (int i = 0; i < 10; i++) {
if (i < 10) {
btnNO = new JButton("" + i);
btnNO.addActionListener(this);
panel2.add(btnNO);
}
}
panel.add(panel2);
btnComfir.setBounds(151, 447, 136, 49);
btnComfir.addActionListener(this);
btnCancel.setBounds(1187, 447, 136, 49);
btnCancel.addActionListener(this);
panel2.add(btnComfir);
panel2.add(btnCancel);
}

public static void main(String[] args) {
AnotherLayout another = new AnotherLayout();
another.fun();
} @Override
public void actionPerformed(ActionEvent e) {
jtxtID.setText(jtxtID.getText() + e.getActionCommand());
//查询数据库中的菜的ID号


//清空jtxtID的内容
btnCancel.addActionListener(new ActionListener(){ @Override
public void actionPerformed(ActionEvent e) {
jtxtID.setText("");
jtxtMenu.setText("");
}

});
}

}