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

📄 readme.java

📁 soure code for j2me browser
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		Row panel3= new Row("to Panel3");				panel3.addCommand(show3);		panel3.setCommandListener(this);//		 to get the best optical results its good to add image icons with text inside popup menus		Row alert= new Row(FireIO.getLocalImage("logo"),Lang.get("Show Alert"));  				alert.addCommand(alertCmd); // for a demonstration of panel alerts go to the alertCmd 														  // handling code in the commandAction() method		alert.setCommandListener(this);				menu.add(panel2);		menu.add(panel3);		menu.add(alert);		// There are two ways to display a popup. 		// The first is by directly calling the FireScreen.getScreen(null).showPopup(myPopup);		// The second is indirectly by associating it with a softkey command on a panel using 		// the panel.addCommand(popup,command) method like below:		menuCmd = new Command(Lang.get("Menu"),Command.BACK,1); // set the Command  as BACK in order to be assigned on the left softkey		helloPanel.addCommand(menuCmd,menu);				// In every case you are responsible for calling the FireScreen.getScreen(null).closePopup() method,		// when you want the popup to close (see menu handling code in commandAction() method) 				// thats it for this panel. Go to createPanel2() and createPanel(3) methods to continue with the demonstration.		return helloPanel;	}			/**	 * This method demonstrates the Ticker, and the DateTimeRow	 *  	 * @return A panel	 */	public Panel createPanel2()	{		Panel panel = new Panel();		panel.setLabel(Lang.get("Second Panel"));		panel.setCommandListener(this);		// A ticket is a very simple component it shows a string that scrolls on the top of the Panel.		// A panel can have only one ticker.		FTicker ticker = new FTicker(Lang.get("This is a ticker that does not inform you about anything usefull"));		panel.setTicker(ticker);						// now lets add a button with an image, that changes when selected.		Row button = new Row("Fire & Water",FireIO.getLocalImage("fire"));		button.setSelectedImage(FireIO.getLocalImage("water"));		button.addCommand(new Command("",Command.OK,1)); // we dont want any action, just add the command and listener 		button.setCommandListener(this);									  // to make the component traversable		button.setAlignment(FireScreen.CENTRE);		panel.add(button);						// now lets add a DateTimeRow. This components allows , as the name implies, the user to input date and time.		// The DateTimeRow has two modes, it can display only the date, or the date and the time (if isShowTime()==true)		// The user can make the date/time selection either by tapping on the appropriate field or by pressing fire on it,		// using the joystick of the device.		DateTimeRow dtr = new DateTimeRow(Calendar.getInstance(),true);		dtr.setLabel(Lang.get("Enter your age"));// The DateTimeRow can optionally have a Label. 		panel.add(dtr);				// If we want we can allow the user to change the orientation of the screen, at runtime.		// We will add a listbox with the three available orientation options: Normal, landscape left, landscape right.		panel.add(new Row(Lang.get("You can select the screen mode you prefer:")));		ListBox orientationChoice = new ListBox(); 				orientationChoice.setBullet(FireIO.getLocalImage("box"));  		orientationChoice.setSelectedBullet(FireIO.getLocalImage("checkedbox"));  				ListElement normal = new ListElement(Lang.get("Normal mode"),"N",false);		ListElement left = new ListElement(Lang.get("Left-handed Landscape"),"L",false);		ListElement right = new ListElement(Lang.get("Right-handed Landscape"),"R",false);				// set the correct element as selected.		int or = screen.getOrientation();		switch(or)		{			case FireScreen.NORMAL:				normal.setChecked(true);				break;			case FireScreen.LANDSCAPELEFT:				left.setChecked(true);				break;			default:				right.setChecked(true);		}				orientationChoice.add(normal); // the ListBox contains list elemens.		orientationChoice.add(left);		orientationChoice.add(right);				// each ListElement, has a text description, an object identifier (or payload) and a state (selected or not).		orientation  = new Command("",Command.OK,1);		orientationChoice.addCommand(orientation); // go to the corresponding location in the commandAction method. 		orientationChoice.setCommandListener(this);		panel.add(orientationChoice);								// finally we add a command to go back to the previous panel.		// we will add this command both on a Softkey and on a row item on the panel.		Row back = new Row("Back",FireIO.getLocalImage("logo"));		back.addCommand(show1);		back.setCommandListener(this);		panel.add(back);				panel.addCommand(show1);												return panel;	}	/**	 * This method demostrates how to dynamically add and remove components from a Panel.	 * @return	 */	public Panel createPanel3()	{		Panel panel = new Panel();		panel.setLabel(Lang.get("Adding components."));		panel.setCommandListener(this);		panel.addCommand(show1);		reset = new Command(Lang.get("Reset"),Command.OK,1); // resets the panel.		panel.addCommand(reset);				more = new Command("",Command.OK,1);		Row moreRow = new Row(Lang.get("More"));		moreRow.setAlignment(FireScreen.CENTRE);		moreRow.addCommand(more);		moreRow.setCommandListener(this);		less = new Command("",Command.OK,1);		Row lessRow = new Row(Lang.get("Less"));		lessRow.setAlignment(FireScreen.CENTRE);		lessRow.addCommand(less);		lessRow.setCommandListener(this);						panel.add(new Row("Pressing more will add a new row to the panel. Pressing less will remove one row from the panel."));		panel.add(moreRow);		panel.add(lessRow);		panel.add(new Row()); // empty line.		// Check the commandAction method for the code and comments on dynamic adding/removing components.				return panel;	}		protected void pauseApp()	{	}	protected void destroyApp(boolean arg0) throws MIDletStateChangeException	{		// In order to stop the clock thread, and clean up you must 		// call the destroy method on the FireScreen singleton, 		// when you exit. 		screen.destroy();		//... thanks for reading :)	}	/**	 * All the actions in this demo use this CommandListener's commandAction. 	 * Check the individual comments for each example.	 * 	 * @see gr.bluevibe.fire.util.CommandListener#commandAction(javax.microedition.lcdui.Command, gr.bluevibe.fire.components.Component)	 */	public void commandAction(Command cmd, Component c)	{			if(cmd==exit)		{ // exit requested , check the comments on the destroyApp method.			notifyDestroyed();			return;		}				if(cmd==update)		{			// get the text entered on the textField			String name = textField.getText();			// set it on the nameRow:			nameRow.setText(name);			// Validate nameRow.			nameRow.validate();			screen.repaint();			return;		}		if(cmd==selection)		{			// get the selected ListElement.			ListElement selected = (ListElement)((ListBox)c).getCheckedElements().elementAt(0); // single selection means always only one checked			if(((String)selected.getId()).equals("N")) // check the id Object of the ListElement. We set "N" to normal and "B" to Busy.			{ // Normal Mode 				screen.setBusyMode(false); // disable busy mode.			}			else			{ // set busy mode, busy mode is usefull for notifing the user that a task is underway in the background. 				// If interractive mode is true, the GUI continues to function normally, and the small animation is displayed on the bottom of the screen.				// otherwise only the cancel command is allowed.								screen.setBusyMode(true); // disable busy mode.			}			return;		}				if(cmd==show1) // return to main menu		{			// if returning to the main menu is going-back , then lets make the transition animation move from left to right			screen.setCurrent(createPanel(),FireScreen.RIGHT);			return;		}				if(cmd==more) // on panel3 , add more components to the panel		{			Panel panel3 = screen.getCurrentPanel();			panel3.add(new Row("One more row, panel now has "+(panel3.countRows()+1)));			panel3.validate();			return;		}		if(cmd==less) // on panel3 , remove components from the panel		{			Panel panel3 = screen.getCurrentPanel();			panel3.remove(panel3.countRows()-1); // remove last component.			panel3.resetPointer(); // reset the pointer position.			panel3.validate();			return;		}		if(cmd==reset) //on panel3, reset.		{			screen.setCurrent(createPanel3());		}				/* Menu Commands Handling Code */		if(cmd==show2)		{			screen.closePopup(); // first close the popup.			screen.setCurrent(createPanel2());			return;		}		if(cmd==show3)		{			screen.closePopup(); // first close the popup.			screen.setCurrent(createPanel3());			return;		}		if(cmd==alertCmd)		{			screen.closePopup(); // first close the popup.			// The panel has an alertUser method, witch displays an alert-like message to the user. 			// This can be very usefull for reporting errors,warnings etc in order to display an alert 			// you can call the showAlert method on the current panel.						screen.getCurrentPanel().showAlert(Lang.get("An alert is a popup box containing a message and/or an image. Any action from the user dismisses the alert"),null);						return;		}		if(cmd==orientation)		{			ListElement selected = (ListElement)((ListBox)c).getCheckedElements().elementAt(0); // single selection means always only one checked			String id = ((String)selected.getId());			if(id.equals("N"))			{ // Normal Mode 				screen.setOrientation(FireScreen.NORMAL);			}			else if(id.equals("L"))			{ 				screen.setOrientation(FireScreen.LANDSCAPELEFT);			}			else			{				screen.setOrientation(FireScreen.LANDSCAPERIGHT);			}			return;		}		if(cmd==cancel)		{			screen.setBusyMode(false);		}		/* End or Menu Commands */			}}

⌨️ 快捷键说明

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