📄 barcodereader.java
字号:
package barcodereader;import java.io.IOException;import javax.microedition.lcdui.Canvas;import javax.microedition.lcdui.Display;import javax.microedition.lcdui.Font;import javax.microedition.lcdui.Graphics;import javax.microedition.lcdui.Image;import javax.microedition.midlet.MIDlet;public class BarcodeReader extends MIDlet{ public Display display; public Image background, buffer; public Graphics graphics; public Font font; public MainMenu mainmenu; public int heightoffset, bufferwidth, bufferheight, width, height, halfwidth, halfheight, fontheight; private SplashScreen splashscreen; public BarcodeReader() { display = Display.getDisplay(this); try{ background = Image.createImage(getClass().getResourceAsStream( "/image/background.PNG")); } catch(IOException ioe) { ioe.printStackTrace(); } heightoffset = 22; buffer = Image.createImage(176, 220); graphics = buffer.getGraphics(); bufferwidth = buffer.getWidth(); bufferheight = buffer.getHeight(); graphics.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL)); font = graphics.getFont(); fontheight = font.getHeight(); splashscreen = new SplashScreen(); mainmenu = new MainMenu(this); } public void startApp() { splashscreen.setFullScreenMode(true); display.setCurrent(splashscreen); try{ Thread.sleep(3000); } catch(InterruptedException ie) { ie.printStackTrace(); } mainmenu.setFullScreenMode(true); display.setCurrent(mainmenu); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } private class SplashScreen extends Canvas{ private Image splashscreen; public SplashScreen() { width = getWidth(); height = getHeight(); halfwidth = width/2; halfheight = height/2 + heightoffset; try{ splashscreen = Image.createImage(getClass().getResourceAsStream( "/image/splashscreen.PNG")); } catch(IOException ioe) { ioe.printStackTrace(); } } public void paint(Graphics g) { graphics.setColor(0, 0, 0); graphics.fillRect(0, 0, bufferheight, bufferwidth); graphics.drawImage(splashscreen, 0, 0, Graphics.LEFT | Graphics.TOP); g.setColor(0, 0, 0); g.fillRect(0, 0, width, height); g.drawImage(background, halfwidth, halfheight, Graphics.HCENTER | Graphics.VCENTER); g.drawImage(buffer, halfwidth, halfheight, Graphics.HCENTER | Graphics.VCENTER); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -