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

📄 connectionmenu.java

📁 一个不错的多媒体传输程序
💻 JAVA
字号:
/* * Movino J2ME Client * Copyright (C) 2007  Johannes Berg *  * 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. *  * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. */package org.movino.connection;import java.io.IOException;import javax.microedition.lcdui.Command;import javax.microedition.lcdui.CommandListener;import javax.microedition.lcdui.Display;import javax.microedition.lcdui.Displayable;import javax.microedition.lcdui.Form;import javax.microedition.lcdui.List;import javax.microedition.lcdui.TextField;import javax.microedition.lcdui.Ticker;import org.movino.Options;import org.movino.Returnable;import org.movino.Showable;public class ConnectionMenu extends Returnable implements CommandListener{	private static final String CONNECT_BLUETOOTH="Bluetooth";	private static final String CONNECT_SOCKET="Internet";	private static final String[] CONNECTION_MENU = new String[]{CONNECT_BLUETOOTH,CONNECT_SOCKET};	private Command selectCommand;	private Command backCommand;		private List connectionMenu;		private Form socketForm;		private TextField serverAddress;	private TextField serverPort;		private Command connectCommand;	private Command cancelCommand;		public ConnectionMenu(){	}		public void show(Display display) {		selectCommand = new Command("Select", Command.ITEM, 1);		backCommand = new Command("Back", Command.BACK, 1);				connectionMenu = new List("Connect",List.IMPLICIT,CONNECTION_MENU,null);		connectionMenu.setCommandListener(this);		connectionMenu.addCommand(backCommand);		connectionMenu.setSelectCommand(selectCommand);				socketForm = new Form("IP connect");		socketForm.setCommandListener(this);		connectCommand = new Command("Connect", Command.OK, 1);		socketForm.addCommand(connectCommand);		cancelCommand = new Command("Cancel", Command.CANCEL, 1);		socketForm.addCommand(cancelCommand);				serverAddress = new TextField("Address", Options.optionServer,100,TextField.URL);		socketForm.append(serverAddress);		serverPort = new TextField("Port", ""+MovinoConnection.DEFAULT_TCP_PORT,10,TextField.NUMERIC);		socketForm.append(serverPort);				display.setCurrent(connectionMenu);	}		public void reShow(Display display){		display.setCurrent(connectionMenu);	}	public void commandAction(Command cmd, Displayable disp){		if(disp==connectionMenu){			if(cmd==selectCommand){				int sel_index = connectionMenu.getSelectedIndex();				String sel = CONNECTION_MENU[sel_index];				if(sel==CONNECT_BLUETOOTH){					try {						Returnable s = (Returnable)Class.forName("org.movino.connection.BluetoothSearch").newInstance();						s.show(getDisplay(), getReturnShowable());					}					catch(Throwable t){						alert("Could not find bluetooth on this device");					}				}				else if(sel==CONNECT_SOCKET){					getDisplay().setCurrent(socketForm);				}			}			else if(cmd==backCommand){				returnBack();			}		}		else if(disp==socketForm){			if(cmd==connectCommand){				try {					Options.optionServer = serverAddress.getString();					ConnectionDialog cd = new ConnectionDialog(new SocketConnection(serverAddress.getString(),Integer.parseInt(serverPort.getString())));					cd.show(getDisplay(), getReturnShowable());				} catch (NumberFormatException e) {					alert("Port must be numeric");				}			}			else if(cmd==cancelCommand){				getDisplay().setCurrent(connectionMenu);			}		}	}}

⌨️ 快捷键说明

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