Source Code Cross Referenced for SMSComposerExample.java in  » IDE-Netbeans » mobility » smscomposerexample » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » mobility » smscomposerexample 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2007, Sun Microsystems, Inc.
003:         * 
004:         * All rights reserved.
005:         * 
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions
008:         * are met:
009:         * 
010:         *     * Redistributions of source code must retain the above copyright
011:         *       notice, this list of conditions and the following disclaimer.
012:         *     * Redistributions in binary form must reproduce the above copyright
013:         *       notice, this list of conditions and the following disclaimer in
014:         *       the documentation and/or other materials provided with the
015:         *       distribution.
016:         *     * Neither the name of Sun Microsystems, Inc. nor the names of its
017:         *       contributors may be used to endorse or promote products derived
018:         *       from this software without specific prior written permission.
019:         * 
020:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
021:         * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
022:         * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
023:         * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
024:         * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
025:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
026:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
027:         * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
028:         * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
029:         * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
030:         * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
031:         */
032:
033:        package smscomposerexample;
034:
035:        import javax.microedition.midlet.*;
036:        import javax.microedition.lcdui.*;
037:        import org.netbeans.microedition.lcdui.SplashScreen;
038:        import org.netbeans.microedition.lcdui.WaitScreen;
039:        import org.netbeans.microedition.lcdui.wma.SMSComposer;
040:        import org.netbeans.microedition.util.SimpleCancellableTask;
041:
042:        /**
043:         * @author devil
044:         * http://www.netbeans.org/kb/60/mobility/smscomposer.html
045:         */
046:        public class SMSComposerExample extends MIDlet implements 
047:                CommandListener {
048:
049:            private boolean midletPaused = false;
050:
051:            //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
052:            private Command exitCommand;
053:            private SimpleCancellableTask task;
054:            private WaitScreen waitScreen;
055:            private Alert alertSent;
056:            private SMSComposer smsComposer;
057:            private SplashScreen splashScreen;
058:            private Alert alertError;
059:
060:            //</editor-fold>//GEN-END:|fields|0|
061:
062:            /**
063:             * The SMSComposerExample constructor.
064:             */
065:            public SMSComposerExample() {
066:            }
067:
068:            //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
069:            //</editor-fold>//GEN-END:|methods|0|
070:
071:            //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize
072:            /**
073:             * Initilizes the application.
074:             * It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
075:             */
076:            private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize
077:                // write pre-initialize user code here
078:                //GEN-LINE:|0-initialize|1|0-postInitialize
079:                // write post-initialize user code here
080:            }//GEN-BEGIN:|0-initialize|2|
081:
082:            //</editor-fold>//GEN-END:|0-initialize|2|
083:
084:            //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction
085:            /**
086:             * Performs an action assigned to the Mobile Device - MIDlet Started point.
087:             */
088:            public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction
089:                // write pre-action user code here
090:                switchDisplayable(null, getSplashScreen());//GEN-LINE:|3-startMIDlet|1|3-postAction
091:                // write post-action user code here
092:            }//GEN-BEGIN:|3-startMIDlet|2|
093:
094:            //</editor-fold>//GEN-END:|3-startMIDlet|2|
095:
096:            //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction
097:            /**
098:             * Performs an action assigned to the Mobile Device - MIDlet Resumed point.
099:             */
100:            public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction
101:                // write pre-action user code here
102:                //GEN-LINE:|4-resumeMIDlet|1|4-postAction
103:                // write post-action user code here
104:            }//GEN-BEGIN:|4-resumeMIDlet|2|
105:
106:            //</editor-fold>//GEN-END:|4-resumeMIDlet|2|
107:
108:            //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
109:            /**
110:             * Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
111:             * @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
112:             * @param nextDisplayable the Displayable to be set
113:             */
114:            public void switchDisplayable(Alert alert,
115:                    Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch
116:                // write pre-switch user code here
117:                Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch
118:                if (alert == null) {
119:                    display.setCurrent(nextDisplayable);
120:                } else {
121:                    display.setCurrent(alert, nextDisplayable);
122:                }//GEN-END:|5-switchDisplayable|1|5-postSwitch
123:                // write post-switch user code here
124:            }//GEN-BEGIN:|5-switchDisplayable|2|
125:
126:            //</editor-fold>//GEN-END:|5-switchDisplayable|2|
127:
128:            //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction
129:            /**
130:             * Called by a system to indicated that a command has been invoked on a particular displayable.
131:             * @param command the Command that was invoked
132:             * @param displayable the Displayable where the command was invoked
133:             */
134:            public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction
135:                // write pre-action user code here
136:                if (displayable == smsComposer) {//GEN-BEGIN:|7-commandAction|1|19-preAction
137:                    if (command == SMSComposer.SEND_COMMAND) {//GEN-END:|7-commandAction|1|19-preAction
138:                        // write pre-action user code here
139:                        switchDisplayable(null, getWaitScreen());//GEN-LINE:|7-commandAction|2|19-postAction
140:                        // write post-action user code here
141:                    } else if (command == exitCommand) {//GEN-LINE:|7-commandAction|3|33-preAction
142:                        // write pre-action user code here
143:                        exitMIDlet();//GEN-LINE:|7-commandAction|4|33-postAction
144:                        // write post-action user code here
145:                    }//GEN-BEGIN:|7-commandAction|5|15-preAction
146:                } else if (displayable == splashScreen) {
147:                    if (command == SplashScreen.DISMISS_COMMAND) {//GEN-END:|7-commandAction|5|15-preAction
148:                        // write pre-action user code here
149:                        switchDisplayable(null, getSmsComposer());//GEN-LINE:|7-commandAction|6|15-postAction
150:                        // write post-action user code here
151:                    }//GEN-BEGIN:|7-commandAction|7|25-preAction
152:                } else if (displayable == waitScreen) {
153:                    if (command == WaitScreen.FAILURE_COMMAND) {//GEN-END:|7-commandAction|7|25-preAction
154:                        // write pre-action user code here
155:                        switchDisplayable(getAlertError(), getSmsComposer());//GEN-LINE:|7-commandAction|8|25-postAction
156:                        // write post-action user code here
157:                    } else if (command == WaitScreen.SUCCESS_COMMAND) {//GEN-LINE:|7-commandAction|9|24-preAction
158:                        // write pre-action user code here
159:                        switchDisplayable(getAlertSent(), getSmsComposer());//GEN-LINE:|7-commandAction|10|24-postAction
160:                        // write post-action user code here
161:                    }//GEN-BEGIN:|7-commandAction|11|7-postCommandAction
162:                }//GEN-END:|7-commandAction|11|7-postCommandAction
163:                // write post-action user code here
164:            }//GEN-BEGIN:|7-commandAction|12|
165:
166:            //</editor-fold>//GEN-END:|7-commandAction|12|
167:
168:            //<editor-fold defaultstate="collapsed" desc=" Generated Getter: splashScreen ">//GEN-BEGIN:|13-getter|0|13-preInit
169:            /**
170:             * Returns an initiliazed instance of splashScreen component.
171:             * @return the initialized component instance
172:             */
173:            public SplashScreen getSplashScreen() {
174:                if (splashScreen == null) {//GEN-END:|13-getter|0|13-preInit
175:                    // write pre-init user code here
176:                    splashScreen = new SplashScreen(getDisplay());//GEN-BEGIN:|13-getter|1|13-postInit
177:                    splashScreen.setTitle("splashScreen");
178:                    splashScreen.setCommandListener(this );
179:                    splashScreen.setText("SMS Composer Example");//GEN-END:|13-getter|1|13-postInit
180:                    // write post-init user code here
181:                }//GEN-BEGIN:|13-getter|2|
182:                return splashScreen;
183:            }
184:
185:            //</editor-fold>//GEN-END:|13-getter|2|
186:
187:            //<editor-fold defaultstate="collapsed" desc=" Generated Getter: smsComposer ">//GEN-BEGIN:|17-getter|0|17-preInit
188:            /**
189:             * Returns an initiliazed instance of smsComposer component.
190:             * @return the initialized component instance
191:             */
192:            public SMSComposer getSmsComposer() {
193:                if (smsComposer == null) {//GEN-END:|17-getter|0|17-preInit
194:                    // write pre-init user code here
195:                    smsComposer = new SMSComposer(getDisplay());//GEN-BEGIN:|17-getter|1|17-postInit
196:                    smsComposer.setTitle("smsComposer");
197:                    smsComposer.addCommand(SMSComposer.SEND_COMMAND);
198:                    smsComposer.addCommand(getExitCommand());
199:                    smsComposer.setCommandListener(this );
200:                    smsComposer.setBGColor(-3355444);
201:                    smsComposer.setFGColor(-16777216);
202:                    smsComposer.setSendAutomatically(false);
203:                    smsComposer.setPhoneNumberLabel("Phone Number:");
204:                    smsComposer.setMessageLabel("Message:");//GEN-END:|17-getter|1|17-postInit
205:                    // write post-init user code here
206:                }//GEN-BEGIN:|17-getter|2|
207:                return smsComposer;
208:            }
209:
210:            //</editor-fold>//GEN-END:|17-getter|2|
211:
212:            //<editor-fold defaultstate="collapsed" desc=" Generated Getter: waitScreen ">//GEN-BEGIN:|21-getter|0|21-preInit
213:            /**
214:             * Returns an initiliazed instance of waitScreen component.
215:             * @return the initialized component instance
216:             */
217:            public WaitScreen getWaitScreen() {
218:                if (waitScreen == null) {//GEN-END:|21-getter|0|21-preInit
219:                    // write pre-init user code here
220:                    waitScreen = new WaitScreen(getDisplay());//GEN-BEGIN:|21-getter|1|21-postInit
221:                    waitScreen.setTitle("waitScreen");
222:                    waitScreen.setCommandListener(this );
223:                    waitScreen.setTask(getTask());//GEN-END:|21-getter|1|21-postInit
224:                    // write post-init user code here
225:                }//GEN-BEGIN:|21-getter|2|
226:                return waitScreen;
227:            }
228:
229:            //</editor-fold>//GEN-END:|21-getter|2|
230:
231:            //<editor-fold defaultstate="collapsed" desc=" Generated Getter: alertError ">//GEN-BEGIN:|28-getter|0|28-preInit
232:            /**
233:             * Returns an initiliazed instance of alertError component.
234:             * @return the initialized component instance
235:             */
236:            public Alert getAlertError() {
237:                if (alertError == null) {//GEN-END:|28-getter|0|28-preInit
238:                    // write pre-init user code here
239:                    alertError = new Alert("alert", "Error", null, null);//GEN-BEGIN:|28-getter|1|28-postInit
240:                    alertError.setTimeout(Alert.FOREVER);//GEN-END:|28-getter|1|28-postInit
241:                    // write post-init user code here
242:                }//GEN-BEGIN:|28-getter|2|
243:                return alertError;
244:            }
245:
246:            //</editor-fold>//GEN-END:|28-getter|2|
247:
248:            //<editor-fold defaultstate="collapsed" desc=" Generated Getter: alertSent ">//GEN-BEGIN:|29-getter|0|29-preInit
249:            /**
250:             * Returns an initiliazed instance of alertSent component.
251:             * @return the initialized component instance
252:             */
253:            public Alert getAlertSent() {
254:                if (alertSent == null) {//GEN-END:|29-getter|0|29-preInit
255:                    // write pre-init user code here
256:                    alertSent = new Alert("alert1", "Message Sent", null, null);//GEN-BEGIN:|29-getter|1|29-postInit
257:                    alertSent.setTimeout(Alert.FOREVER);//GEN-END:|29-getter|1|29-postInit
258:                    // write post-init user code here
259:                }//GEN-BEGIN:|29-getter|2|
260:                return alertSent;
261:            }
262:
263:            //</editor-fold>//GEN-END:|29-getter|2|
264:
265:            //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand ">//GEN-BEGIN:|32-getter|0|32-preInit
266:            /**
267:             * Returns an initiliazed instance of exitCommand component.
268:             * @return the initialized component instance
269:             */
270:            public Command getExitCommand() {
271:                if (exitCommand == null) {//GEN-END:|32-getter|0|32-preInit
272:                    // write pre-init user code here
273:                    exitCommand = new Command("Exit", Command.EXIT, 0);//GEN-LINE:|32-getter|1|32-postInit
274:                    // write post-init user code here
275:                }//GEN-BEGIN:|32-getter|2|
276:                return exitCommand;
277:            }
278:
279:            //</editor-fold>//GEN-END:|32-getter|2|
280:
281:            //<editor-fold defaultstate="collapsed" desc=" Generated Getter: task ">//GEN-BEGIN:|39-getter|0|39-preInit
282:            /**
283:             * Returns an initiliazed instance of task component.
284:             * @return the initialized component instance
285:             */
286:            public SimpleCancellableTask getTask() {
287:                if (task == null) {//GEN-END:|39-getter|0|39-preInit
288:                    // write pre-init user code here
289:                    task = new SimpleCancellableTask();//GEN-BEGIN:|39-getter|1|39-execute
290:                    task
291:                            .setExecutable(new org.netbeans.microedition.util.Executable() {
292:                                public void execute() throws Exception {//GEN-END:|39-getter|1|39-execute
293:                                    smsComposer.sendSMS();
294:                                }//GEN-BEGIN:|39-getter|2|39-postInit
295:                            });//GEN-END:|39-getter|2|39-postInit
296:                    // write post-init user code here
297:                }//GEN-BEGIN:|39-getter|3|
298:                return task;
299:            }
300:
301:            //</editor-fold>//GEN-END:|39-getter|3|
302:
303:            /**
304:             * Returns a display instance.
305:             * @return the display instance.
306:             */
307:            public Display getDisplay() {
308:                return Display.getDisplay(this );
309:            }
310:
311:            /**
312:             * Exits MIDlet.
313:             */
314:            public void exitMIDlet() {
315:                switchDisplayable(null, null);
316:                destroyApp(true);
317:                notifyDestroyed();
318:            }
319:
320:            /**
321:             * Called when MIDlet is started.
322:             * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
323:             */
324:            public void startApp() {
325:                if (midletPaused) {
326:                    resumeMIDlet();
327:                } else {
328:                    initialize();
329:                    startMIDlet();
330:                }
331:                midletPaused = false;
332:            }
333:
334:            /**
335:             * Called when MIDlet is paused.
336:             */
337:            public void pauseApp() {
338:                midletPaused = true;
339:            }
340:
341:            /**
342:             * Called to signal the MIDlet to terminate.
343:             * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
344:             */
345:            public void destroyApp(boolean unconditional) {
346:            }
347:
348:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.