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

📄 readme.java

📁 soure code for j2me browser
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * Fire (Flexible Interface Rendering Engine) is a set of graphics widgets for creating GUIs for j2me applications.  * Copyright (C) 2006  Bluebird co (www.bluebird.gr) * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. *  *  * This library 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 * Lesser General Public License for more details. *  * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA *  *//* * Created on Nov 26, 2006 */package gr.bluevibe.fire.test;import java.util.Calendar;import java.util.Hashtable;import gr.bluevibe.fire.components.Component;import gr.bluevibe.fire.components.DateTimeRow;import gr.bluevibe.fire.components.FTicker;import gr.bluevibe.fire.components.ListBox;import gr.bluevibe.fire.components.ListElement;import gr.bluevibe.fire.components.Panel;import gr.bluevibe.fire.components.Popup;import gr.bluevibe.fire.components.Row;import gr.bluevibe.fire.displayables.FireScreen;import gr.bluevibe.fire.displayables.SplashScreen;import gr.bluevibe.fire.util.CommandListener;import gr.bluevibe.fire.util.FireIO;import gr.bluevibe.fire.util.Lang;import javax.microedition.lcdui.Canvas;import javax.microedition.lcdui.Command;import javax.microedition.lcdui.Display;import javax.microedition.lcdui.Font;import javax.microedition.lcdui.TextField;import javax.microedition.midlet.MIDlet;import javax.microedition.midlet.MIDletStateChangeException;/** *  * This Midlet is a demonstration and a walk-through on developing a GUI using the Fire Engine.  *  * Read the comments in the source for details. *  * On the following walk through I assume you've gone throught the documentation and got a general idea of what each Fire class does. *  * In order for the FireScreen singleton to initialize correctly it must have a theme file.  * So make sure you have the default theme provided with the source.   *  *  * @author padeler * */public class ReadMe extends MIDlet implements CommandListener{	/* These vars are used in the examples below */	private Command exit,cancel, update,selection,show2,show3,alertCmd,menuCmd,reset,more,less,orientation;	private Command show1 = new Command("Back",Command.BACK,1);	private Row nameRow,textField;	private FireScreen screen;		/* ****************************************** */	/**	 * A midlet that will demostrate the capabilities of the Fire Components and 	 * how to use them. 	 *	 */	public ReadMe()	{	}	protected void startApp() throws MIDletStateChangeException	{		// The first step is to initialize the FireIO. 		// The FireScreen class uses the FireIO in order to load the 		// theme image so we really need to do this first.		// Most of the lines here could be ommited, if the default values are ok.				Hashtable mediaMap = new Hashtable(); // The hashtable maps key string to file 																		  // name that are located either in the jar or at a web location.				mediaMap.put(FireScreen.THEME_FILE,"theme.png"); // THEME_FILE is the default key for the theme image		mediaMap.put("logo","cafe.png"); // some other media we are going to use later on the tutorial.		mediaMap.put("box","box.png");  		mediaMap.put("checkedbox","checkedbox.png");		mediaMap.put("fire","fire.jpg");  		mediaMap.put("water","water.jpg");  				// we setup the FireIO with the mediaMap we just created, and a cache size=10.		// This means that up to 10 images will be cached in the FireIO class. 		// The downloadLocation is null because all our images will be local.   		FireIO.setup(mediaMap,10,null); 						// I want to have a nice splash screen while my application initializes 		// so i will use the SplashScreen class before doing anything else.         SplashScreen loading = new SplashScreen();         loading.setTitle("Fire Demo"); // set the title of the splash screen        loading.setLogo(FireIO.getLocalImage("logo")); // show a nice logo.        // Note that i used the FireIO.getLocalImage in order to load the logo image.         // The getLocalImage method will first look in the cache for the image, then in the record store,         // thirdly in the jar and finally (if a url was provided on setup()) it will try to download the image and         // store it locally. If the image is found on a location it is cached, in case of a later request.                Display.getDisplay(this).setCurrent(loading); // show the load screen.                // now we continue with the start up proccess:                // First we load the default language bundle:        Lang.loadBundle(); // this is optional if you dont want to use the Lang class for i18n                        // Secondly set the location of the theme logo, on the top border of each panel.         // This is optional, the default value is FireScreen.RIGHT, other possible values are FireScreen.CENTER and FireScreen.LEFT.        FireScreen.setLogoPossition(FireScreen.LEFT);                        // Thirdly we initialize the FireScreen.        screen = FireScreen.getScreen(Display.getDisplay(this));        // A request to the FireScreen.getSctreen() with null parameter, returns the singleton if initialized        // ie : screen = FireScreen.getScreen(null); returns the same screen object, thus there is no need for keeping the pointer.        // For the scope of this demo, we will use the screen variable instead of calling the FireScreen.getScreen(null) each time.        screen.setFullScreenMode(true); // set the FireScreen to full screen mode.                 // You can set the orientation of the screen, normal, or landscape (right handed or left handed)        screen.setOrientation(FireScreen.NORMAL); // normal is the default orientation        screen.setOrientationChangeKey(new Integer(Canvas.KEY_STAR));  // no preset key is the default. You can reset that by setting null key.                // set the screen to a non interractive busy mode. That means that no user action is allowed while the screen is in busy mode.        screen.setInteractiveBusyMode(false); // false is the default value.                // and thats with the initialization proccess ... in a real application there would be more stuff to do here        // now we will create out first panel        Panel p = createPanel(); // look in the method comments for details.                screen.setCurrent(p); // set the current panel on the FireScreen.  	}		/**	 * Demonstrates how to create a simple panel on Fire engine. 	 * It shows the use of Row as a means to display images, text, create textfields, links (or buttons) etc. 	 * It also demonstrates the  use of a ListBox, and the Busy mode of the FireScreen.	 * Finally it shows how to create a popup menu.	 */	public Panel createPanel()	{		Panel helloPanel = new Panel(); // create instance		helloPanel.setLabel(Lang.get("Fire Demo")); // set label (displayed on the top of the screen)		// ok we have a panel now, lets add some functionallity		exit = new Command(Lang.get("Exit"),Command.EXIT,1);		helloPanel.addCommand(exit); // add the command to the panel, 		// it will be displayed on the bottom bar on the right, and assigned to the righ softkey.		// The Panel checks the type of the command added. If it is Command.BACK 		// it is assigned to the left softkey, otherwise it goes to the right. 				// now set the cancel command (it is displayed only if the FireScreen is on busy mode		cancel = new Command(Lang.get("Cancel"),Command.CANCEL,1);		helloPanel.addCommand(cancel);						// now set the CommandListener of the panel.		helloPanel.setCommandListener(this);		// this class implements a CommandListener.		// for notes on the listener go to the commandAction method.				// ok, up to now we have a very simple application. 		// next step is to add a couple of rows to our panel.				Row simpleText = new Row(Lang.get("This is a text only row. The string can have any size, and the alligment can be set both horizontally and verytically"));		simpleText.setTextHpos(FireScreen.CENTRE); // the default V/H pos is TOP/LEFT, you dont have to set these every time.		simpleText.setTextVpos(FireScreen.TOP);		helloPanel.add(simpleText);						Row imageText = new Row(Lang.get("This is a row that has both text and an image. The image can be before or after the text."),FireIO.getLocalImage("fire"));		helloPanel.add(imageText);						// in order to make the UI clearer we can add an empty row.		helloPanel.add(new Row()); // you can comment this out to see the difference.				// another type of seperator or header can be a line of color, with or without a text label		Row seperator = new Row();		seperator.setFilled(new Integer(FireScreen.defaultFilledRowColor)); // use the default color of the theme.		seperator.setBorder(true); // borders look nice :)		seperator.setText(Lang.get("TextFields & Commands")); // a string can be usefull on a header.		seperator.setFont(Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_BOLD,Font.SIZE_SMALL)); // change the font		seperator.setAlignment(FireScreen.CENTRE); // allign the text to the centre.		helloPanel.add(seperator);				// now lets add a text area		textField = new Row();		textField.setEditable(true); // when a row is set as editable 													 // it gets a min height equal to the Fonts height.				// you can even add a label on a row, so lets add one to our textField example		textField.setLabel(Lang.get("What is your name?"),									  FireScreen.defaultLabelFont,									  new Integer(screen.getWidth()/2), // set the width of the label to be half the screen width.									  																						   // this helps with the alligment of multiple textfields.									  																						   // If you dont care about the label width, you can leave this null									  FireScreen.CENTRE); // The alligment of the label in the row (applicable if row.height>labeltext.heigh)				textField.setTextBoxConstrains(TextField.INITIAL_CAPS_WORD); // if a row is editable it gets the same constratints as a TextBox		textField.setTextBoxSize(20); // max name size=20		// when a user enters text on a text field you can get it back using the getText() method. 		helloPanel.add(textField); // finally add it to the panel.				// now lets add some components with commands		nameRow = new Row(); 		nameRow.setLabel(Lang.get("Your name is"),FireScreen.defaultLabelFont,new Integer(screen.getWidth()/2),FireScreen.CENTRE);		helloPanel.add(nameRow);				// Create a "button" that will update the text in the nameRow, with the one set on the textField.		update = new Command("",Command.OK,1);		Row updateButton = new Row(Lang.get("Update"));		updateButton.setAlignment(FireScreen.RIGHT); // set it on the right		updateButton.addCommand(update); // set the command		updateButton.setCommandListener(this); 		helloPanel.add(updateButton);						// add another seperator. Before we continue to the next component		seperator = new Row();		seperator.setFilled(new Integer(FireScreen.defaultSecondaryFilledRowColor)); // use the default color of the theme.		seperator.setBorder(true);		seperator.setImage(FireIO.getLocalImage("logo")); // add an image		seperator.setText(Lang.get("ListBox & Gauge")); // and a text		seperator.setImageHpos(FireScreen.LEFT); // set image horizontal possition on the left		seperator.setTextHpos(FireScreen.RIGHT); // set text pos to the right		/* Note:		 * Setting the horizontal location of images and text on a row can be done in a single line 		 * by using the "new Row(Image, String)" or the "new Row(String, Image)" constructors.		 */		seperator.setFont(Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_BOLD,Font.SIZE_MEDIUM)); // change the font		seperator.setAlignment(FireScreen.CENTRE); // allign the text to the centre.		helloPanel.add(seperator);						// Now we will make a list of items, and demonstrate the use of the busy indicator.				ListBox choice = new ListBox(); // a listbox is an area that shown a list of choices.														  // it can function as a set of checkboxes (multiple selection)														  // or are a set radio buttons ( single selection, default)		choice.setMultiple(false); // radio buttons mode (default)				choice.setBullet(FireIO.getLocalImage("box"));  // if not set, a filled circle is drawn as a bullet..		choice.setSelectedBullet(FireIO.getLocalImage("checkedbox"));  // comment these two lines to see the difference.						// For this demo we will use the single selection, to turn busy mode on and off.		choice.add(new ListElement(Lang.get("Normal mode"),"N",true)); // the ListBox contains list elemens.		choice.add(new ListElement(Lang.get("Busy mode"),"B",false)); 		// each ListElement, has a text description, an object identifier (or payload) and a state (selected or not).		selection = new Command("",Command.OK,1);		choice.addCommand(selection); // go to the corresponding location in the commandAction method. 		choice.setCommandListener(this);		helloPanel.add(choice);				// The last part of the demo, on this panel will be to create a popup menu. 		// Throught this menu we will move to other Panels demonstrating more of the engines capabilities.		Popup menu = new Popup(); // create a popup instance.				// instantiate some commands				show2 = new Command("",Command.OK,1);		show3 = new Command("",Command.OK,1);		alertCmd = new Command("",Command.OK,1);		// in a popup panel you can add everything you add on a normal panel.		// it even shown a scrollbar if you put too much elements in it.		Row panel2= new Row("to Panel2");		panel2.addCommand(show2);		panel2.setCommandListener(this);

⌨️ 快捷键说明

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