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

📄 teacherframe.java

📁 使用java连接server sql 2000 的一个小作业
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import java.util.*;
import java.sql.*;


public class TeacherFrame extends JFrame implements ActionListener{
	
	JButton b0,b1,b2,b3,b4,b5;
    JPanel ForToolBar=new JPanel(new FlowLayout());
    JPanel CenterPane=new JPanel();
    CardLayout cl=new CardLayout();
    
    
    
    
    TeacherFrame(){
    	   getContentPane().setLayout(new BorderLayout());
    	   getContentPane().add(ForToolBar,"South");
           getContentPane().add(CenterPane,"Center");
           
           /////////-----------
        JToolBar tb=new JToolBar();
        tb=createToolBar() ;
        ForToolBar.add(tb);
          /////////-------- 
       	
           CenterPane.setLayout(cl);
           JPanel firstPane=new JPanel();
           firstPane.add(new JLabel(new ImageIcon("首页2.JPG")));
           CenterPane.add(firstPane,"FirstPage");
           CenterPane.add(new DisposePane(),"secondPage");
           CenterPane.add(new GradePane(),"thirdPage");
          CenterPane.add(new lookAllPane(),"fouthPage");
    	
/////////////
        setSize(500,800);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();
        setLocation((screen.width-500)/2,(screen.height-800)/2);
        setTitle("welcome to MPX");
        setVisible(true);
    }
   
    public void actionPerformed(ActionEvent e){
    	if(e.getSource()==b0){
    		cl.show(CenterPane, "FirstPage");
    	}
    	if(e.getSource()==b1){
    		cl.show(CenterPane, "secondPage");
    	}
    	if(e.getSource()==b2){
    		new ChangePasswordDia();
    	}
    	if(e.getSource()==b3){
    		cl.show(CenterPane, "thirdPage");
    	}
    	if(e.getSource()==b4){
    		cl.show(CenterPane,"fouthPage");
    	}
    	if(e.getSource()==b5){
    		int n=JOptionPane.showConfirmDialog(null, "退出系统吗");
        	if(n==JOptionPane.YES_OPTION)
        	{
        		dispose();
        		
        		new LoginDia();
        	}
        	else
        		return;
    	}
    }
    
   
 public JToolBar createToolBar(){
    	
        JToolBar tb=new JToolBar();
        b0=new JButton("首页",new ImageIcon("6.gif"));
        b0.setHorizontalTextPosition(AbstractButton.CENTER);
        b0.setVerticalTextPosition(AbstractButton.BOTTOM);
        b0.setFocusPainted(false);
        b0.setRequestFocusEnabled(false);
        
        b1=new JButton("布置作业",new ImageIcon("7.gif"));
        b1.setHorizontalTextPosition(AbstractButton.CENTER);
        b1.setVerticalTextPosition(AbstractButton.BOTTOM);
        b1.setFocusPainted(false);
        b1.setRequestFocusEnabled(false);
        
        b2=new JButton("修改密码",new ImageIcon("8.gif"));
        b2.setHorizontalTextPosition(AbstractButton.CENTER);
        b2.setVerticalTextPosition(AbstractButton.BOTTOM);
        b2.setToolTipText("修改帐号或密码");
        b2.setFocusPainted(false);
        b2.setRequestFocusEnabled(false);
        
        b3=new JButton("批改作业",new ImageIcon("9.gif"));
        b3.setHorizontalTextPosition(AbstractButton.CENTER);
        b3.setVerticalTextPosition(AbstractButton.BOTTOM);
        b3.setFocusPainted(false);
        b3.setRequestFocusEnabled(false);
        
        b4=new JButton("成绩表",new ImageIcon("10.gif"));
        b4.setHorizontalTextPosition(AbstractButton.CENTER);
        b4.setVerticalTextPosition(AbstractButton.BOTTOM);
        b4.setFocusPainted(false);
        b4.setRequestFocusEnabled(false);
        
        b5=new JButton("退出系统",new ImageIcon("11.gif"));
        b5.setHorizontalTextPosition(AbstractButton.CENTER);
        b5.setVerticalTextPosition(AbstractButton.BOTTOM);
        b5.setFocusPainted(false);
        b5.setRequestFocusEnabled(false);
        
        tb.add(b0);tb.add(b1);tb.add(b2);tb.add(b3);tb.add(b4);tb.add(b5);
        b0.addActionListener(this);
        b1.addActionListener(this);
        b2.addActionListener(this);
        b3.addActionListener(this);
        b4.addActionListener(this);
        b5.addActionListener(this);

        tb.setRollover(true);
        tb.setFloatable(true);
        
        return tb;
    }

}

⌨️ 快捷键说明

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