?? mainframe.java
字號(hào):
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JButton;
public class MainFrame implements ActionListener{
//定義元素
JFrame mFrame;
JLabel up_lb;
JPanel up_panel;
JPanel down_panel;
JPanel main_panel;
JButton c_button;
JButton b_button;
JButton quit_button;
JButton see_button;
ArrayList array = new ArrayList();
Customer cust;
JLabel show_lb;
public MainFrame(ArrayList ar){
int ar_i = ar.size();
for(int j=0;j<ar_i;j++){
Customer ct = (Customer)ar.get(j);
String id = new String(ct.getB().getId());
String length = new String(ct.getB().getLength());
String name = new String(ct.getName());
String tel = new String(ct.getTel());
String pwd = new String(ct.getPwd());
String add = new String(ct.getAddress());
cust = new Customer(id,length,name,tel,pwd,add);
this.array.add(ct);
}
mFrame = new JFrame("主頁(yè)面"); //定義Frame
//構(gòu)建容器
up_panel = new JPanel(new GridLayout(2,1));
down_panel = new JPanel();
main_panel = new JPanel(new GridLayout(2,1));
//定義標(biāo)題
up_lb = new JLabel("船舶管理系統(tǒng)!");
up_lb.setForeground(Color.red);
up_lb.setFont(new Font("黑體",10,30));
up_lb.setHorizontalAlignment(JLabel.CENTER);
show_lb =new JLabel(" 船長(zhǎng) 您好!歡迎登陸該系統(tǒng)!");
show_lb.setHorizontalAlignment((int) JLabel.CENTER_ALIGNMENT);
show_lb.setForeground(Color.blue);
//構(gòu)件按妞
c_button = new JButton("增加客戶/查看客戶");
b_button = new JButton("增加船只/查看船只");
see_button = new JButton("會(huì)員資料顯示");
c_button.addActionListener(this);
b_button.addActionListener(this);
see_button.addActionListener(this);
//將組件加入到容器
up_panel.add(up_lb);
up_panel.add(show_lb);
down_panel.add(c_button);
down_panel.add(b_button);
down_panel.add(see_button);
main_panel.add(up_panel);
main_panel.add(down_panel);
mFrame.add(main_panel);
//mFrame設(shè)置
mFrame.setSize(500,300);
mFrame.setLocation(350,250);
mFrame.setDefaultCloseOperation(mFrame.EXIT_ON_CLOSE);
mFrame.setResizable(false);
mFrame.setVisible(true);
}
public MainFrame(ArrayList ar,int i){
int ji = i; //接收傳過(guò)來(lái)的i值
int ar_i = ar.size();
for(int j=0;j<ar_i;j++){
Customer ct = (Customer)ar.get(j);
String id = new String(ct.getB().getId());
String length = new String(ct.getB().getLength());
String name = new String(ct.getName());
String tel = new String(ct.getTel());
String pwd = new String(ct.getPwd());
String add = new String(ct.getAddress());
cust = new Customer(id,length,name,tel,pwd,add);
this.array.add(ct);
}
Customer ct1 = (Customer)ar.get(ji);
mFrame = new JFrame("主頁(yè)面"); //定義Frame
//構(gòu)建容器
up_panel = new JPanel(new GridLayout(2,1));
down_panel = new JPanel();
main_panel = new JPanel(new GridLayout(2,1));
//定義標(biāo)題
up_lb = new JLabel("船舶管理系統(tǒng)!");
up_lb.setForeground(Color.red);
up_lb.setFont(new Font("黑體",10,30));
up_lb.setHorizontalAlignment(JLabel.CENTER);
show_lb =new JLabel(ct1.getName()+" 您好!歡迎登陸該系統(tǒng)!");
show_lb.setHorizontalAlignment((int) JLabel.CENTER_ALIGNMENT);
show_lb.setForeground(Color.blue);
//構(gòu)件按妞
c_button = new JButton("增加客戶/查看客戶");
b_button = new JButton("增加船只/查看船只");
see_button = new JButton("會(huì)員查詢");
//將組件加入到容器
up_panel.add(up_lb);
up_panel.add(show_lb);
down_panel.add(c_button);
down_panel.add(b_button);
down_panel.add(see_button);
main_panel.add(up_panel);
main_panel.add(down_panel);
mFrame.add(main_panel);
//mFrame設(shè)置
mFrame.setSize(500,300);
mFrame.setLocation(350,250);
mFrame.setDefaultCloseOperation(mFrame.EXIT_ON_CLOSE);
mFrame.setResizable(false);
mFrame.setVisible(true);
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == c_button){
new AddCustomerFrame(array);
mFrame.dispose();
}
else if(e.getSource() == b_button){
new AddBoatFrame(array);
mFrame.dispose();
}
else{
new SearchFrame(array);
mFrame.dispose();
}
}
public static void main(String[] args){
//new MainFrame();
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -