![]()
|
||||||||
Example 2: Java Swing example for JApplet by Java Swing GUI Tool / JToolBar on BorderLayout with Actions (JButtons) / JMenuItems on JMenu / DocumentListener with JTextArea
Java Swing example for JApplet by Java Swing GUI Tool. Floatable JToolBar can be placed on BorderLayout with Action. The JMenuItems on JMenu are enabled/disabled along with JButtons on JToolBar.
For example, when the user modifies the text on JTextArea, JButton for saving the file should be activated on JToolBar. At the same time, the JMenuItem for saving the file will also be activated in JMenu.
To be notified of the modification in JTextArea, DocumentListener should be added into Document of the JTextArea.
You can download the free source code of this example: And please read about XMLPanelEdit and download the trial version of it. |
||||||||
About this exampleBy this example, you can build Applet which works as the very simple text editor. This example is a slight modification of: through which you can build some simple text editor from XML. In the original version, the main class was the subclass of XMLFrame_1_0. To make it available as JApplet, the main class is now the subclass of XMLPanel_1_0, which can be embed to ContentPane of JApplet. Because JMenu should be embed into JApplet rather than into JPanel, the main class keeps the reference to the enclosing Applet. For details, please read the above link and explore the source code which you will find under:
All the XML for Java Swing GUI are same as the original ones, so please read the above link. You will find the XML, property resource files and image files under:
You can prepare the XML for another Locale by: , which consists of the XML editor for Java Swing GUI and a set of abstract classes. You can download the trial version of this tool from: After you download and extract it, please copy xmlrun_try.jar in the directory where this README.html resides. Then, go to:
and start to compile the source. You will find the shell script which compiles the source files and places the compiled class tree into:
In case of Windows platform, please modify this script suitable for your environment. After you compile the source tree, please go to:
Then, there is another shell script for building the single distribution JAR file for the intended Applet. It first copies xmlrun_try.jar as text_editor.jar and update it with the compiled class tree and other required files (XML, property resource files and image files). Again, in case of Windows platform, please modify this script suitable for your environment. HTML for Applet / Access PrivilegesAll the classes and required resources (such as XML, property files and image files) can be loaded from the single JAR file. Please place your JAR file under the document base of your web server so that it is available at the URL something like:
Then, your HTML can point your JAR file by the applet tag like below:
Assuming that your HTML is accessible at the URL of:
you can start appletviewer from the console by typing:
Because the example Applet requires the privileges for its actions,
must define the following permissions:
In case of Windows platform, please modify/add the FilePermission for the available disk drives. Running Applet within IE or Mozilla by JavaPlug-In
In the age of JDK 1.0.x, everything was easy. Because the most popular web browser (at that time, it was Netscape) implemented the JVM which was completely compatible with Sun's JDK. It was a good old day. Everybody can run any Applet within her/his web browser. And the Java developers in the world can publish their Applet without bothering about the web browsers. But, since JDK 1.1.x, no web browsers in the world do not catch up with Sun's JDK. Moreover, Microsoft shipped their web browser with something like Java. Whenever you develop your Applet today, you must take account of the browser compatibility.
Then, you will see
You can specify the single HTML file or the directory to be converted. |
|
|||||||
|
Java and all Java-based trademarks and logos are trademarks or registered of Sun Microsystems, Inc. in the United States and other countries. |
||||||||
|
ALL CONTENTS COPYRIGHT 1997-2007, OOP-Research Corporation. All rights reserved. |
||||||||