?? setcontact.java
字號(hào):
/* * Copyright 2004 Grzegorz Grasza groz@gryf.info * * This file is part of mobber. Mobber 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. * Mobber 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 mobber; * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA . */import javax.microedition.lcdui.*;import java.util.*;public class SetContact extends Form implements CommandListener{ TextField jid, name, newgroup, message; ChoiceGroup choice; public SetContact(String jid) { super(Label.setcontact); this.jid = new TextField("JID", jid, 64, TextField.EMAILADDR); name = new TextField(Label.name, (String)mobber.roster.names.get(jid), 32, TextField.ANY); Enumeration groups = mobber.roster.presentGroups.keys(); choice = new ChoiceGroup (null, Choice.MULTIPLE); while(groups.hasMoreElements()) { int e = 0; String eg = (String)groups.nextElement(); while(choice.size()>e && choice.getString(e).compareTo(eg)<0) e++; choice.insert(e, eg, null); if(mobber.roster.groups.get(jid) != null) { Enumeration enum = ((Vector)mobber.roster.groups.get(jid)).elements(); while(enum.hasMoreElements()) if(jid != null && choice.getString(e).equals(enum.nextElement())) choice.setSelectedIndex(e, true); } } newgroup = new TextField(Label.newgroup, "", 32, TextField.ANY); message = new TextField(Label.message, Label.text, 64, TextField.ANY); append(this.jid); append(name); append(choice); append(newgroup); append(message); addCommand(Action.ok); addCommand(Action.cancel); setCommandListener(this); } private class Groups implements Enumeration { boolean[] selected; int e = -1, i = 0; int num; public Groups(int number, boolean[] selected) { this.selected = selected; num = number; } public boolean hasMoreElements() { if(num > i) return true; return false; } public Object nextElement() { while(!selected[++e]); ++i; return choice.getString(e); } }; public void commandAction(Command c, Displayable s) { if(c == Action.ok) { if(newgroup.getString().equals("") && !jid.getString().equals("")) { boolean[] selected = new boolean[choice.size()]; int selectednum = choice.getSelectedFlags(selected); if(!mobber.roster.names.containsKey(jid.getString())) mobber.jabber.sendPresence(jid.getString(), "subscribe", null , message.getString(), 0); mobber.jabber.setContact(jid.getString(), name.getString(), new Groups(selectednum, selected), null); mobber.display.setCurrent(mobber.roster); } else if(!newgroup.getString().equals("")) { choice.setSelectedIndex(choice.append(newgroup.getString(), null), true); newgroup.setString(""); } } else mobber.display.setCurrent(mobber.roster); }};
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -