《酒店管理系统实现代码》由会员分享,可在线阅读,更多相关《酒店管理系统实现代码(59页珍藏版)》请在金锄头文库上搜索。
1、入住import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.Border;import javax.swing.text.*;public class A1 extends JFrame implements WindowListener /定义各个组件JFrame frame = new JFrame (入住系统);JLabel nameLabel = new JLabel(客户);JLabel idtifyLabel = new JLabel(号);JLabel roo
2、mLabel = new JLabel(入住房号);JLabel moneyLabel = new JLabel(应付金额);JTextField nameField = new JTextField();JTextField idtifyField= new JTextField();JTextField roomField= new JTextField();JTextField moneyField= new JTextField();JButton button1,button2;/*public static void main(String args)A1 a1 = new A1(
3、);a1.go();*/public void go()UpperCaseDocument ucDocument = new UpperCaseDocument(); nameField.setDocument(ucDocument);nameField.setForeground(Color.black);/frame.addWindowListener(this);nameField.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) String username = name
4、Field.getText(););JComboBox jcbl;/组合框String口 itemList = 现金,刷卡; jcbl = new JComboBox(itemList); jcb1.setSelectedIndex(0);button1=new JButton(确认支付); button2=new JButton(取消支付); final JPanel p1 = new JPanel(); p1.add(jcb1);p1.add(button1);p1.add(button2);p1.setLayout(new GridLayout(3,1);Border etched =
5、BorderFactory.createEtchedBorder();Border border = BorderFactory.createTitledBorder(etched, 付款方式 );p1.setBorder(border);button1.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) if (e.getActionCommand()二二确认支付) JOptionPane.showMessageDialog(p1, 支付成功success,JOptionPane.
6、INFORMATION_MESSAGE); );button2.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) if (e.getActionCommand()二二取消支付) JOptionPane.showMessageDialog(p1,支付失败,failure,JOptionPane.INFORMATION_MESSAGE); );idtifyField.addActionListener(new ActionListener() public void actionPer
7、formed(ActionEvent e) String idtify= idtifyField.getText();String idtifyword= new String(idtify););roomField.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) String room= roomField.getText();String roomword= new String(room););moneyField.addActionListener(new ActionL
8、istener() public void actionPerformed(ActionEvent e) String money= moneyField.getText();String idtifyword= new String(money););/面板labelPanel放标签JPanel labelPanel = new JPanel();labelPanel.setLayout(new GridLayout(4,1); labelPanel.add(nameLabel);labelPanel.add(idtifyLabel);labelPanel.add(roomLabel);la
9、belPanel.add(moneyLabel);/面板fieldPanel放文本框JPanel fieldPanel = new JPanel();fieldPanel.setLayout(new GridLayout(4,1);fieldPanel.add(nameField);fieldPanel.add(idtifyField);fieldPanel.add(roomField);fieldPanel.add( moneyField);/面板 northPanel 放面板 lanelPanel 和面板 fieldPanel JPanel northPanel = new JPanel(
10、);northPanel.setLayout(new GridLayout(1,2);northPanel.add(labelPanel);northPanel.add(fieldPanel);Container cp = frame.getContentPane();cp.add(northPanel,BorderLayout.NORTH);/northPanel 放在 northcp.add(p1,BorderLayout.SOUTH);frame.setSize(200,250);frame.setVisible(true);public void windowClosing(Windo
11、wEvent e1)System.exit(0);public void windowOpened(WindowEvent e2)public void windowIconified(WindowEvent e3)public void windowDeiconified(WindowEvent e4)public void windowClosed(WindowEvent e5)public void windowActivated(WindowEvent e6)public void windowDeactivated(WindowEvent e7)class UpperCaseDocu
12、ment extends PlainDocument public void insertString(int offset,String string, AttributeSet attributeSet)throws BadLocationException string = string.toUpperCase();super.insertString(offset,string, attributeSet);第二个:退房import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.bo
13、rder.Border;import javax.swing.text.*;public class A2 extends JFrame /定义各个组件JFrame frame = new JFrame (退房系统);JLabel nameLabel = new JLabel(客户);JLabel idtifyLabel = new JLabel(号);JLabel roomLabel = new JLabel(退房号);JLabel timeLabel = new JLabel(退房时间);JTextField nameField = new JTextField();JTextField
14、idtifyField= new JTextField();JTextField roomField= new JTextField();JTextField timeField= new JTextField();JButton button1,button2;/JTextArea ta = new JTextArea(5,20);/*public static void main(String args)(A2 a2 = new A2();a2.go();*/public void go()UpperCaseDocument ucDocument = new UpperCaseDocume
15、nt(); nameField.setDocument(ucDocument); nameField.setForeground(Color.black);nameField.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) String username = nameField.getText(););button1=new JButton(是);button2=new JButton(否); final JPanel p1 = new JPanel();p1.add(button1);p1.add(button2);p1.setLayout(new GridLayout(2,1);