📄 function.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 Function extends GameCanvas implements Runnable{ int screenWidth; int screenHeight; private Graphics g; public Thread thread; int choice; String file_transfer, setting, help, exit; public boolean select_pressed; Font font_label; DisplayMain main; protected Function(DisplayMain m) { super(true); screenWidth=176; screenHeight=220; font_label = Font.getFont (Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_LARGE); main =m; setFullScreenMode(true); thread =new Thread(this); thread.start(); g = this.getGraphics(); draw(); } public void draw() { choice =0; draw_choice(choice); } public void draw_choice(int c) { g.setColor(255,255,255); g.fillRect(0,0,screenWidth,screenHeight); draw_image ("function_bg.png", screenWidth, screenHeight,Graphics.BOTTOM|Graphics.RIGHT); g.setColor(255,190,33); g.fillRect(0,screenHeight/7,screenWidth,2); g.setFont(font_label); g.setColor(0,0,0); file_transfer="file_transfer_small.png"; setting= "setting_small.png"; help= "help_small.png"; exit = "exit_small.png"; if (c ==0) { file_transfer="file_transfer_large.png"; g.drawString("File Transfer", screenWidth/2, 4, Graphics.TOP|Graphics.HCENTER); draw_image("select_shade.png",screenWidth/3/2-1,screenHeight/7+5 + screenHeight*6/7/3/2 , Graphics.VCENTER|Graphics.HCENTER); } if (c==1) { setting= "setting_large.png"; g.drawString("Setting", screenWidth/2, 4, Graphics.TOP|Graphics.HCENTER); draw_image("select_shade.png",screenWidth/3/2+screenWidth/3-1,screenHeight/7+5 + screenHeight*6/7/3/2 , Graphics.VCENTER|Graphics.HCENTER); } if (c ==2) { help= "help_large.png"; g.drawString("Help", screenWidth/2, 4, Graphics.TOP|Graphics.HCENTER); draw_image("select_shade.png",screenWidth/3/2+(screenWidth/3)*2-1,screenHeight/7 +5+ screenHeight*6/7/3/2, Graphics.VCENTER|Graphics.HCENTER); } if (c ==3) { exit = "exit_large.png"; g.drawString("Exit", screenWidth/2, 4, Graphics.TOP|Graphics.HCENTER); draw_image("select_shade.png",screenWidth/3/2-1,screenHeight/7+5 + screenHeight*6/7/3/2+screenHeight*6/7/3, Graphics.VCENTER|Graphics.HCENTER); } draw_image(file_transfer ,screenWidth/3/2,screenHeight/7+5 + screenHeight*6/7/3/2 , Graphics.VCENTER|Graphics.HCENTER); draw_image(setting ,screenWidth/3/2+screenWidth/3,screenHeight/7+5 + screenHeight*6/7/3/2 , Graphics.VCENTER|Graphics.HCENTER); draw_image(help ,screenWidth/3/2+(screenWidth/3)*2,screenHeight/7+5 + screenHeight*6/7/3/2 , Graphics.VCENTER|Graphics.HCENTER); draw_image(exit ,screenWidth/3/2,screenHeight/7+5 + screenHeight*6/7/3/2+screenHeight*6/7/3 , Graphics.VCENTER|Graphics.HCENTER); 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); } public void key_Pressed() { int keyState =getKeyStates(); if ((keyState & UP_PRESSED) !=0) { if (choice ==3) { choice =0; }else{ choice =3; } draw_choice(choice); } if ((keyState & DOWN_PRESSED) !=0) { if (choice ==3) { choice =0; }else{ choice =3; } draw_choice(choice); } if ((keyState & LEFT_PRESSED) !=0) { choice --; if (choice <0) { choice =3; } draw_choice(choice); } if ((keyState & RIGHT_PRESSED) !=0) { choice ++; if (choice >3) { choice =0; } draw_choice(choice); } if ((keyState & FIRE_PRESSED) !=0) { select_pressed =true; if (choice ==3) { main.destroyApp(false); main.notifyDestroyed(); } if (choice ==0) { main.update_filelist(-1); } if (choice ==2) { main.help_screen(); } if (choice ==1) { if (main.sound_setting == true) { main.setting_screen("Open", main.default_ip); } if (main.sound_setting == false) { main.setting_screen("Close", main.default_ip); } } } } public void run() { while (!select_pressed) { key_Pressed(); try { Thread.sleep(100); }catch (InterruptedException ie) {} } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -