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

📄 fcanvas.java

📁 A MMS sender written in Java
💻 JAVA
字号:
/***************************************************************************** Description: This if a file canvas class used to display the file system on the phone                     Created By: Oscar Vivall 2005-12-14 @file        FCanvas.java COPYRIGHT All rights reserved Sony Ericsson Mobile Communications AB 2004. The software is the copyrighted work of Sony Ericsson Mobile Communications AB. The use of the software is subject to the terms of the end-user license  agreement which accompanies or is included with the software. The software is  provided "as is" and Sony Ericsson specifically disclaim any warranty or  condition whatsoever regarding merchantability or fitness for a specific  purpose, title or non-infringement. No warranty of any kind is made in  relation to the condition, suitability, availability, accuracy, reliability,  merchantability and/or non-infringement of the software provided herein. *****************************************************************************/import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import java.io.*;import java.util.*;public class FCanvas extends Canvas implements Runnable, IFConn{    private final int WIDTH, HEIGHT;    private FReader fileReader = null;        private Vector folder = null;    private boolean newFolder = true;    int numFolders = 0;    int fileIndex = 0;    int dispIndex = 0;        private MIDlet midlet;    private Display display;        private boolean running = false;    private final int TOP = 25;        public FCanvas(MIDlet m){        setFullScreenMode(true);        WIDTH = getWidth();        HEIGHT = getHeight();                midlet = m;        display = Display.getDisplay(midlet);                fileReader = new FReader(this);        start();    }        public void fileArrival(InputStream is) {        System.out.println("fuleArrival");        display.setCurrent(new MMSForm(is));    }    public void folderArrival(String name, boolean isFolder) {        if(newFolder){            System.out.println("new Folder arrival");            numFolders = 0;            fileIndex = 0;                        newFolder = false;            folder = new Vector();        }        if(isFolder){            numFolders++;        }        folder.addElement(name);    }    public void paint(Graphics g) {        g.setColor(0xFFFFFF);        g.fillRect(0, 0, WIDTH, HEIGHT);        g.setColor(0x00);        g.drawString("Select picture to send:", 0, 0, 0);        g.fillRect(0, 20, WIDTH, 2);                if(folder != null){            int index=0;            for(int i=dispIndex; i<folder.size(); i++){                if(i==fileIndex){                    g.fillRect(0, index*20 - 1 + TOP, WIDTH, 22);                    g.setColor(0xFFFFFF);                    String file = (String)folder.elementAt(i);                    g.drawString(file, 1, index*20 + TOP, 0);                    g.setColor(0x00);                    index++;                }else{                    String file = (String)folder.elementAt(i);                    g.drawString(file, 1, index*20 + TOP, 0);                    index++;                }            }        }    }    public void keyPressed(int key){        switch(key){            case -11:                midlet.notifyDestroyed();                break;            case -3:                System.out.println(fileReader.currentPath());                break;            case -1:                fileIndex = fileIndex > 0?fileIndex-1:0;                dispIndex = fileIndex>8?fileIndex-8:0;                break;            case -2:                fileIndex = fileIndex < folder.size()-1?fileIndex+1:fileIndex;                dispIndex = fileIndex>8?fileIndex-8:0;                break;            case -5:                if(fileIndex < numFolders){                    newFolder = true;                    String fname = (String)folder.elementAt(fileIndex);                    if(fileIndex==0 && fname.compareTo("../") == 0){                        System.out.println("BACK..");                        String path = fileReader.currentPath();                        for(int i=path.length()-2; i>0; i--){                            if(path.charAt(i) == '/'){                                path = path.substring(0, i+1);                                if(path.compareTo("file:///")==0){                                    fileReader.getRoot();                                }else{                                    fileReader.getFolder(path);                                }                                break;                            }                        }                    }else{                        newFolder = true;                        String name = (String) folder.elementAt(fileIndex);                        fileReader.getFolder(fileReader.currentPath() + name);                    }                }else{                    String name = (String) folder.elementAt(fileIndex);                    fileReader.getFile(fileReader.currentPath() + name);                }                break;        }    }    public void start(){        running = true;        new Thread(this).start();    }    public void stop(){        System.out.println("hideNotify()");        running = false;    }        public void showNotify(){    }    public void hideNotify(){    }    public void run() {        newFolder = true;        fileReader.getRoot();                while(running){            repaint();            try{                Thread.sleep(10);            }catch(Exception e){            }        }    }}

⌨️ 快捷键说明

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