📄 onlineframe.java~51~
字号:
package netbar;
import java.awt.*;
import javax.swing.*;
import java.awt.Dimension;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import javax.swing.BorderFactory;
import java.awt.Color;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.FocusAdapter;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class onlineFrame extends JFrame {
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
JLabel jLabel1 = new JLabel();
JLabel jLabelcomputerid = new JLabel();
JComboBox jComboBoxcardid = new JComboBox();
JLabel jLabel3 = new JLabel();
JComboBox jComboBoxcounttype = new JComboBox();
JLabel jLabelcardtype = new JLabel();
JComboBox jComboBoxcardtype = new JComboBox();
JLabel jLabel5 = new JLabel();
JLabel jLabelonlinetime = new JLabel();
JLabel jLabel6 = new JLabel();
JLabel jLabelyajin = new JLabel();
JLabel jLabel8 = new JLabel();
JLabel jLabel9 = new JLabel();
JLabel jLabel10 = new JLabel();
JLabel jLabelbalance = new JLabel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JLabel jLabeltitle = new JLabel();
public onlineFrame() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(borderLayout1);
setSize(new Dimension(378, 285));
this.setTitle("充值");
setIconImage(Toolkit.getDefaultToolkit().createImage(netbar.mainFrame.class.getResource("login.png")));
this.setResizable(false);
jLabel1.setBounds(new Rectangle(14, 43, 76, 15));
jLabelcomputerid.setBounds(new Rectangle(74, 38, 91, 20));
jComboBoxcardid.setBorder(BorderFactory.createLineBorder(Color.black));
jComboBoxcardid.setBounds(new Rectangle(230, 42, 115, 16));
jComboBoxcardid.addFocusListener(new
onlineFrame_jComboBoxcardid_focusAdapter(this));
connectSQL con=new connectSQL();
java.sql.ResultSet rs=con.s.executeQuery("select * from member");
while(rs.next()){
jComboBoxcardid.addItem(rs.getString(1));}
connectSQL cont=new connectSQL();
java.sql.ResultSet rst=cont.s.executeQuery("select * from common");
while(rst.next()){
jComboBoxcardid.addItem(rst.getString(1)); }
jLabel3.setText("计费类型:");
jLabel3.setBounds(new Rectangle(14, 82, 76, 18));
jComboBoxcounttype.setBorder(BorderFactory.createLineBorder(Color.black));
jComboBoxcounttype.setBounds(new Rectangle(79, 82, 89, 17));
jComboBoxcounttype.addItem("标准费率");
jComboBoxcounttype.addItem("会员费率");
jComboBoxcounttype.addItem("优惠费率");
jLabelcardtype.setBounds(new Rectangle(232, 78, 91, 22));
jComboBoxcardtype.setBorder(BorderFactory.createLineBorder(Color.black));
jComboBoxcardtype.setBounds(new Rectangle(230, 82, 115, 18));
jComboBoxcardtype.addItem("普通卡");
jComboBoxcardtype.addItem("会员卡");
jComboBoxcardtype.addItem("VIP卡");
jLabel5.setText("上机开始时间:");
jLabel5.setBounds(new Rectangle(14, 130, 93, 16));
jLabelonlinetime.setBounds(new Rectangle(108, 130, 235, 18));
jLabel6.setText("押金:");
jLabel6.setBounds(new Rectangle(15, 167, 59, 19));
jLabelyajin.setBounds(new Rectangle(76, 167, 93, 15));
jLabel8.setText("余额:");
jLabel8.setBounds(new Rectangle(176, 167, 55, 16));
jLabel9.setText("卡号:");
jLabel9.setBounds(new Rectangle(176, 41, 47, 16));
jLabel10.setText("卡类型:");
jLabel10.setBounds(new Rectangle(176, 83, 56, 15));
jLabelbalance.setBounds(new Rectangle(232, 167, 118, 14));
jButton1.setBounds(new Rectangle(145, 219, 75, 27));
jButton1.setText("上机");
jButton1.addMouseListener(new onlineFrame_jButton1_mouseAdapter(this));
jButton2.setBounds(new Rectangle(239, 219, 74, 27));
jButton2.setText("取消");
jButton2.addMouseListener(new onlineFrame_jButton2_mouseAdapter(this));
jLabeltitle.setForeground(Color.red);
jLabeltitle.setBorder(BorderFactory.createTitledBorder ("上机"));
jLabeltitle.setBounds(new Rectangle(7, 16, 358, 198));
this.getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
jPanel1.add(jLabel1, null);
jPanel1.add(jComboBoxcardid);
jPanel1.add(jLabel3);
jPanel1.add(jComboBoxcounttype);
jPanel1.add(jLabelcardtype);
jPanel1.add(jComboBoxcardtype);
jPanel1.add(jLabel5);
jPanel1.add(jLabelonlinetime);
jPanel1.add(jLabelyajin);
jPanel1.add(jLabel8);
jPanel1.add(jLabel9);
jPanel1.add(jLabel10);
jPanel1.add(jLabelbalance);
jPanel1.add(jLabel6);
jPanel1.add(jButton1);
jPanel1.add(jLabelcomputerid, null);
jPanel1.add(jLabeltitle);
jPanel1.add(jButton2);
jLabel1.setText("计算机名:");
jPanel1.setLayout(null);
}
public void jButton2_mouseClicked(MouseEvent e) {
if(e.getButton()==e.BUTTON1)
this.dispose();
}
public void jComboBoxcardid_focusLost(FocusEvent e) {
char tmp=jComboBoxcardid.getSelectedItem().toString().charAt(0);
if(tmp=='2'){
connectSQL con=new connectSQL();
float ba=con.getMemberbalance(jComboBoxcardid.getSelectedItem().toString());
jLabelbalance.setText(String.valueOf(ba));
jLabelyajin.setText("");
}else if(tmp=='5'){
connectSQL con=new connectSQL();
float bc=con.getCommonbalance(jComboBoxcardid.getSelectedItem().toString());
jLabelyajin.setText(String.valueOf(bc));
jLabelbalance.setText("");
}
}
public void jButton1_mouseClicked(MouseEvent e) {
if(e.getButton()==e.BUTTON1){
connectSQL con = new connectSQL();
if(con.online(jLabelcomputerid.getText(),jComboBoxcardid.getSelectedItem().toString(),jComboBoxcounttype.getSelectedItem().toString(),jComboBoxcardtype.getSelectedItem().toString(),jLabelonlinetime.getText(),jLabelyajin.getText(),jLabelbalance.getText(),"使用")){
this.dispose();
}else{
JOptionPane.showMessageDialog(this,"错误!","上机",JOptionPane.ERROR_MESSAGE);
}
}
}
}
class onlineFrame_jComboBoxcardid_focusAdapter extends FocusAdapter {
private onlineFrame adaptee;
onlineFrame_jComboBoxcardid_focusAdapter(onlineFrame adaptee) {
this.adaptee = adaptee;
}
public void focusLost(FocusEvent e) {
adaptee.jComboBoxcardid_focusLost(e);
}
}
class onlineFrame_jButton1_mouseAdapter extends MouseAdapter {
private onlineFrame adaptee;
onlineFrame_jButton1_mouseAdapter(onlineFrame adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent e) {
adaptee.jButton1_mouseClicked(e);
}
}
class onlineFrame_jButton2_mouseAdapter extends MouseAdapter {
private onlineFrame adaptee;
onlineFrame_jButton2_mouseAdapter(onlineFrame adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent e) {
adaptee.jButton2_mouseClicked(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -