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

📄 firstframe.java

📁 这是一个用于上班签到的记录本java应用程序.但有的功能还不完善.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
  
   if(world1!=1){ 
    administrator.setLayout(new GridLayout(3,1));
	a_pp.add(pp);
	a_p1.add(a_name);
	
	a_p1.add(a_password);
	a_p2.add(a_yes);
	a_p2.add(a_cancel);
	administrator.add(a_pp);
	administrator.add(a_p1);
	administrator.add(a_p2);
	administrator.setLocation(350,330);
	administrator.setSize(300,200);

	administrator.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    fileRandom file6=new fileRandom("成员.txt");
    file6.readname(b_cho);
   
   }
    	}
           	           
     	if(e.getSource()==a_yes)//上班--
    	{
     String str=a_password.getText();
     System.out.println ("密码:"+str);
     
     if(str.compareTo("world")==0){
    
    	System.out.println("ok");
     	administrator.dispose();
        
     	//进入后面的程序.     	
     //	JDialog admin=new JDialog();
            p.setVisible(false);
           // menudenglu.setVisible(false);
           // menuhere.setVisible(false);
            b_pan4.setVisible(true);
     	   if(world1==0){
     	   
     	    b_pan1.add(b_lab);
     	    b_pan1.add(b_t1);
     	    b_pan1.add(b_lab1);
     		b_pan1.add(b_cho);
     		
     		b_pan2.add(b_add);
     		b_pan2.add(b_del);
     		b_pan3.add(b_say);
     		b_pan3.add(b_delsay);
     //		b_pan2.add(b_pan3);
     		b_pan.add(b_addrecord);
			b_pan.add(b_delrecord);
		//	b_pan.add(b_say);
			b_pan.add(b_cancel);
			b_pan4.setLayout(new GridLayout(4,1));
			b_pan4.add(b_pan1);
			b_pan4.add(b_pan2);
			b_pan4.add(b_pan3);
			b_pan4.add(b_pan);
			add(b_pan4);
		//	admin.setSize(350,300);
		//	admin.setLocation(330,300);
		    setVisible(true);
		//	setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);	
     	   }
     }
     
     else{
     	 //administrator.dispose();
    	 JOptionPane.showMessageDialog(null,"您输入的密码不正确,请重新输入.");//消息框显示.
}
    	}  
    if(e.getSource()==a_cancel){
    	administrator.dispose();
    	menuBar.setVisible(true);
    }	
    if(e.getSource()==b_cancel){
    	b_pan4.setVisible(false);
    	p.setVisible(true);
  //  	menudenglu.setVisible(true);
   // 	menuhere.setVisible(true);
        menuBar.setVisible(true);
    	world1=1;
    }		  
   if(e.getSource()==b_addrecord){//添加记录
    //	admin.dispose();
    	System.out.println("b_ddrecord");
    }
     if(e.getSource()==b_delrecord){//删除记录
    //	admin.dispose();
    }
     if(e.getSource()==b_add){//添加成员
    	name.add(b_t1.getText());
    	name1.add(b_t1.getText());
    	fileRandom file3=new fileRandom("成员.txt");
    	file3.writef(b_t1.getText()+" ");
    	b_t1.setText("");
    	JOptionPane.showMessageDialog(null,"添加成功!");
    	
    }
     if(e.getSource()==b_del){//删除成员
    try{	name.remove(b_cho.getSelectedItem());
            name1.remove(b_cho.getSelectedItem());
            b_cho.remove(b_cho.getSelectedItem());
            fileRandom  file6=new fileRandom("成员.txt");
            file6.delname(b_cho);
    	b_t1.setText("");
    	JOptionPane.showMessageDialog(null,"删除成功!");
    }catch(Exception e1){
    	System.out.println(e1);
    	JOptionPane.showMessageDialog(null,"没有这个成员");
    }
     }
    if(e.getSource()==b_say){//发表留言
    	
    }	
  	
 //管理员登录界面结束------------------------------------------------   		
    	if(e.getSource()==menuuser){};//用户登录
  //进入留言本.------------------------------  	
    	if(e.getSource()==menumessage){
    		
    		m_p.setLayout(new BorderLayout());
    		m_p1.add(m_text);
    		m_p.add(m_p1,"Center");
    		m_p2.setLayout(new BorderLayout());
    		m_p3.add(m_yes);
    		m_p3.add(m_del);
    		m_p2.add(m_p3,"East");
    		m_p.add(m_p2,"South");
    		add(m_p);
    		m_text.setText("world");
    		m_p.setBackground(Color.lightGray);
    		
    	p.setVisible(false);
    	m_p.setVisible(true);
    	menudenglu.setEnabled(false);
    	menuFile.setEnabled(false);
    	}
    	if(e.getSource()==m_yes){
    		m_p.setVisible(false);
    		p.setVisible(true);
    		menudenglu.setEnabled(true);
    		menuFile.setEnabled(true);
    	}
    	if(e.getSource()==m_del){
    		m_p.setVisible(false);
    		p.setVisible(true);
    		menudenglu.setEnabled(true);
    		menuFile.setEnabled(true);
    	}
  //留言结束---------------------------------  	
  
  
    }//事件响应结束------------------------------------------
    
  
  //图像类获取图像----------------------------------------  
    class Pic extends JPanel{
	Image im;
	MediaTracker tracker=new MediaTracker(this);
	Pic(String fname){
		Toolkit tool=Toolkit.getDefaultToolkit();
		im=tool.getImage(fname);
		tracker.addImage(im,0);
		try{
			tracker.waitForAll();
			
		}catch (InterruptedException e){}
			this.setPreferredSize(new Dimension(im.getWidth(this),im.getHeight(this)));
			
		}
	
	public void paintComponent(Graphics g){
         g.drawImage(im,-50,-100,this);
	}
}//图像类结束---------------------------------------------------------
   

    /**
     * Shutdown procedure when run as an application.
     */
    protected void windowClosed() {
    	
    	// TODO: Check if it is safe to close the application
    	
        // Exit application.
        System.exit(0);
    }
    

 
}
//主类结束上面所有--------------------------------------------------------------------------------------



  class fileRandom {
  	String fdata="";
  	String file="";
  	int fm=0;
  //	int x=0,y=0;
	public fileRandom(String s) {
	file=s;
	//读取文件长度--------------------------------------------------
    	try   {   
  FileInputStream   wr=new   FileInputStream(file);   
  fm=wr.available();
  System.out.println("文件长度"+fm);//通过这个m可获取单条记录长度,当只有一条记录时.
  wr.close();  
  }   catch   (Exception   e)   {   
  //   TODO   Auto-generated   catch   block   
  e.printStackTrace();
  JOptionPane.showMessageDialog(null,"用户文件内容为空!");   
  }
   //end读取文件长度------------------------------------------------ 	
	}
//	public fileRandom(){};
//向文件写入新添内容	------------------------------------------
	public void writef(String fdata){
		try{
			//byte fd[]=fdata;
			FileWriter randf=new FileWriter(file,true);	
			randf.write(fdata);
			randf.close();
			System.out.println("文件写入成功");
					}
					catch(IOException e){
						System.out.println ("error >> "+e);
					}					
    }
    
//end写入内容到文件-------------------------------------------------------------    
    public void readf(Object cells[][]){  	//文件内容显示到表格
     int i=0,j=0,k=0,m=0,n=0; 	
   
    	
     try{	FileReader	 in=new FileReader(file);
	               
	                 char r1[]=new char[300];
	                // char r2[]=new char[20];	               
	                int a=0,b=1,max=0;
	                in.read(r1);
	               	String str1=new String(r1);	       
	             in.read(r1);	              
	              while(a<fm/31)
	                {
	                	k=i;
	                	while(r1[i]!=' '&&r1[i]!='\n')
	                	{	max+=1;i++;           }
	                		char r2[]=new char[max];
	                		while(r1[k]!=' '&&r1[i]!='\n')
	                	{ r2[j]=r1[k];	j++	;k++; }
	               
	                	i+=1;	 j=0;  max=0;	            	                
	                		 if(new String(r2)!=" ")
	                		 {	cells[a][0]=file;
	                		 	cells[a][b]=new String(r2);}//显示到表格
	                		 else break;
	           //     		 x=a;y=b;
	                	b+=1;
	                if(b==4) {a+=1;b=1;}
	                    
	                }
	          
	            System.out.println(str1);
	                in.close();
	               
	           	}catch(IOException e){
			System.out.println ("error-> "+e);
		}    			
			 	              		
    } //readf方法结束.
   // public void returnxy(int f_x,int f_y){
   // 	f_x=x;f_y=y;
   // }
//读取成员文件-----------------------------
  
   public void readname(Choice name){
    System.out.println(fm);
    int i=0,j=0,k=0;
    try{	FileReader	 in=new FileReader(file);
	               
	                 char r1[]=new char[300];	                 
	                int a=0,b=1,max=0;
	                in.read(r1);
	               	String str1=new String(r1);	       
	              in.read(r1);	              
	              while(a<fm/6)
	                {
	                	k=i;
	                	while(r1[i]!=' ')
	                	{	max+=1;i++;           }
	                		char r2[]=new char[max];
	                		while(r1[k]!=' ')
	                	{ r2[j]=r1[k];	j++	;k++; }	               
	                	i+=1;	 j=0;  max=0;	            	                	                		 	                		 	
	                		  name.add(new String(r2));//添加成员到choice	                		         
	                	      
	                	 a++;              	                    
	                }
	          
	            System.out.println(str1);
	                in.close();
	               
	           	}catch(IOException ee){
			System.out.println ("error-- "+ee);
		}    			
			 	              		
    } //读取成员文件方法结束------------------.
    
   public void delname(Choice name){
    System.out.println("成员文件");
    String str2="";
    String fd="";
    int i=0,j=0,k=0;
    try{	FileReader	 in=new FileReader(file);
	               
	                 char r1[]=new char[300];
	                 	                 
	                int a=0,b=1,max=0;
	                in.read(r1);
	               	String str1=new String(r1);	       
	              in.read(r1);	              
	              while(a<fm/6)
	                {
	                	k=i;
	                	while(r1[i]!=' ')
	                	{	max+=1;i++;           }
	                		char r2[]=new char[max];
	                		while(r1[k]!=' ')
	                	{ r2[j]=r1[k];	j++	;k++; }	
	                		               
	                	i+=1;	 j=0;  max=0;	     
	                		if(new String(r2).compareTo(name.getSelectedItem())!=0)       	                	                		 	                		 	
	                		{	str2=str2+new String(r2)+" ";
	                	    
		try{
			FileWriter randf=new FileWriter(file);	
			randf.write(fd);
			randf.close();
			System.out.println("ok删除成功")	;
					}
					catch(IOException e){
						System.out.println ("error >> "+e);
					}					  
	                   }      	                    
	                	 a++;     
	                }
	          
	            System.out.println(str1);
	                in.close();
	               
	           	}catch(IOException ee){
			System.out.println ("error-- "+ee);
		}    			
			 	              		
    } //删除成员方法结束------------------.
   
}//显示结束.------------------------------------------------

⌨️ 快捷键说明

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