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

📄 bikeinfo.java

📁 关于自行车店管理系统的源代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
import java.awt.*;
import java.io.*;
import java.sql.*;
import java.awt.event.*;
import javax.swing.table.*;
import javax.swing.border.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;

//----------------------------------------------------------------------------------------------------
class BikeIn extends JFrame implements ActionListener
{
	static int idcount=0;
	static int idcount2=0;
	JTextField studentnumber;
	JTextField name;
	JTextField password;//password.getText()
	JTextField telephone;
	JTextField adress;
	JComboBox sex;
	JCheckBox party;
	JTextField age;
	JComboBox grade;
	JButton backcolor;
	JButton forcolor;
	JLabel photo;
	JButton photoButton;
	JTextArea resume;
	JSplitPane split_one;
	JSplitPane split_two;
	JSplitPane split_three;
	
	JButton add;
	JButton delete;
	JButton search;
	JButton change;
	JButton next;
	JButton previous;
	JButton first;
	JButton last;
	
	JTable table;
	DefaultTableModel model;
	
	JCheckBoxMenuItem toolbarVisible;
	JMenuItem count;
	JMenuItem exit;
	
	JToolBar toolbar;
	JButton countButton;
	JButton exitButton;
	
	JLabel dispTime;
	JLabel position=new JLabel();
	
	int num=0;
	
	String filenamepath="2.gif";
	
	BikeIn()
	{
		super("自行车进库管理系统");
		
		addWindowListener(new WindowAdapter()
		{
			public void windowClosing(WindowEvent e)
			{
				//System.exit(0);
				//System.runFinalizersOnExit(false);
				System.runFinalization();
				//new ExitWindow();
			}
		});
		
		Container con=getContentPane();
		
		JMenuBar menubar=new JMenuBar();
		JMenu menu=new JMenu("功能");
		toolbarVisible=new JCheckBoxMenuItem("显示/隐藏工具条",true);
		toolbarVisible.addActionListener(this);
		count=new JMenuItem("统计数量");
		count.setActionCommand("count");
		count.addActionListener(this);
		exit=new JMenuItem("Exit",'x');
		exit.addActionListener(this);
		exit.setActionCommand("exit");
  		exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,InputEvent.ALT_MASK));
		menu.add(toolbarVisible);
		menu.addSeparator();
		menu.add(count);
		menu.addSeparator();
		menu.add(exit);
		menubar.add(menu);
		setJMenuBar(menubar);
		
		countButton=new JButton("统计数量");
		countButton.setActionCommand("count");
		countButton.addActionListener(this);
		countButton.setToolTipText("统计当前已输入的学生人数");
		exitButton=new JButton("退出");
		exitButton.addActionListener(this);
		exitButton.setActionCommand("exit");
		exitButton.setToolTipText("退出本系统");
		toolbar=new JToolBar();
		toolbar.add(countButton);
		toolbar.addSeparator();
		toolbar.add(exitButton);
		con.add(toolbar,"North");
		
		Box snBox=Box.createHorizontalBox();
		studentnumber=new JTextField(20);
		snBox.add(new JLabel("代号"));
		snBox.add(Box.createHorizontalStrut(5));
		snBox.add(studentnumber);
		snBox.add(Box.createHorizontalGlue());

		Box nameBox=Box.createHorizontalBox();
		name=new JTextField(20);
		nameBox.add(new JLabel("型号"));
		nameBox.add(Box.createHorizontalStrut(5));
		nameBox.add(name);
		nameBox.add(Box.createHorizontalGlue());
		
		Box passwordBox=Box.createHorizontalBox();
		password=new JTextField(20);
		passwordBox.add(new JLabel("大小"));
		passwordBox.add(Box.createHorizontalStrut(5));
		passwordBox.add(password);
		passwordBox.add(Box.createHorizontalGlue());
		
		Box telephoneBox=Box.createHorizontalBox();
		telephone=new JTextField(20);
		telephoneBox.add(new JLabel("电话"));
		telephoneBox.add(Box.createHorizontalStrut(5));
		telephoneBox.add(telephone);
		telephoneBox.add(Box.createHorizontalGlue());
		
		Box adressBox=Box.createHorizontalBox();
		adress=new JTextField(20);
		adressBox.add(new JLabel("地址"));
		adressBox.add(Box.createHorizontalStrut(5));
		adressBox.add(adress);
		adressBox.add(Box.createHorizontalGlue());
		
		Box sexBox=Box.createHorizontalBox();
		sex=new JComboBox();
		sex.addItem("男");
		sex.addItem("女");
		sexBox.add(new JLabel("样式"));
		sexBox.add(Box.createHorizontalStrut(5));
		sexBox.add(sex);
		sexBox.add(Box.createHorizontalGlue());
		
		Box partyBox=Box.createHorizontalBox();
		party=new JCheckBox();
		party.setHorizontalTextPosition(JCheckBox.LEFT);
		party.setSelected(false);
		partyBox.add(new JLabel("合格"));
		partyBox.add(Box.createHorizontalStrut(5));
		partyBox.add(party);
		partyBox.add(Box.createHorizontalGlue());

		Box ageBox=Box.createHorizontalBox();
		age=new JTextField(20);
		ageBox.add(new JLabel("数量"));
		ageBox.add(Box.createHorizontalStrut(5));
		ageBox.add(age);
		ageBox.add(Box.createHorizontalGlue());
		
		Box gradeBox=Box.createHorizontalBox();
		grade=new JComboBox();
		grade.addItem("一级品");
		grade.addItem("二级品");
		grade.addItem("三级品");
		grade.addItem("四级品");
		gradeBox.add(new JLabel("等级"));
		gradeBox.add(Box.createHorizontalStrut(5));
		gradeBox.add(grade);
		gradeBox.add(Box.createHorizontalGlue());

		Box colorBox=Box.createHorizontalBox();
		
		forcolor=new JButton("前景色");
		forcolor.addActionListener(this);
		backcolor=new JButton("背景色");
		backcolor.addActionListener(this);
		colorBox.add(new JLabel("颜色"));
		colorBox.add(Box.createHorizontalStrut(5));
		colorBox.add(forcolor);
		colorBox.add(Box.createHorizontalStrut(5));
		colorBox.add(backcolor);
		colorBox.add(Box.createHorizontalGlue());

		Box photoBox=Box.createVerticalBox();
		photoButton=new JButton("选择照片");
		photoButton.addActionListener(this);
		photo=new JLabel(new ImageIcon("2.gif"));
              photoBox.add(photo);
		photoBox.add(Box.createVerticalStrut(10));
		photoBox.add(photoButton);
		photoBox.add(Box.createVerticalGlue());
		photoBox.add(new JScrollPane(photo));
		photoBox.add(Box.createVerticalStrut(10));
		
		Box resumeBox=Box.createVerticalBox();
		resume=new JTextArea(11,28);
		String a=new String();
		a="天是透明的 因为雪慢慢的停了\n心是透明的 因为我不想隐藏了 \n天是透明的 因为黑夜已过去了 \n因为你对我笑了 所以想念很快乐 \n心是透明的 因为有你永远陪着 \n因为你决定爱了 所以等待也是值得\n你看不到我的苍凉,我依然带你去飞翔;\n你看不到我的迷惘,我依然带你去流浪; \n你找不到的地方,我和你一起跳舞`歌唱; \n你找不到的天堂,我把它拿来放在你手上。 \n";
		resume.setText(a);
		resume.setForeground(Color.BLUE);
		resumeBox.add(resume);
		resumeBox.add(Box.createVerticalStrut(10));
		resumeBox.add(new JLabel("简介"));
		resumeBox.add(Box.createVerticalGlue());
		resumeBox.add(new JScrollPane(resume));
		resumeBox.add(Box.createVerticalStrut(10));

		Box leftBox=Box.createVerticalBox();
		leftBox.add(Box.createVerticalStrut(10));
		leftBox.add(snBox);
		
		leftBox.add(Box.createVerticalStrut(10));
		leftBox.add(nameBox);
		
		leftBox.add(Box.createVerticalStrut(10));
		leftBox.add(passwordBox);
		
		leftBox.add(Box.createVerticalStrut(10));
		leftBox.add(sexBox);
		
		leftBox.add(Box.createVerticalStrut(10));
		leftBox.add(ageBox);
		
		leftBox.add(Box.createVerticalStrut(10));
		leftBox.add(gradeBox);
		
		leftBox.add(Box.createVerticalStrut(10));
		leftBox.add(partyBox);
		
		leftBox.add(Box.createVerticalStrut(10));
		leftBox.add(telephoneBox);
		
		leftBox.add(Box.createVerticalStrut(10));
		leftBox.add(adressBox);
												
		leftBox.add(Box.createVerticalStrut(10));
		leftBox.add(colorBox);
		
		leftBox.add(Box.createVerticalStrut(10));
		leftBox.add(Box.createHorizontalGlue());
		
		
		Box rightBox=Box.createVerticalBox();
		rightBox.add(Box.createHorizontalGlue());
		rightBox.add(Box.createHorizontalStrut(5));
		
		add=new JButton("确认添加");
		add.addActionListener(this);
		rightBox.add(add);
		rightBox.add(Box.createHorizontalStrut(5));
		
		delete=new JButton("删除");
		delete.addActionListener(this);
		rightBox.add(delete);
		rightBox.add(Box.createHorizontalStrut(5));
		
		search=new JButton("查找");
		search.addActionListener(this);
		rightBox.add(search);
		rightBox.add(Box.createHorizontalStrut(5));
		
		change=new JButton("修改");
		rightBox.add(change);
		change.addActionListener(this);
		rightBox.add(Box.createHorizontalStrut(5));
	
				
		previous=new JButton("上一个");
		previous.addActionListener(this);
		rightBox.add(previous);
		rightBox.add(Box.createHorizontalStrut(5));
		
		next=new JButton("下一个");
		next.addActionListener(this);
		rightBox.add(next);
		rightBox.add(Box.createHorizontalStrut(5));
	
		first=new JButton("第一个");
		first.addActionListener(this);
		rightBox.add(first);
		rightBox.add(Box.createHorizontalStrut(5));
		
		last=new JButton("最后一个");
		last.addActionListener(this);
		rightBox.add(last);
		rightBox.add(Box.createHorizontalStrut(5));
		
		JLabel rightpanel=new JLabel();
		rightBox.add(rightpanel);
		rightBox.add(Box.createHorizontalGlue());
		split_one=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,false,leftBox,photoBox);
		split_one.setSize(0,50);
		split_two=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,false,split_one,resumeBox);
		split_three=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,false,split_two,rightBox);
		Box inputBox=Box.createHorizontalBox();
		inputBox.add(split_three,BorderLayout.CENTER);
                                       
		
		Border border=BorderFactory.createTitledBorder(
		    BorderFactory.createLineBorder(Color.BLACK,2),
			"自行车进库管理系统",
			TitledBorder.CENTER,TitledBorder.ABOVE_TOP,
			new Font("GB_2312",Font.BOLD,28),
			Color.BLACK);
		inputBox.setBorder(border);
		
		Object[][] data={};
		Object[] column={"代号","型号","大小","样式","数量","等级","合格","电话","地址","照片","简介"};
		model=new DefaultTableModel(data,column);
		table=new JTable(model);
		table.setShowGrid(true);
		JScrollPane tablepane=new JScrollPane(table);	
		
		JSplitPane pane=new JSplitPane(JSplitPane.VERTICAL_SPLIT,true,inputBox,tablepane);
			
		con.add(pane,BorderLayout.CENTER);
		setSize(600,400);
		setVisible(true);
		setExtendedState(MAXIMIZED_BOTH);
		setResizable(false);
		//setSizable(false);		
			
		Box bottomBox=Box.createHorizontalBox();
		dispTime=new JLabel();
		dispTime.setHorizontalAlignment(JLabel.LEFT);
		dispTime.setForeground(Color.BLACK);
		
		
        position.setHorizontalAlignment(JLabel.RIGHT);
        position.setText("^-^ 伟伟制作   济南大学   计0239    2002033155           ");
        
        bottomBox.add(position);
        bottomBox.add(dispTime);
        
        con.add(bottomBox,BorderLayout.SOUTH);
        bottomBox.add(Box.createHorizontalGlue());
         
         
		ActionListener time=new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				dispTime.setText(new java.util.Date().toString());
			}
		};
		new Timer(1000,time).start();
		
	}	
     
//-----------------------------------------------------------------------------------------------------------   
        	
	public void actionPerformed(ActionEvent e)
	{		
		if (e.getSource()==toolbarVisible)
		{
			toolbar.setVisible(toolbarVisible.getState());
		}
		
		if (e.getActionCommand().equals("count"))
		{
			JOptionPane.showMessageDialog(this,"当前人数:"+String.valueOf(num),"统计结果",JOptionPane.INFORMATION_MESSAGE);
		}
		
		//退出
		if (e.getActionCommand().equals("exit"))
		{
			if (JOptionPane.YES_OPTION==JOptionPane.showConfirmDialog(this,"你确定要退出本系统吗?","确认",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE))
			{
				System.runFinalization();
			}
		}

		if (e.getSource()==forcolor)
		{
			JColorChooser colorChooser=new JColorChooser();
			Color colors=colorChooser.showDialog(this,"请选择颜色",Color.green);
			resume.setForeground(colors);
		}
		
		if (e.getSource()==backcolor)
		{
			JColorChooser colorChooser=new JColorChooser();
			Color colors=colorChooser.showDialog(this,"请选择颜色",Color.green);
			resume.setBackground(colors);
		}
		
		if (e.getSource()==photoButton)
		{
			JFileChooser photoChooser=new JFileChooser();
			if (JFileChooser.APPROVE_OPTION==photoChooser.showOpenDialog(this))
			{
				filenamepath=photoChooser.getSelectedFile().getPath();
				photo.setIcon(new ImageIcon(filenamepath));
			}
		}
		
		if (e.getSource()==add)

⌨️ 快捷键说明

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