Source Code Cross Referenced for MMSSend.java in  » IDE-Netbeans » mobility » example » mms » 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 » example.mms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *
003:         * Copyright (c) 2007, Sun Microsystems, Inc.
004:         *
005:         * All rights reserved.
006:         *
007:         * Redistribution and use in source and binary forms, with or without
008:         * modification, are permitted provided that the following conditions
009:         * are met:
010:         *
011:         *  * Redistributions of source code must retain the above copyright
012:         *    notice, this list of conditions and the following disclaimer.
013:         *  * Redistributions in binary form must reproduce the above copyright
014:         *    notice, this list of conditions and the following disclaimer in the
015:         *    documentation and/or other materials provided with the distribution.
016:         *  * Neither the name of Sun Microsystems nor the names of its contributors
017:         *    may be used to endorse or promote products derived from this software
018:         *    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
023:         * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
024:         * 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:        package example.mms;
033:
034:        import javax.microedition.io.*;
035:        import javax.microedition.lcdui.*;
036:        import javax.microedition.midlet.*;
037:
038:        import javax.wireless.messaging.*;
039:
040:        /**
041:         * An example MIDlet to send text via an MMS MessageConnection
042:         */
043:        public class MMSSend extends MIDlet implements  CommandListener {
044:            /** user interface command for indicating Exit request. */
045:            private static Command CMD_EXIT = new Command("Exit", Command.EXIT,
046:                    2);
047:
048:            /** user interface command for sending the message */
049:            private static Command CMD_SEND = new Command("Send", Command.ITEM,
050:                    1);
051:
052:            /** user interface command for adding message's part */
053:            private static Command CMD_ADD_PART = new Command("Add Part",
054:                    Command.ITEM, 1);
055:
056:            /** current display. */
057:            private Display display;
058:
059:            /** The application-ID on which we send MMS messages */
060:            private String appID;
061:
062:            /** Area where the user enters the subject of the message */
063:            private TextField subjectField;
064:
065:            /** Area where the user enters the phone number to send the message to */
066:            private TextField destinationField;
067:
068:            /** Area where the user enters the phone number to send the message to */
069:            private StringItem partsLabel;
070:
071:            /** Error message displayed when an invalid phone number is entered */
072:            private Alert errorMessageAlert;
073:
074:            /** Alert that is displayed when a message is being sent */
075:            private Alert sendingMessageAlert;
076:
077:            /** The last visible screen when we paused */
078:            private Displayable resumeScreen = null;
079:            private MMSMessage message;
080:            private PartsDialog partsDialog;
081:
082:            /**
083:             * Initialize the MIDlet with the current display object and
084:             * graphical components.
085:             */
086:            public MMSSend() {
087:                appID = getAppProperty("MMS-ApplicationID");
088:
089:                display = Display.getDisplay(this );
090:
091:                Form mainForm = new Form("New MMS");
092:
093:                subjectField = new TextField("Subject:", null, 256,
094:                        TextField.ANY);
095:                mainForm.append(subjectField);
096:
097:                destinationField = new TextField("Destination Address: ",
098:                        "mms://", 256, TextField.ANY);
099:                mainForm.append(destinationField);
100:
101:                partsLabel = new StringItem("Parts:", "0");
102:                mainForm.append(partsLabel);
103:
104:                mainForm.addCommand(CMD_EXIT);
105:                mainForm.addCommand(CMD_SEND);
106:                mainForm.addCommand(CMD_ADD_PART);
107:                mainForm.setCommandListener(this );
108:
109:                errorMessageAlert = new Alert("MMS", null, null,
110:                        AlertType.ERROR);
111:                errorMessageAlert.setTimeout(5000);
112:
113:                sendingMessageAlert = new Alert("MMS", null, null,
114:                        AlertType.INFO);
115:                sendingMessageAlert.setTimeout(5000);
116:                sendingMessageAlert.setCommandListener(this );
117:
118:                resumeScreen = mainForm;
119:
120:                message = new MMSMessage();
121:            }
122:
123:            /**
124:             * startApp should return immediately to keep the dispatcher
125:             * from hanging.
126:             */
127:            public void startApp() {
128:                display.setCurrent(resumeScreen);
129:            }
130:
131:            /**
132:             * Remember what screen is showing
133:             */
134:            public void pauseApp() {
135:                resumeScreen = display.getCurrent();
136:            }
137:
138:            /**
139:             * Destroy must cleanup everything.
140:             * @param unconditional true if a forced shutdown was requested
141:             */
142:            public void destroyApp(boolean unconditional) {
143:            }
144:
145:            /**
146:             * Respond to commands, including exit
147:             * @param c user interface command requested
148:             * @param s screen object initiating the request
149:             */
150:            public void commandAction(Command c, Displayable s) {
151:                try {
152:                    if ((c == CMD_EXIT) || (c == Alert.DISMISS_COMMAND)) {
153:                        destroyApp(false);
154:                        notifyDestroyed();
155:                    } else if (c == CMD_ADD_PART) {
156:                        if (partsDialog == null) {
157:                            partsDialog = new PartsDialog(this );
158:                        }
159:
160:                        partsDialog.show();
161:                    } else if (c == CMD_SEND) {
162:                        promptAndSend();
163:                    }
164:                } catch (Exception ex) {
165:                    ex.printStackTrace();
166:                }
167:            }
168:
169:            void show() {
170:                partsLabel.setText(Integer.toString(partsDialog.counter));
171:                display.setCurrent(resumeScreen);
172:            }
173:
174:            Display getDisplay() {
175:                return display;
176:            }
177:
178:            MMSMessage getMessage() {
179:                return message;
180:            }
181:
182:            /**
183:             * Prompt for and send the message
184:             */
185:            private void promptAndSend() {
186:                try {
187:                    String address = destinationField.getString();
188:                    message.setSubject(subjectField.getString());
189:                    message.setDestination(address);
190:
191:                    String statusMessage = "Sending message to " + address
192:                            + "...";
193:                    sendingMessageAlert.setString(statusMessage);
194:
195:                    new SenderThread(message, appID).start();
196:                } catch (IllegalArgumentException iae) {
197:                    errorMessageAlert.setString(iae.getMessage());
198:                    display.setCurrent(errorMessageAlert);
199:                }
200:            }
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.