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

📄 filelist.java

📁 手机控制邮件以及附件的发送
💻 JAVA
字号:
package remote.display;// standardimport java.io.ByteArrayInputStream;import java.util.Hashtable;import java.util.Stack;//micro editionimport javax.microedition.lcdui.*;import javax.microedition.lcdui.game.*;import javax.microedition.midlet.*;import javax.microedition.io.*;import java.io.*;class FileList extends GameCanvas implements Runnable{	int screenWidth;	int screenHeight;	private Graphics g;	Font font_label;	Font font_text;	public Thread thread;	public boolean select_pressed;	public int choice;	public int display_choice;	int type;	int list_size;	public int progress_h;	//private boolean scrollbar =false;	public String selected_text="test";	DisplayMain main;	int no_file_selected;	protected FileList(DisplayMain m) {		super(true);		screenWidth=128;		screenHeight=160;		font_label = Font.getFont (Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM);		font_text = Font.getFont (Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);		main =m;		setFullScreenMode(true);		select_pressed=false;		thread=new Thread(this);		thread.start();		no_file_selected=0;		progress_h = screenHeight/8+1;		g= this.getGraphics();		draw();	}	public void draw() {		choice=0;		type=0;		display_choice=0;		draw_choice();	}	public void draw_choice() {		int c = display_choice;		int t = type;		g.setColor(255,255,255);		g.fillRect(0,0,screenWidth,screenHeight);		draw_image ("function_bg.png", screenWidth, screenHeight,Graphics.BOTTOM|Graphics.RIGHT);		draw_label(0,0,t);		draw_select_pic(0, screenHeight/8+1+(display_choice*font_text.getHeight()));		draw_list(screenHeight/8+1,t);		draw_scroll_bar(t);		g.setColor(255,255,255);		g.fillRect(screenWidth,0,200,screenHeight);		flushGraphics();	}	private void draw_image(String image_name, int x, int y, int anchor){		Image pic =null;		try{			pic =Image.createImage("/"+image_name);		} catch (IOException e) {			System.out.println ("load png resource error" + e.getMessage());		}		g.drawImage (pic, x, y, anchor);	}	private void list_structure(int t,int c,int y){		if (t==0) {//drive			for (int i=0; i <list_size ; i++) {				draw_image("disk.png",2,y+(i*font_text.getHeight()),Graphics.TOP|Graphics.LEFT);				g.setColor(0,0,0);				g.setFont(font_text);				g.drawString(main.drive_name[c+i].substring(0,main.drive_name[c+i].length()-1),20, y+(i*font_text.getHeight()), Graphics.TOP|Graphics.LEFT);			}		}else{			for (int i=0; i <list_size ; i++) {				if (c+i<main.dir_name.length){					draw_image("close_folder.png",2,y+(i*font_text.getHeight()),Graphics.TOP|Graphics.LEFT);					g.setColor(0,0,0);					g.setFont(font_text);					g.drawString(main.dir_name[c+i],20, y+(i*font_text.getHeight()), Graphics.TOP|Graphics.LEFT);				}else{					draw_image("file.png",2,y+(i*font_text.getHeight()),Graphics.TOP|Graphics.LEFT);					g.setColor(0,0,0);					g.setFont(font_text);					g.drawString(main.file_name[c+i-main.dir_name.length],20, y+(i*font_text.getHeight()), Graphics.TOP|Graphics.LEFT);				}			}		}	}	private void draw_list(int y, int type){		int j;		if (type ==0) {			if (main.drive_name.length>9) {				list_size=9;					if (display_choice==0){						list_structure(0,choice,y);					}					if(display_choice==1){						list_structure(0,choice-1,y);					}					if(display_choice==2){						list_structure(0,choice-2,y);					}					if(display_choice==3){						list_structure(0,choice-3,y);					}					if(display_choice==4){						list_structure(0,choice-4,y);					}					if(display_choice==5){						list_structure(0,choice-5,y);					}					if(display_choice==6){						list_structure(0,choice-6,y);					}					if(display_choice==7){						list_structure(0,choice-7,y);					}					if(display_choice==8) {						list_structure(0,choice-8,y);					}			}else{				list_size=main.drive_name.length;				list_structure(0,0,y);			}		}else {			if (main.dir_name.length+main.file_name.length>9) {				list_size=9;					if (display_choice==0){						list_structure(type,choice,y);					}					if(display_choice==1){						list_structure(type,choice-1,y);					}					if(display_choice==2){						list_structure(type,choice-2,y);					}					if(display_choice==3){						list_structure(type,choice-3,y);					}					if(display_choice==4){						list_structure(type,choice-4,y);					}					if(display_choice==5){						list_structure(type,choice-5,y);					}					if(display_choice==6){						list_structure(type,choice-6,y);					}					if(display_choice==7){						list_structure(type,choice-7,y);					}					if(display_choice==8) {						list_structure(type,choice-8,y);					}			}else{				list_size=main.dir_name.length+main.file_name.length;				list_structure(type,0,y);			}		}	}	private void draw_scroll_bar(int type) {		int h;		if (type==0) {			if (main.drive_name.length>9){				h=9*9*font_text.getHeight()/main.drive_name.length;				g.setColor(250,180,10);				g.fillRect(screenWidth-6, screenHeight/8+1,6,9*font_text.getHeight());				System.out.println(h);				g.setColor(251,224,171);				g.fillRect(screenWidth-5,progress_h,4,h);			}		}else {			if (main.dir_name.length+main.file_name.length>9){				h=9*9*font_text.getHeight()/(main.dir_name.length+main.file_name.length);				g.setColor(250,180,10);				g.fillRect(screenWidth-6, screenHeight/8+1,6,9*font_text.getHeight());				System.out.println(h);				g.setColor(251,224,171);				g.fillRect(screenWidth-5,progress_h,4,h);			}		}	}	private void draw_select_pic(int x, int y) {		int[] maskArray;		maskArray = new int[screenWidth*font_text.getHeight()];		for (int i = 0; i < screenWidth*font_text.getHeight(); i++) {				maskArray[i] = 0xCDFFD163; //set to orange color		}		g.drawRGB(maskArray,0,screenWidth,x, y, screenWidth,font_text.getHeight(),true);	}	private void draw_label(int x, int y, int t) {		int[] maskArray;		maskArray = new int[screenWidth*screenHeight/8];		for (int i = 0; i < screenWidth*screenHeight/8; i++) {			if (i >= screenWidth*screenHeight/8-screenWidth*1){				maskArray[i]=0x00FFFFFF; //set to gery color			}else{				maskArray[i] = 0xCDFFD163; //set to orange color			}		}		g.drawRGB(maskArray,0,screenWidth,x, y, screenWidth, screenHeight/8,true);		if (t==0){			draw_image("computer.png",2,2,Graphics.TOP|Graphics.LEFT);			g.setColor(0,0,0);			g.setFont(font_label);			g.drawString("My computer",15, 2, Graphics.TOP|Graphics.LEFT);		}		if (t ==1) {			draw_image("disk.png",2,2,Graphics.TOP|Graphics.LEFT);			g.setColor(0,0,0);			g.setFont(font_label);			g.drawString(selected_text,20, 2, Graphics.TOP|Graphics.LEFT);		}		if (t==2) {			draw_image("open_folder.png",2,2,Graphics.TOP|Graphics.LEFT);			g.setColor(0,0,0);			g.setFont(font_label);			g.drawString(selected_text,20, 2, Graphics.TOP|Graphics.LEFT);		}	}	public void key_Pressed() {		int keyState =getKeyStates();		if ((keyState & UP_PRESSED) !=0) {			choice --;			display_choice--;			if (type ==0) {				if (main.drive_name.length>9){					if(display_choice==0){						if(choice==0) {							display_choice=0;						}else{							progress_h=(screenHeight/8+1)+(choice-1)*9*font_text.getHeight()/main.drive_name.length;							display_choice=1;						}					}					if(display_choice<0) {						progress_h=screenHeight/8+1+9*font_text.getHeight()-9*9*font_text.getHeight()/main.drive_name.length;						display_choice=8;						choice=main.drive_name.length-1;					}				}else{					if (display_choice <0) {						display_choice =main.drive_name.length-1;						choice=main.drive_name.length-1;					}				}			}else {				if (main.dir_name.length+main.file_name.length>9){					if(display_choice==0){						if(choice==0) {							display_choice=0;						}else{							progress_h=(screenHeight/8+1)+(choice-1)*9*font_text.getHeight()/(main.dir_name.length+main.file_name.length);							display_choice=1;						}					}					if(display_choice<0) {						progress_h=screenHeight/8+1+9*font_text.getHeight()-9*9*font_text.getHeight()/(main.dir_name.length+main.file_name.length);						display_choice=8;						choice=(main.dir_name.length+main.file_name.length)-1;						main.file_list_screen.addCommand(main.previewCommand);						main.file_list_screen.addCommand(main.detailCommand);					}				}else{					if (display_choice <0) {						display_choice =(main.dir_name.length+main.file_name.length)-1;						choice=(main.dir_name.length+main.file_name.length)-1;						main.file_list_screen.addCommand(main.previewCommand);						main.file_list_screen.addCommand(main.detailCommand);					}				}				if(choice==main.dir_name.length-1) {					main.file_list_screen.removeCommand(main.previewCommand);					main.file_list_screen.removeCommand(main.detailCommand);				}			}			draw_choice();			System.out.println ("currentpath="+main.currentpath);		}		if ((keyState & DOWN_PRESSED) !=0) {			choice ++;			display_choice++;			if (type ==0) {				if (main.drive_name.length>9){					if(display_choice==8){						if(choice==main.drive_name.length-1) {							display_choice=8;						}else{							progress_h=(screenHeight/8+1)+((choice-7)*9*font_text.getHeight()/main.drive_name.length);							display_choice=7;						}					}					if(display_choice>8) {						progress_h=screenHeight/8+1;						display_choice=0;						choice=0;					}				}else{					if (display_choice >main.drive_name.length-1) {						display_choice =0;						choice=0;					}				}			}else{				if (main.dir_name.length+main.file_name.length>9){					if(display_choice==8){						if(choice==(main.dir_name.length+main.file_name.length)-1) {							display_choice=8;						}else{							progress_h=(screenHeight/8+1)+((choice-7)*9*font_text.getHeight()/(main.dir_name.length+main.file_name.length));							display_choice=7;						}					}					if(display_choice>8) {						progress_h=screenHeight/8+1;						display_choice=0;						choice=0;						main.file_list_screen.removeCommand(main.previewCommand);						main.file_list_screen.removeCommand(main.detailCommand);					}				}else{					if (display_choice >(main.dir_name.length+main.file_name.length)-1) {						display_choice =0;						choice=0;						main.file_list_screen.removeCommand(main.previewCommand);						main.file_list_screen.removeCommand(main.detailCommand);					}				}				if(choice==main.dir_name.length) {					main.file_list_screen.addCommand(main.previewCommand);					main.file_list_screen.addCommand(main.detailCommand);				}			}			draw_choice();		}		if ((keyState & FIRE_PRESSED) !=0) {			main.file_selected();			try {				Thread.sleep(200);			}catch (InterruptedException ie) {}		}	}	public void run() {		while (!select_pressed) {			key_Pressed();			try {				Thread.sleep(20);			}catch (InterruptedException ie) {}		}	}}

⌨️ 快捷键说明

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