⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frame1.java~4~

📁 一个简单的使用电话卡的JAVA程序
💻 JAVA~4~
字号:
package phone;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class Frame1 extends JFrame {
  JPanel contentPane;
  XYLayout xYLayout1 = new XYLayout();
  JButton jButton1 = new JButton();
  JLabel jLabel1 = new JLabel();
  JLabel jLabel2 = new JLabel();
  JLabel jLabel3 = new JLabel();
  JLabel jLabel4 = new JLabel();
  JTextField T1 = new JTextField();
  JTextField T2 = new JTextField();
  JTextField T3 = new JTextField();
  JTextField T4 = new JTextField();

  //Construct the frame
  public Frame1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  //Component initialization
  private void jbInit() throws Exception  {
    contentPane = (JPanel) this.getContentPane();
    jButton1.setHorizontalAlignment(SwingConstants.CENTER);
    jButton1.setText("输入");
    jButton1.addActionListener(new Frame1_jButton1_actionAdapter(this));
    contentPane.setLayout(xYLayout1);
    this.setSize(new Dimension(400, 300));
    this.setTitle("Frame Title");
    jLabel1.setText("电话卡接入号码");
    jLabel2.setText("电话卡卡号");
    jLabel3.setText("电话卡密码");
    jLabel4.setText("剩余金额");
    T1.setText("");
    T2.setText("");
    T3.setText("");
    T4.setText("");
    contentPane.add(jButton1, new XYConstraints(317, 51, -1, -1));
    contentPane.add(jLabel1,  new XYConstraints(26, 99, -1, -1));
    contentPane.add(jLabel2,  new XYConstraints(28, 138, -1, -1));
    contentPane.add(jLabel3,  new XYConstraints(30, 184, -1, -1));
    contentPane.add(jLabel4,  new XYConstraints(34, 231, -1, -1));
    contentPane.add(T1,    new XYConstraints(153, 96, 137, -1));
    contentPane.add(T2,  new XYConstraints(154, 142, 134, -1));
    contentPane.add(T3,  new XYConstraints(154, 185, 137, -1));
    contentPane.add(T4,  new XYConstraints(156, 233, 137, -1));
  }
  //Overridden so we can exit when window is closed
  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
    }
  }
class PhoneCard
{long cardNumeber;
   private int password;
   double balance;
   String connectNumber;
   boolean connected;
   PhoneCard(long cn,int pw,double b,String s)
   {cardNumber=cn;
     password=pw;
     if(b>0)
       blanace=b;
       else
         System.exit(1);
         connectNumber=s;
         connected=false;
   }
   boolean performConnection(long cn,int pw)
   {
     if (cn == cardNumber && pw == password)
     {connected=true;
       return true;
     }
     else
     {connected=false;
       return false;
     }

  }
   double getBalance()
   {if(conneced)
       return balace;
     else
       return -1;
   }
   void performDial()
   {if(connected)
       balance-=0.5;

    }
}
void jButton1_actionPerformed(ActionEvent e) {
    PhoneCard myCard = new PhoneCard(12345678, 1234, 50.0, "300");
    T1.setText(12345678);
    T2.setText(1234);
    T3.setText(50.0);
    T4.setText(300);
}
class Frame1_jButton1_actionAdapter implements java.awt.event.ActionListener
{

    Frame1 adaptee;

    Frame1_jButton1_actionAdapter(Frame1 adaptee) {
      this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
      adaptee.jButton1_actionPerformed(e);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -