?? register.java
字號:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class register
{
public static void main(String args[])
{
new RegisterFrame();
}
}
class RegisterFrame extends Frame implements ActionListener
{
Label prompt1;
Label prompt2;
TextField userName;
TextField password;
Button btn1,btn2,btn3;
Panel p1,p2,p3;
RegisterFrame()
{
super("注冊窗口");
prompt1=new Label("用戶名:");
prompt2=new Label("密碼:");
userName=new TextField(10);
password=new TextField(10);
password.setEchoChar('*');
btn1=new Button("確定");
btn2=new Button("注冊");
btn3=new Button("退出");
btn1.addActionListener(this);
btn3.addActionListener(this);
p1=new Panel();
p2=new Panel();
p3=new Panel();
p1.setBackground(Color.yellow);
p2.setBackground(Color.yellow);
p3.setBackground(Color.yellow);
setLayout(new BorderLayout());
p1.add(prompt1);
p1.add(userName);
p1.add(prompt2);
p1.add(password);
p2.add(btn1);
p2.add(btn2);
p2.add(btn3);
add("North",p1);
add("South",p2);
add("Center",p3);
addWindowListener(new closeWin());
setSize(400,100);
setVisible(true);
}
public void actionPerformed(ActionEvent ap)
{
if(ap.getActionCommand()=="確定")
{
setVisible(false);
new StocksTrade();
}
if(ap.getActionCommand()=="退出")
{
dispose();
System.exit(0);
}
}
}
class StocksTrade extends Frame
{
Customer myCustomer;
StocksInformation myStocksInformation;
StocksTrade()
{
super("簡單股票交易系統");
myCustomer=new Customer();
myStocksInformation=new StocksInformation();
setLayout(new BorderLayout());
add("Center",myCustomer);
add("East",myStocksInformation);
addWindowListener(new closeWin());
setSize(830,500);
setVisible(true);
}
}
class Operate extends Panel
{
Label prompt=new Label("客戶信息");
Button btn1,btn2,btn3,btn4,btn5;
Panel p1,p2,p3;
Font f=new Font("TimeRoman",Font.BOLD,12);
Operate()
{
setLayout(new BorderLayout());
btn1=new Button("添 加");
btn2=new Button("刪 除");
btn3=new Button("更 新");
btn4=new Button("視 圖");
btn5=new Button("顯 示");
p1=new Panel();
p2=new Panel();
p3=new Panel();
p1.setFont(f);
btn1.setFont(f);
btn2.setFont(f);
btn3.setFont(f);
btn4.setFont(f);
btn5.setFont(f);
p1.setBackground(Color.cyan);
p2.setBackground(Color.LIGHT_GRAY);
p3.setBackground(Color.red);
p1.add(prompt);
p2.add(btn1);
p2.add(btn2);
p2.add(btn3);
p2.add(btn4);
p2.add(btn5);
add("North",p1);
add("Center",p2);
add("South",p3);
}
}
class User extends Panel
{
Panel p1,p2,p3;
Label label1,label2;
TextField tf1,tf2;
Font f=new Font("TimeRoman",Font.BOLD,12);
User()
{
p1=new Panel();
p2=new Panel();
p3=new Panel();
label1=new Label("姓名");
label2=new Label("號碼");
tf1=new TextField("",15);
tf2=new TextField("",15);
label1.setFont(f);
label2.setFont(f);
p1.add(label1);
p1.add(tf1);
p1.setBackground(Color.LIGHT_GRAY);
p2.setBackground(Color.LIGHT_GRAY);
p3.setBackground(Color.LIGHT_GRAY);
p2.add(label2);
p2.add(tf2);
setLayout(new BorderLayout());
add(p1,"North");
add(p2,"South");
add(p3,"Center");
}
}
class Address extends Panel
{
Panel p;
User pan;
Label label;
TextArea texta;
Font f=new Font("TimeRoman",Font.BOLD,12);
Address()
{
p=new Panel();
pan=new User();
label=new Label("地址");
texta=new TextArea(10,20);
label.setFont(f);
p.setBackground(Color.LIGHT_GRAY);
p.add(label);
p.add(texta);
setLayout(new BorderLayout());
add(pan,"North");
add(p,"Center");
}
}
class ShareInformation extends Panel
{
Label label;
TextArea texta;
Panel p1,p2;
Font f=new Font("TimeRoman",Font.BOLD,12);
ShareInformation()
{
label=new Label("股票文件夾");
texta=new TextArea(20,25);
p1=new Panel();
p2=new Panel();
label.setFont(f);
p1.setBackground(Color.LIGHT_GRAY);
p2.setBackground(Color.LIGHT_GRAY);
setLayout(new BorderLayout());
p1.add(label);
p2.add(texta);
add("North",p1);
add("Center",p2);
}
}
class Alluser extends Panel
{
Label label;
TextArea texta;
Panel p1,p2;
Font f=new Font("TimeRoman",Font.BOLD,12);
Alluser()
{
label=new Label("所有客戶");
texta=new TextArea(20,25);
p1=new Panel();
p2=new Panel();
label.setFont(f);
p1.setBackground(Color.LIGHT_GRAY);
p2.setBackground(Color.LIGHT_GRAY);
setLayout(new BorderLayout());
p1.add(label);
p2.add(texta);
add("North",p1);
add("Center",p2);
}
}
class PanelCentrol extends Panel
{
Address myAddress;
ShareInformation myShareInformation;
Alluser myAlluser;
PanelCentrol()
{
myAddress=new Address();
myShareInformation=new ShareInformation();
myAlluser=new Alluser();
setLayout(new BorderLayout());
add("West",myAddress);
add("Center",myShareInformation);
add("East",myAlluser);
}
}
class ShareOperate extends Panel
{
Button btn1,btn2;
TextField textfield;
Panel p1,p2;
Label label;
Font f=new Font("TimeRoman",Font.BOLD,12);
ShareOperate()
{
p1=new Panel();
p2=new Panel();
btn1=new Button("買 進");
btn2=new Button("賣 出");
btn1.setFont(f);
btn2.setFont(f);
textfield=new TextField("",10);
setLayout(new BorderLayout());
p1.setBackground(Color.red);
p2.setBackground(Color.LIGHT_GRAY);
p2.add(btn1);
p2.add(textfield);
p2.add(btn2);
add("North",p1);
add("Center",p2);
}
}
class Customer extends Panel
{
Operate myOperate;
PanelCentrol myPanelCentrol;
ShareOperate myShareOperate;
Customer()
{
myOperate=new Operate();
myPanelCentrol=new PanelCentrol();
myShareOperate=new ShareOperate();
setLayout(new BorderLayout());
add(myOperate,"North");
add(myPanelCentrol,"Center");
add(myShareOperate,"South");
}
}
class Information extends Panel
{
Panel panel1,panel2,panel3;
Label label1,label2;
TextField textfield1,textfield2;
Font f=new Font("TimeRoman",Font.BOLD,12);
Information()
{
panel1=new Panel();
panel2=new Panel();
panel3=new Panel();
label1=new Label("股 票");
label2=new Label("即時價格");
label1.setFont(f);
label2.setFont(f);
textfield1=new TextField("",7);
textfield2=new TextField("",7);
panel1.setBackground(Color.LIGHT_GRAY);
panel2.setBackground(Color.LIGHT_GRAY);
panel3.setBackground(Color.cyan);
panel1.add(label1);
panel1.add(textfield1);
panel2.add(label2);
panel2.add(textfield2);
setLayout(new BorderLayout());
add(panel3,"North");
add(panel1,"Center");
add(panel2,"South");
}
}
class RightOperate extends Panel
{
Label label;
TextArea textarea;
Button button;
Panel p1,p2,p3;
Font f=new Font("TimeRoman",Font.BOLD,12);
RightOperate()
{
label=new Label("可用股票");
textarea=new TextArea(30,20);
button=new Button("當 前 股 票 價 格");
p1=new Panel();
p2=new Panel();
p3=new Panel();
label.setFont(f);
button.setFont(f);
setLayout(new BorderLayout());
p1.setBackground(Color.LIGHT_GRAY);
p2.setBackground(Color.LIGHT_GRAY);
p3.setBackground(Color.LIGHT_GRAY);
p1.add(label);
p2.add(textarea);
p3.add(button);
add(p1,"North");
add(p2,"Center");
add(p3,"South");
}
}
class RightStocksInformation extends Panel
{
Information rb;
RightOperate rt;
Panel p;
Label label;
Font f=new Font("TimeRoman",Font.BOLD,12);
RightStocksInformation()
{
p=new Panel();
label=new Label("股票信息");
rb=new Information();
rt=new RightOperate();
label.setFont(f);
rb.setBackground(Color.LIGHT_GRAY);
rt.setBackground(Color.LIGHT_GRAY);
p.setBackground(Color.cyan);
setLayout(new BorderLayout());
p.add(label);
add(p,"North");
add(rb,"South");
add(rt,"Center");
}
}
class StocksInformation extends Panel
{
RightStocksInformation rsi;
Panel p;
StocksInformation()
{
rsi=new RightStocksInformation();
p=new Panel();
p.setBackground(Color.LIGHT_GRAY);
setLayout(new BorderLayout());
add(p,"West");
add(rsi,"Center");
}
}
class closeWin extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
Frame frm=(Frame)(e.getSource());
frm.dispose();
System.exit(0);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -