📄 splashscreen.java
字号:
/* I BlueTooth You -- Simple BlueTooth talker Copyright (C) 2007 Jan Tomka This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */package net.sf.btw.ibtu.ui;import javax.microedition.lcdui.Display;import javax.microedition.lcdui.Displayable;import javax.microedition.lcdui.Canvas;import javax.microedition.lcdui.Font;import javax.microedition.lcdui.Graphics;/** * This class defines an initial appliction canvas -- the splash screen. * * @author Jan Tomka * TODO Remove OK command and dismiss at any key pressed. */public class SplashScreen extends Canvas { /** * Reference to the {@link javax.microedition.lcdui.Display} the splash * screen is displayed on. */ private Display display; /** * Reference to the {@link javax.microedition.lcdui.Displayable} which is to * be set as current after splash screen is OK'ed. */ private Displayable nextDisplayable; /** * Color used to draw background of a splash screen. */ private final int backgroundColor = 0xffffff; /** * Color used to draw the text of a splash screen. */ private final int textColor = 0xbbbbbb; /** * Small font used to draw text of a splash screen. */ private final Font smallFont = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_ITALIC, Font.SIZE_SMALL); /** * Large font used to draw text of a splash screen. */ private final Font largeFont = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_ITALIC, Font.SIZE_LARGE); /** * Creates new SplashScreen instance. * * @param display * Display the splash screen is painted on. * @param nextDisplayable * Displayable to be switched to after splash screen is OK'ed. */ public SplashScreen(Display display, Displayable nextDisplayable) { super(); this.display = display; this.nextDisplayable = nextDisplayable; } /** * Paints the splash screen itself. * * @param g * {@link Graphics} to paint a splash screen on. */ // TODO Redo to fit on smaller screens, add the version information. public void paint(Graphics g) { g.setColor(backgroundColor); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(textColor); g.setFont(largeFont); String str[] = { "BTChat", "(c) 2008 Dimmetrius", "" }; int yOffset[] = { -largeFont.getHeight(), 0, smallFont.getHeight() }; g.drawString(str[0], getWidth() / 2, getHeight() / 2 + yOffset[0], Graphics.BASELINE | Graphics.HCENTER); g.setFont(smallFont); g.drawString(str[1], getWidth() / 2, getHeight() / 2 + yOffset[1], Graphics.BASELINE | Graphics.HCENTER); g.drawString(str[2], getWidth() / 2, getHeight() / 2 + yOffset[2], Graphics.BASELINE | Graphics.HCENTER); } public void keyPressed(int keyCode) { display.setCurrent(nextDisplayable); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -