资源预览内容
第1页 / 共59页
第2页 / 共59页
第3页 / 共59页
第4页 / 共59页
第5页 / 共59页
第6页 / 共59页
第7页 / 共59页
第8页 / 共59页
第9页 / 共59页
第10页 / 共59页
亲,该文档总共59页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
入住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 roomLabel = 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();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 = nameField.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 = 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.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 actionPerformed(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 ActionListener() 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);labelPanel.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();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(WindowEvent 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 UpperCaseDocument 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.border.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 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 UpperCaseDocument(); 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);
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号