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

📄 mainframe.java

📁 码头船舶管理系统 适合初学者使用 J2SE的知识
💻 JAVA
字号:
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("主页面");	//定义Frame
				
		//构建容器
		
		up_panel = new JPanel(new GridLayout(2,1));
		down_panel = new JPanel();
		main_panel = new JPanel(new GridLayout(2,1));
		
		//定义标题
		up_lb = new JLabel("船舶管理系统!");
		up_lb.setForeground(Color.red);
		up_lb.setFont(new Font("黑体",10,30));
		up_lb.setHorizontalAlignment(JLabel.CENTER);
		show_lb =new JLabel(" 船长 您好!欢迎登陆该系统!");
		show_lb.setHorizontalAlignment((int) JLabel.CENTER_ALIGNMENT);
		show_lb.setForeground(Color.blue);
		
		//构件按妞
		
		c_button = new JButton("增加客户/查看客户");
		b_button = new JButton("增加船只/查看船只");
		see_button = new JButton("会员资料显示");
		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设置
		
		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;			//接收传过来的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("主页面");	//定义Frame
				
		//构建容器
		
		up_panel = new JPanel(new GridLayout(2,1));
		down_panel = new JPanel();
		main_panel = new JPanel(new GridLayout(2,1));
		
		//定义标题
		up_lb = new JLabel("船舶管理系统!");
		up_lb.setForeground(Color.red);
		up_lb.setFont(new Font("黑体",10,30));
		up_lb.setHorizontalAlignment(JLabel.CENTER);
		show_lb =new JLabel(ct1.getName()+"  您好!欢迎登陆该系统!");
		show_lb.setHorizontalAlignment((int) JLabel.CENTER_ALIGNMENT);
		show_lb.setForeground(Color.blue);
		
		//构件按妞
		
		c_button = new JButton("增加客户/查看客户");
		b_button = new JButton("增加船只/查看船只");
		see_button = new JButton("会员查询");
		
		//将组件加入到容器
		
		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设置
		
		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();
	}
}

⌨️ 快捷键说明

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