aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/examples
diff options
context:
space:
mode:
authorMark Wielaard <mark@gcc.gnu.org>2005-11-15 23:20:01 +0000
committerMark Wielaard <mark@gcc.gnu.org>2005-11-15 23:20:01 +0000
commit8f523f3a1047919d3563daf1ef47ba87336ebe89 (patch)
treea5eb7cf42a51869cc8aa1fad7ad6a90cca47fdd8 /libjava/classpath/examples
parent02e549bfaaec38f68307e7f34e46ea57ea1809af (diff)
downloadgcc-8f523f3a1047919d3563daf1ef47ba87336ebe89.zip
gcc-8f523f3a1047919d3563daf1ef47ba87336ebe89.tar.gz
gcc-8f523f3a1047919d3563daf1ef47ba87336ebe89.tar.bz2
Imported GNU Classpath 0.19 + gcj-import-20051115.
* sources.am: Regenerated. * Makefile.in: Likewise. * scripts/makemake.tcl: Use glob -nocomplain. From-SVN: r107049
Diffstat (limited to 'libjava/classpath/examples')
-rw-r--r--libjava/classpath/examples/Makefile.in12
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java4
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java31
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/DemoServer.java (renamed from libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/comServer.java)10
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoServant.java (renamed from libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comServant.java)32
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoTester.java (renamed from libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comTester.java)16
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java40
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java56
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPass.java (renamed from libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThis.java)9
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java (renamed from libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHelper.java)19
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHolder.java (renamed from libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHolder.java)14
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturn.java (renamed from libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThis.java)9
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java (renamed from libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHelper.java)17
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHolder.java (renamed from libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHolder.java)14
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNode.java (renamed from libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/node.java)15
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java (renamed from libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHelper.java)44
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHolder.java (renamed from libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHolder.java)32
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisException.java (renamed from libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException.java)11
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java (renamed from libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserExceptionHelper.java)18
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterImplBase.java (renamed from libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterImplBase.java)31
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterStub.java (renamed from libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterStub.java)37
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/midi/Demo.java137
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/swing/ButtonDemo.java284
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/swing/ClasspathSwingActivityBoard.launch19
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/swing/ComboBoxDemo.java360
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/swing/Demo.java214
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/swing/FileChooserDemo.java228
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/swing/GNULookAndFeel.java184
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/swing/ProgressBarDemo.java219
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/swing/ScrollBarDemo.java141
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/swing/SliderDemo.java249
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/swing/TextFieldDemo.java488
32 files changed, 2685 insertions, 309 deletions
diff --git a/libjava/classpath/examples/Makefile.in b/libjava/classpath/examples/Makefile.in
index 5c067bc..f688ab7 100644
--- a/libjava/classpath/examples/Makefile.in
+++ b/libjava/classpath/examples/Makefile.in
@@ -41,10 +41,8 @@ subdir = examples
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/Makefile.jawt.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/../../config/depstand.m4 \
- $(top_srcdir)/../../config/lead-dot.m4 \
- $(top_srcdir)/../../config/no-executables.m4 \
- $(top_srcdir)/../../libtool.m4 $(top_srcdir)/m4/accross.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
+ $(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \
$(top_srcdir)/m4/acinclude.m4 $(top_srcdir)/m4/iconv.m4 \
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/pkg.m4 \
@@ -86,10 +84,14 @@ CLASSPATH_MODULE = @CLASSPATH_MODULE@
CP = @CP@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
+CREATE_ALSA_LIBRARIES_FALSE = @CREATE_ALSA_LIBRARIES_FALSE@
+CREATE_ALSA_LIBRARIES_TRUE = @CREATE_ALSA_LIBRARIES_TRUE@
CREATE_API_DOCS_FALSE = @CREATE_API_DOCS_FALSE@
CREATE_API_DOCS_TRUE = @CREATE_API_DOCS_TRUE@
CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
+CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
+CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -226,6 +228,7 @@ build_vendor = @build_vendor@
datadir = @datadir@
default_toolkit = @default_toolkit@
exec_prefix = @exec_prefix@
+glibjdir = @glibjdir@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
@@ -239,6 +242,7 @@ libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
+nativelibdir = @nativelibdir@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java
index b4a3772..fb5ebdb 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java
@@ -73,7 +73,7 @@ import org.omg.CosNaming.NamingContextHelper;
*/
public class Demo
{
- public static void main(final String[] args)
+ public static void main(String[] an_args)
{
// We create the following naming graph:
// <ROOT CONTEXT>
@@ -90,6 +90,8 @@ public class Demo
System.out.println("Starting the GNU Classpath " +
"built-in transient naming service"
);
+
+ final String[] args = an_args;
new Thread()
{
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java
index 85f233a..f53609c 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package gnu.classpath.examples.CORBA.SimpleCommunication;
+import java.io.File;
+
import gnu.classpath.examples.CORBA.SimpleCommunication.communication.DirectTest;
import gnu.classpath.examples.CORBA.SimpleCommunication.communication.RequestTest;
@@ -61,23 +63,34 @@ public class Demo
{
public static void main(final String[] args)
{
+ File ior = new File("IOR.txt");
+ if (ior.exists())
+ ior.delete();
+
// Start the server.
new Thread()
{
public void run()
{
- comServer.start_server(args);
+ DemoServer.start_server(args);
}
}.start();
- System.out.println("Waiting for three seconds for the server to start...");
-
- // Pause some time for the server to start.
- try {
- Thread.sleep(3000);
- }
- catch (InterruptedException ex) {
- }
+ System.out.print("Waiting for the server to start ");
+ while (!ior.exists())
+ {
+ // Pause some time for the server to start.
+ try
+ {
+ Thread.sleep(200);
+ }
+ catch (InterruptedException ex)
+ {
+ }
+ System.out.print(".");
+ }
+ System.out.println("ok.");
+ System.out.println();
// Test the stream oriented communication.
DirectTest.main(args);
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/comServer.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/DemoServer.java
index d4e0c56..d7b1a77 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/comServer.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/DemoServer.java
@@ -1,4 +1,4 @@
-/* comServer.java --
+/* DemoServer.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.classpath.examples.CORBA.SimpleCommunication;
-import gnu.classpath.examples.CORBA.SimpleCommunication.communication.comServant;
+import gnu.classpath.examples.CORBA.SimpleCommunication.communication.DemoServant;
import org.omg.CORBA.ORB;
@@ -47,7 +47,7 @@ import java.io.PrintStream;
/**
* This is the server class that handles the client requests,
- * delegating the functionality to the {@link comServant}.
+ * delegating the functionality to the {@link DemoServant}.
*
* When starting, the server writes the IOR.txt file into the current
* folder. With the information, stored in this file, the server
@@ -62,7 +62,7 @@ import java.io.PrintStream;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class comServer
+public class DemoServer
{
public static void main(String[] args)
@@ -78,7 +78,7 @@ public class comServer
final ORB orb = org.omg.CORBA.ORB.init(args, null);
// Create the servant and register it with the ORB.
- comServant tester = new comServant();
+ DemoServant tester = new DemoServant();
orb.connect(tester);
// Storing the IOR reference.
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comServant.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoServant.java
index 08d1759..c07b77b 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comServant.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoServant.java
@@ -1,4 +1,4 @@
-/* comServant.java --
+/* DemoServant.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,12 +45,6 @@ import org.omg.CORBA.DoubleHolder;
import org.omg.CORBA.ShortHolder;
import org.omg.CORBA.StringHolder;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.PrintStream;
-
/**
* This class handles the actual server functionality in this test
* application. When the client calls the remote method, this
@@ -62,8 +56,8 @@ import java.io.PrintStream;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class comServant
- extends _comTesterImplBase
+public class DemoServant
+ extends _DemoTesterImplBase
{
/**
* The field, that can be set and checked by remote client.
@@ -129,7 +123,7 @@ public class comServant
/**
* Accept and return the structures.
*/
- public returnThis passStructure(passThis in_structure)
+ public StructureToReturn passStructure(StructureToPass in_structure)
{
System.out.println("SERVER: ***** Transferring structures");
System.out.println("SERVER: Received " + in_structure.a + ":" +
@@ -137,7 +131,7 @@ public class comServant
);
// Create and send back the returned structure.
- returnThis r = new returnThis();
+ StructureToReturn r = new StructureToReturn();
r.c = in_structure.a + in_structure.b;
r.n = 555;
r.arra = new int[] { 11, 22, 33 };
@@ -147,14 +141,14 @@ public class comServant
/**
* Pass and return the tree structure
*/
- public void passTree(nodeHolder tree)
+ public void passTree(TreeNodeHolder tree)
{
System.out.println("SERVER: ***** Transferring tree");
StringBuffer b = new StringBuffer();
// This both creates the tree string representation
- // and changes the node names.
+ // and changes the TreeNode names.
getImage(b, tree.value);
System.out.println("SERVER: The tree was: " + b + ", returning changed.");
}
@@ -190,11 +184,11 @@ public class comServant
*
* @param parameter specifies which exception will be thrown.
*
- * @throws ourUserException for the non negative parameter.
+ * @throws WeThrowThisException for the non negative parameter.
* @throws BAD_OPERATION for the negative parameter.
*/
public void throwException(int parameter)
- throws ourUserException
+ throws WeThrowThisException
{
System.out.println("SERVER: ***** Testing exceptions");
if (parameter > 0)
@@ -202,7 +196,7 @@ public class comServant
System.out.println("SERVER: Throwing the user exception, " +
"specific field = "+parameter
);
- throw new ourUserException(parameter);
+ throw new WeThrowThisException(parameter);
}
else
{
@@ -215,12 +209,12 @@ public class comServant
/**
* Visit all tree nodes, getting the string representation
- * and adding '++' to the node names.
+ * and adding '++' to the TreeNode names.
*
* @param b the buffer to collect the string representation.
- * @param n the rott tree node.
+ * @param n the rott tree TreeNode.
*/
- private void getImage(StringBuffer b, node n)
+ private void getImage(StringBuffer b, TreeNode n)
{
b.append(n.name);
n.name = n.name + "++";
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comTester.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoTester.java
index 495807e..f3766f3 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comTester.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoTester.java
@@ -1,4 +1,4 @@
-/* comTester.java --
+/* DemoTester.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,12 +45,12 @@ import org.omg.CORBA.StringHolder;
/**
* The interface of our remote object. Some IDL compiles split it
- * into "comTester" and "comTesterOperations", but we do not see
+ * into "DemoTester" and "comTesterOperations", but we do not see
* much sense in doing this here.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public interface comTester
+public interface DemoTester
{
/**
* Passes wide (UTF-16) string and narrow (ISO8859_1) string.
@@ -77,14 +77,14 @@ public interface comTester
/**
* Passes and returns the structures.
*/
- returnThis passStructure(passThis in_structure);
+ StructureToReturn passStructure(StructureToPass in_structure);
/**
* Pass and return the tree structure
*
- * @param tree the root node of the tree.
+ * @param tree the root TreeNode of the tree.
*/
- void passTree(nodeHolder tree);
+ void passTree(TreeNodeHolder tree);
/**
* Just prints the "Hello" message.
@@ -102,10 +102,10 @@ public interface comTester
void theField(int newTheField);
/**
- * Throws either 'ourUserException' with the 'ourField' field
+ * Throws either 'WeThrowThisException' with the 'ourField' field
* initialised to the passed positive value
* or system exception (if the parameter is zero or negative).
*/
void throwException(int parameter)
- throws ourUserException;
+ throws WeThrowThisException;
}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java
index 5cf372b..732b00c 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java
@@ -57,7 +57,7 @@ import java.io.IOException;
* where the program has been started.
*
* The IOR.txt file is written by the server
- * {@link gnu.classpath.examples.CORBA.SimpleCommunication.comServer}.
+ * {@link gnu.classpath.examples.CORBA.SimpleCommunication.DemoServer}.
* The server should be reachable over Internet, unless blocked by
* security tools.
*
@@ -83,7 +83,7 @@ public class DirectTest
/**
* The invocation target.
*/
- comTester object;
+ DemoTester object;
/**
* Get the object reference.
@@ -102,7 +102,7 @@ public class DirectTest
String ior = new String(c);
DirectTest we = new DirectTest();
- we.object = (comTester) orb.string_to_object(ior);
+ we.object = (DemoTester) orb.string_to_object(ior);
we.Demo();
orb.shutdown(false);
}
@@ -199,11 +199,11 @@ public class DirectTest
{
System.out.println("***** Pass structure");
- passThis arg = new passThis();
+ StructureToPass arg = new StructureToPass();
arg.a = "A";
arg.b = "B";
- returnThis r = object.passStructure(arg);
+ StructureToReturn r = object.passStructure(arg);
System.out.println(" Fields of the returned structure:");
@@ -257,15 +257,15 @@ public class DirectTest
// +-- bb
System.out.println("***** Pass and return the tree.");
- node n = nod("Root");
+ TreeNode n = nod("Root");
- n.children = new node[] { nod("a"), nod("b") };
- n.children [ 1 ].children = new node[] { nod("ba"), nod("bb") };
- n.children [ 1 ].children [ 0 ].children = new node[] { nod("bac") };
+ n.children = new TreeNode[] { nod("a"), nod("b") };
+ n.children [ 1 ].children = new TreeNode[] { nod("ba"), nod("bb") };
+ n.children [ 1 ].children [ 0 ].children = new TreeNode[] { nod("bac") };
- nodeHolder nh = new nodeHolder(n);
+ TreeNodeHolder nh = new TreeNodeHolder(n);
- // The server should add '++' to each node name.
+ // The server should add '++' to each TreeNode name.
object.passTree(nh);
// Convert the returned tree to some strig representation.
@@ -288,7 +288,7 @@ public class DirectTest
object.throwException(123);
throw new InternalError();
}
- catch (ourUserException uex)
+ catch (WeThrowThisException uex)
{
System.out.println(" The user exception with field " + uex.ourField +
", has been thrown on remote side."
@@ -312,9 +312,9 @@ public class DirectTest
/**
* Get the string representation of the passed tree.
* @param b the string buffer to accumulate the representation.
- * @param n the tree (root node).
+ * @param n the tree (root TreeNode).
*/
- private void getImage(StringBuffer b, node n)
+ private void getImage(StringBuffer b, TreeNode n)
{
b.append(n.name);
b.append(": (");
@@ -328,15 +328,15 @@ public class DirectTest
}
/**
- * Create a node with the given header.
+ * Create a TreeNode with the given header.
*
- * @param hdr the node header.
- * @return the created node.
+ * @param hdr the TreeNode header.
+ * @return the created TreeNode.
*/
- private node nod(String hdr)
+ private TreeNode nod(String hdr)
{
- node n = new node();
- n.children = new node[ 0 ];
+ TreeNode n = new TreeNode();
+ n.children = new TreeNode[ 0 ];
n.name = hdr;
return n;
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java
index 977fb42..9c908e5 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java
@@ -1,3 +1,39 @@
+/* RequestTest.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath 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, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
@@ -7,14 +43,10 @@ import java.io.FileReader;
import java.io.IOException;
import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ByteHolder;
-import org.omg.CORBA.DoubleHolder;
import org.omg.CORBA.ExceptionList;
import org.omg.CORBA.NVList;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Request;
-import org.omg.CORBA.ShortHolder;
-import org.omg.CORBA.StringHolder;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.UnknownUserException;
@@ -25,7 +57,7 @@ import org.omg.CORBA.UnknownUserException;
* where the program has been started.
*
* The IOR.txt file is written by the server
- * {@link gnu.classpath.examples.CORBA.SimpleCommunication.comServer}.
+ * {@link gnu.classpath.examples.CORBA.SimpleCommunication.DemoServer}.
* The server should be reachable over Internet, unless blocked by
* security tools.
*
@@ -106,7 +138,6 @@ public class RequestTest
throw new InternalError();
}
testSystemException();
- testUserException();
testWideNarrowStrings();
}
@@ -135,13 +166,6 @@ public class RequestTest
Request r =
object._create_request(null, "passSimple", orb.create_list(0), null);
- ByteHolder a_byte = new ByteHolder((byte) 0);
- ShortHolder a_short = new ShortHolder((short) 3);
- StringHolder a_string = new StringHolder("[string 4]");
-
- // This is an 'out' parameter; the value must not be passed to servant.
- DoubleHolder a_double = new DoubleHolder(56.789);
-
r.add_inout_arg().insert_octet((byte) 0);
r.add_in_arg().insert_long(2);
r.add_inout_arg().insert_short((short) 3);
@@ -188,7 +212,7 @@ public class RequestTest
try
{
ExceptionList exList = orb.create_exception_list();
- exList.add(ourUserExceptionHelper.type());
+ exList.add(WeThrowThisExceptionHelper.type());
Request rq =
object._create_request(null, "throwException", orb.create_list(1),
@@ -217,7 +241,7 @@ public class RequestTest
System.out.println("**** Test user exception:");
ExceptionList exList = orb.create_exception_list();
- exList.add(ourUserExceptionHelper.type());
+ exList.add(WeThrowThisExceptionHelper.type());
Request rq =
object._create_request(null, "throwException", orb.create_list(1), null,
@@ -228,7 +252,7 @@ public class RequestTest
rq.invoke();
UnknownUserException uku = (UnknownUserException) rq.env().exception();
- ourUserException our_exception = ourUserExceptionHelper.extract(uku.except);
+ WeThrowThisException our_exception = WeThrowThisExceptionHelper.extract(uku.except);
System.out.println(" Our user exception, field " + our_exception.ourField +
", has been thrown on remote side."
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThis.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPass.java
index 2a680b9..d17e91f 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThis.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPass.java
@@ -1,4 +1,4 @@
-/* passThis.java --
+/* StructureToPass.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,9 +44,14 @@ package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class passThis
+public class StructureToPass
implements org.omg.CORBA.portable.IDLEntity
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* The first string, stored in this structure (defined as
* "narrow string").
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHelper.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java
index 6b9f4ce..c41ebe2 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHelper.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java
@@ -1,4 +1,4 @@
-/* passThisHelper.java --
+/* StructureToPassHelper.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,6 @@ exception statement from your version. */
package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
-import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
import org.omg.CORBA.TypeCode;
@@ -46,17 +45,17 @@ import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
/**
- * The helper operations for the {@link passThis}.
+ * The helper operations for the {@link StructureToPass}.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class passThisHelper
+public abstract class StructureToPassHelper
{
/**
- * The repository ID of the {@link passThis}.
+ * The repository ID of the {@link StructureToPass}.
*/
private static String id =
- "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThis:1.0";
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPass:1.0";
/**
* Get the repository id.
@@ -69,9 +68,9 @@ public abstract class passThisHelper
/**
* Read the structure from the CDR stram.
*/
- public static passThis read(InputStream istream)
+ public static StructureToPass read(InputStream istream)
{
- passThis value = new passThis();
+ StructureToPass value = new StructureToPass();
value.a = istream.read_string();
value.b = istream.read_wstring();
return value;
@@ -88,13 +87,13 @@ public abstract class passThisHelper
members [ 0 ] = new StructMember("a", member, null);
member = ORB.init().create_string_tc(0);
members [ 1 ] = new StructMember("b", member, null);
- return ORB.init().create_struct_tc(passThisHelper.id(), "passThis", members);
+ return ORB.init().create_struct_tc(StructureToPassHelper.id(), "StructureToPass", members);
}
/**
* Write the structure into the CDR stream.
*/
- public static void write(OutputStream ostream, passThis value)
+ public static void write(OutputStream ostream, StructureToPass value)
{
ostream.write_string(value.a);
ostream.write_wstring(value.b);
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHolder.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHolder.java
index 0d93cba..5bbe690 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHolder.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHolder.java
@@ -6,32 +6,32 @@ import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.Streamable;
-public final class passThisHolder
+public final class StructureToPassHolder
implements Streamable
{
- public passThis value;
+ public StructureToPass value;
- public passThisHolder()
+ public StructureToPassHolder()
{
}
- public passThisHolder(passThis initialValue)
+ public StructureToPassHolder(StructureToPass initialValue)
{
value = initialValue;
}
public void _read(InputStream i)
{
- value = passThisHelper.read(i);
+ value = StructureToPassHelper.read(i);
}
public org.omg.CORBA.TypeCode _type()
{
- return passThisHelper.type();
+ return StructureToPassHelper.type();
}
public void _write(OutputStream o)
{
- passThisHelper.write(o, value);
+ StructureToPassHelper.write(o, value);
}
}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThis.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturn.java
index b7c3923..5dc843a 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThis.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturn.java
@@ -1,4 +1,4 @@
-/* returnThis.java --
+/* StructureToReturn.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,9 +44,14 @@ import org.omg.CORBA.portable.IDLEntity;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class returnThis
+public class StructureToReturn
implements IDLEntity
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* The string field.
*/
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHelper.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java
index 79838d7..42fb7a5 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHelper.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java
@@ -1,4 +1,4 @@
-/* returnThisHelper.java --
+/* StructureToReturnHelper.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,7 +37,6 @@ exception statement from your version. */
package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
-import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
import org.omg.CORBA.TCKind;
@@ -46,17 +45,17 @@ import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
/**
- * This class defines the helper operations for {@link returnThis}.
+ * This class defines the helper operations for {@link StructureToReturn}.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class returnThisHelper
+public abstract class StructureToReturnHelper
{
/**
* The repository id.
*/
private static String _id =
- "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThis:1.0";
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturn:1.0";
/**
* Return the repository id.
@@ -69,9 +68,9 @@ public abstract class returnThisHelper
/**
* Read the structure from the CDR stream.
*/
- public static returnThis read(InputStream istream)
+ public static StructureToReturn read(InputStream istream)
{
- returnThis value = new returnThis();
+ StructureToReturn value = new StructureToReturn();
value.n = istream.read_long();
value.c = istream.read_wstring();
value.arra = new int[ 3 ];
@@ -95,7 +94,7 @@ public abstract class returnThisHelper
member = ORB.init().get_primitive_tc(TCKind.tk_long);
member = ORB.init().create_array_tc(3, member);
members [ 2 ] = new StructMember("arra", member, null);
- return ORB.init().create_struct_tc(returnThisHelper.id(), "returnThis",
+ return ORB.init().create_struct_tc(StructureToReturnHelper.id(), "StructureToReturn",
members
);
}
@@ -103,7 +102,7 @@ public abstract class returnThisHelper
/**
* Write the structure to the CDR stream.
*/
- public static void write(OutputStream ostream, returnThis value)
+ public static void write(OutputStream ostream, StructureToReturn value)
{
ostream.write_long(value.n);
ostream.write_wstring(value.c);
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHolder.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHolder.java
index 294e37a..c70f9cf 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHolder.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHolder.java
@@ -10,25 +10,25 @@ import org.omg.CORBA.portable.Streamable;
/**
* The holder for the structure, returned from the server.
*/
-public final class returnThisHolder
+public final class StructureToReturnHolder
implements Streamable
{
/**
* The enclosed structure.
*/
- public returnThis value = null;
+ public StructureToReturn value = null;
/**
* Create the empty holder.
*/
- public returnThisHolder()
+ public StructureToReturnHolder()
{
}
/**
* Crate the holder with the defined initial value.
*/
- public returnThisHolder(returnThis initialValue)
+ public StructureToReturnHolder(StructureToReturn initialValue)
{
value = initialValue;
}
@@ -38,7 +38,7 @@ public final class returnThisHolder
*/
public void _read(InputStream in)
{
- value = returnThisHelper.read(in);
+ value = StructureToReturnHelper.read(in);
}
/**
@@ -46,7 +46,7 @@ public final class returnThisHolder
*/
public TypeCode _type()
{
- return returnThisHelper.type();
+ return StructureToReturnHelper.type();
}
/**
@@ -55,6 +55,6 @@ public final class returnThisHolder
*/
public void _write(OutputStream out)
{
- returnThisHelper.write(out, value);
+ StructureToReturnHelper.write(out, value);
}
}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/node.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNode.java
index 527d02d..b267f39 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/node.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNode.java
@@ -1,4 +1,4 @@
-/* node.java --
+/* TreeNode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,12 +44,17 @@ package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class node
+public class TreeNode
implements org.omg.CORBA.portable.IDLEntity
{
- /** The node name */
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /** The TreeNode name */
public String name = null;
- /** The node children. */
- public node[] children = null;
+ /** The TreeNode children. */
+ public TreeNode[] children = null;
}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHelper.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java
index 8d4121c..f111d0e 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHelper.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java
@@ -1,4 +1,4 @@
-/* nodeHelper.java --
+/* TreeNodeHelper.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -51,13 +51,13 @@ import org.omg.CORBA.portable.OutputStream;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class nodeHelper
+public abstract class TreeNodeHelper
{
/**
- * The node repository id, used to identify the structure.
+ * The TreeNode repository id, used to identify the structure.
*/
private static String _id =
- "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/node:1.0";
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNode:1.0";
/**
* Caches the typecode, allowing to compute it only once.
@@ -66,21 +66,21 @@ public abstract class nodeHelper
/**
* This is used to handle the recursive object references in
- * CORBA - supported way. The tree node definition is recursive,
- * as the node contains the sequence of the nodes as its field.
+ * CORBA - supported way. The tree TreeNode definition is recursive,
+ * as the TreeNode contains the sequence of the nodes as its field.
*/
private static boolean active;
/**
- * Extract the tree node from the unversal CORBA wrapper, Any.
+ * Extract the tree TreeNode from the unversal CORBA wrapper, Any.
*/
- public static node extract(Any a)
+ public static TreeNode extract(Any a)
{
return read(a.create_input_stream());
}
/**
- * Get the node string identifer.
+ * Get the TreeNode string identifer.
*/
public static String id()
{
@@ -88,9 +88,9 @@ public abstract class nodeHelper
}
/**
- * Insert the node into the universal CORBA wrapper, Any.
+ * Insert the TreeNode into the universal CORBA wrapper, Any.
*/
- public static void insert(Any a, node that)
+ public static void insert(Any a, TreeNode that)
{
OutputStream out = a.create_output_stream();
a.type(type());
@@ -99,22 +99,22 @@ public abstract class nodeHelper
}
/**
- * Read the node from the common data reprentation (CDR) stream.
+ * Read the TreeNode from the common data reprentation (CDR) stream.
*/
- public static node read(InputStream istream)
+ public static TreeNode read(InputStream istream)
{
- node value = new node();
+ TreeNode value = new TreeNode();
value.name = istream.read_string();
int _len0 = istream.read_long();
- value.children = new node[ _len0 ];
+ value.children = new TreeNode[ _len0 ];
for (int i = 0; i < value.children.length; ++i)
- value.children [ i ] = nodeHelper.read(istream);
+ value.children [ i ] = TreeNodeHelper.read(istream);
return value;
}
/**
- * Get the node type code definition.
+ * Get the TreeNode type code definition.
*/
public static synchronized TypeCode type()
{
@@ -131,7 +131,7 @@ public abstract class nodeHelper
return ORB.init().create_recursive_tc(_id);
active = true;
- // List all memebers of the node structure.
+ // List all memebers of the TreeNode structure.
StructMember[] members = new StructMember[ 2 ];
TypeCode memberType;
memberType = ORB.init().create_string_tc(0);
@@ -139,7 +139,7 @@ public abstract class nodeHelper
memberType = ORB.init().create_recursive_tc("");
members [ 1 ] = new StructMember("children", memberType, null);
typeCode =
- ORB.init().create_struct_tc(nodeHelper.id(), "node", members);
+ ORB.init().create_struct_tc(TreeNodeHelper.id(), "TreeNode", members);
active = false;
}
}
@@ -148,13 +148,13 @@ public abstract class nodeHelper
}
/**
- * Write the node into the common data reprentation (CDR) stream.
+ * Write the TreeNode into the common data reprentation (CDR) stream.
*/
- public static void write(OutputStream ostream, node value)
+ public static void write(OutputStream ostream, TreeNode value)
{
ostream.write_string(value.name);
ostream.write_long(value.children.length);
for (int i = 0; i < value.children.length; ++i)
- nodeHelper.write(ostream, value.children [ i ]);
+ TreeNodeHelper.write(ostream, value.children [ i ]);
}
}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHolder.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHolder.java
index 8e49139..ec180ce 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHolder.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHolder.java
@@ -1,4 +1,4 @@
-/* nodeHolder.java --
+/* TreeNodeHolder.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,57 +44,57 @@ import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.Streamable;
/**
- * The node holder is a wrapper about the node data structure. It
- * can be used where the node must be passed both to and from
+ * The TreeNode holder is a wrapper about the TreeNode data structure. It
+ * can be used where the TreeNode must be passed both to and from
* the method being called. The same structure holds the tree,
- * as it can be represented as a root node with children.
+ * as it can be represented as a root TreeNode with children.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class nodeHolder
+public class TreeNodeHolder
implements Streamable
{
/**
- * Stores the node value.
+ * Stores the TreeNode value.
*/
- public node value;
+ public TreeNode value;
/**
- * Creates the node holder with the null initial value.
+ * Creates the TreeNode holder with the null initial value.
*/
- public nodeHolder()
+ public TreeNodeHolder()
{
}
/**
- * Creates the node holder with the given initial value.
+ * Creates the TreeNode holder with the given initial value.
*/
- public nodeHolder(node initialValue)
+ public TreeNodeHolder(TreeNode initialValue)
{
value = initialValue;
}
/**
- * Reads the node value from the common data representation (CDR)
+ * Reads the TreeNode value from the common data representation (CDR)
* stream.
*/
public void _read(InputStream in)
{
- value = nodeHelper.read(in);
+ value = TreeNodeHelper.read(in);
}
/**
- * Writes the node value into common data representation (CDR)
+ * Writes the TreeNode value into common data representation (CDR)
* stream.
* @return
*/
public TypeCode _type()
{
- return nodeHelper.type();
+ return TreeNodeHelper.type();
}
public void _write(OutputStream out)
{
- nodeHelper.write(out, value);
+ TreeNodeHelper.write(out, value);
}
}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisException.java
index 51ea5f2..cf20d61 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisException.java
@@ -1,4 +1,4 @@
-/* ourUserException.java --
+/* WeThrowThisException.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -49,10 +49,15 @@ import org.omg.CORBA.portable.IDLEntity;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class ourUserException
+public class WeThrowThisException
extends UserException
implements IDLEntity
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* Our specific field, transferred to client.
*/
@@ -63,7 +68,7 @@ public class ourUserException
*
* @param _ourField the value of our specific field.
*/
- public ourUserException(int _ourField)
+ public WeThrowThisException(int _ourField)
{
ourField = _ourField;
}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserExceptionHelper.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java
index 8c499df..4d5eee7 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserExceptionHelper.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java
@@ -1,4 +1,4 @@
-/* ourUserExceptionHelper.java --
+/* WeThrowThisExceptionHelper.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -50,14 +50,14 @@ import org.omg.CORBA.TypeCode;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class ourUserExceptionHelper
+public abstract class WeThrowThisExceptionHelper
{
/**
* The exception repository id. This name is also used to find the
* mapping local CORBA class.
*/
private static String _id =
- "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException:1.0";
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisException:1.0";
/**
* Get the exception repository id.
@@ -71,7 +71,7 @@ public abstract class ourUserExceptionHelper
* Extract the exception from the given Any where it might be
* wrapped.
*/
- public static ourUserException extract(Any a)
+ public static WeThrowThisException extract(Any a)
{
return read(a.create_input_stream());
}
@@ -79,9 +79,9 @@ public abstract class ourUserExceptionHelper
/**
* Read the exception from the CDR stream.
*/
- public static ourUserException read(org.omg.CORBA.portable.InputStream istream)
+ public static WeThrowThisException read(org.omg.CORBA.portable.InputStream istream)
{
- ourUserException value = new ourUserException(0);
+ WeThrowThisException value = new WeThrowThisException(0);
// The repository ID is not used
istream.read_string();
@@ -98,8 +98,8 @@ public abstract class ourUserExceptionHelper
TypeCode member = null;
member = ORB.init().get_primitive_tc(TCKind.tk_long);
members [ 0 ] = new StructMember("ourField", member, null);
- return ORB.init().create_struct_tc(ourUserExceptionHelper.id(),
- "ourUserException", members
+ return ORB.init().create_struct_tc(WeThrowThisExceptionHelper.id(),
+ "WeThrowThisException", members
);
}
@@ -107,7 +107,7 @@ public abstract class ourUserExceptionHelper
* Write the exception into the CDR stream.
*/
public static void write(org.omg.CORBA.portable.OutputStream ostream,
- ourUserException value
+ WeThrowThisException value
)
{
ostream.write_string(id());
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterImplBase.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterImplBase.java
index 4c8f5b9..237c230 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterImplBase.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterImplBase.java
@@ -1,4 +1,4 @@
-/* _comTesterImplBase.java --
+/* _DemoTesterImplBase.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -53,13 +53,16 @@ import org.omg.CORBA.portable.ResponseHandler;
/**
* The base for the class that is actually implementing the functionality
- * of the object on the server side ({@link comServant} of our case).
+ * of the object on the server side ({@link DemoServant} of our case).
+ *
+ * Following CORBA standards, the name of this class must start from
+ * underscore and end by the "ImplBase".
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class _comTesterImplBase
+public abstract class _DemoTesterImplBase
extends ObjectImpl
- implements comTester, InvokeHandler
+ implements DemoTester, InvokeHandler
{
/**
* When the server receives the request message from client, it
@@ -138,7 +141,7 @@ public abstract class _comTesterImplBase
}
else
/*
- Throws either 'ourUserException' with the 'ourField' field
+ Throws either 'WeThrowThisException' with the 'ourField' field
initialised to the passed positive value
or system exception (if the parameter is zero or negative).
*/
@@ -150,21 +153,21 @@ public abstract class _comTesterImplBase
throwException(parameter);
out = rh.createReply();
}
- catch (ourUserException exception)
+ catch (WeThrowThisException exception)
{
out = rh.createExceptionReply();
- ourUserExceptionHelper.write(out, exception);
+ WeThrowThisExceptionHelper.write(out, exception);
}
}
else
/* Passes and returns the structures. */
if (a_method.equals("passStructure"))
{
- passThis in_structure = passThisHelper.read(in);
- returnThis result = null;
+ StructureToPass in_structure = StructureToPassHelper.read(in);
+ StructureToReturn result = null;
result = passStructure(in_structure);
out = rh.createReply();
- returnThisHelper.write(out, result);
+ StructureToReturnHelper.write(out, result);
}
else
/* Passes and returns the string sequence. */
@@ -180,11 +183,11 @@ public abstract class _comTesterImplBase
/** Pass and return the tree structure */
if (a_method.equals("passTree"))
{
- nodeHolder tree = new nodeHolder();
- tree.value = nodeHelper.read(in);
+ TreeNodeHolder tree = new TreeNodeHolder();
+ tree.value = TreeNodeHelper.read(in);
passTree(tree);
out = rh.createReply();
- nodeHelper.write(out, tree.value);
+ TreeNodeHelper.write(out, tree.value);
}
else
@@ -201,6 +204,6 @@ public abstract class _comTesterImplBase
public String[] _ids()
{
// They are the same as for the stub.
- return _comTesterStub._ids;
+ return _DemoTesterStub._ids;
}
}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterStub.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterStub.java
index b71cd8e..c8e0ccd 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterStub.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterStub.java
@@ -1,4 +1,4 @@
-/* _comTesterStub.java --
+/* _DemoTesterStub.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -55,23 +55,26 @@ import org.omg.CORBA.portable.RemarshalException;
* side. It has all the same methods as the actual implementation
* on the server side. These methods contain the code for remote
* invocation.
+ *
+ * Following CORBA standards, the name of this class must start from
+ * underscore and end by the "Stub".
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class _comTesterStub
+public class _DemoTesterStub
extends ObjectImpl
- implements comTester
+ implements DemoTester
{
/**
- * A string array of comTester repository ids.
+ * A string array of DemoTester repository ids.
*/
public static String[] _ids =
{
- "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/comTester:1.0"
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoTester:1.0"
};
/**
- * Return an array of comTester repository ids.
+ * Return an array of DemoTester repository ids.
*/
public String[] _ids()
{
@@ -217,7 +220,7 @@ public class _comTesterStub
/**
Passes and returns the structures.
*/
- public returnThis passStructure(passThis in_structure)
+ public StructureToReturn passStructure(StructureToPass in_structure)
{
InputStream in = null;
try
@@ -226,13 +229,13 @@ public class _comTesterStub
OutputStream out = _request("passStructure", true);
// Write the structure, using its helper.
- passThisHelper.write(out, in_structure);
+ StructureToPassHelper.write(out, in_structure);
// Invoke the method.
in = _invoke(out);
// Read the returned structer, using another helper.
- returnThis result = returnThisHelper.read(in);
+ StructureToReturn result = StructureToReturnHelper.read(in);
return result;
}
catch (ApplicationException ex)
@@ -253,7 +256,7 @@ public class _comTesterStub
/**
* Pass and return the tree structure
*/
- public void passTree(nodeHolder tree)
+ public void passTree(TreeNodeHolder tree)
{
InputStream in = null;
try
@@ -261,15 +264,15 @@ public class _comTesterStub
// Get the stream where the parameters must be written.
OutputStream out = _request("passTree", true);
- // Write the tree (node with its chilred, grandchildren and so on),
+ // Write the tree (TreeNode with its chilred, grandchildren and so on),
// using the appropriate helper.
- nodeHelper.write(out, tree.value);
+ TreeNodeHelper.write(out, tree.value);
// Call the method.
in = _invoke(out);
// Read the returned tree.
- tree.value = nodeHelper.read(in);
+ tree.value = TreeNodeHelper.read(in);
}
catch (ApplicationException ex)
{
@@ -382,10 +385,10 @@ public class _comTesterStub
* of the positive value of this argument, and system
* exception otherwise.
*
- * @throws ourUserException
+ * @throws WeThrowThisException
*/
public void throwException(int parameter)
- throws ourUserException
+ throws WeThrowThisException
{
InputStream in = null;
try
@@ -408,9 +411,9 @@ public class _comTesterStub
// If this is the user exception we expect to catch, read and throw
// it here. The system exception, if thrown, is handled by _invoke.
- if (id.equals("IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException:1.0")
+ if (id.equals("IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisException:1.0")
)
- throw ourUserExceptionHelper.read(in);
+ throw WeThrowThisExceptionHelper.read(in);
else
throw new MARSHAL(id);
}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/midi/Demo.java b/libjava/classpath/examples/gnu/classpath/examples/midi/Demo.java
new file mode 100644
index 0000000..7e403d8
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/midi/Demo.java
@@ -0,0 +1,137 @@
+/* Demo.java -- And example of MIDI support
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+package gnu.classpath.examples.midi;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+import javax.sound.midi.*;
+
+/**
+ * An example how javax.sound.midi facilities work.
+ */
+public class Demo extends Frame implements ItemListener
+{
+ Choice midiInChoice = new Choice();
+ Choice midiOutChoice = new Choice();
+
+ MidiDevice inDevice = null;
+ MidiDevice outDevice = null;
+
+ ArrayList inDevices = new ArrayList();
+ ArrayList outDevices = new ArrayList();
+
+ public Demo () throws Exception
+ {
+ MenuBar mb = new MenuBar ();
+ Menu menu = new Menu ("File");
+ MenuItem quit = new MenuItem("Quit", new MenuShortcut('Q'));
+ quit.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ System.exit(0);
+ }
+ });
+ menu.add (quit);
+ mb.add(menu);
+
+ setTitle("synthcity: the GNU Classpath MIDI Demo");
+ setLayout(new FlowLayout());
+
+ MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
+
+ for (int i = 0; i < infos.length; i++)
+ {
+ MidiDevice device = MidiSystem.getMidiDevice(infos[i]);
+ if (device.getMaxReceivers() > 0)
+ {
+ midiOutChoice.addItem(infos[i].getDescription());
+ outDevices.add(device);
+ }
+ if (device.getMaxTransmitters() > 0)
+ {
+ midiInChoice.addItem(infos[i].getDescription());
+ inDevices.add(device);
+ }
+ }
+
+ setMenuBar (mb);
+ add(new Label("MIDI IN: "));
+ add(midiInChoice);
+ add(new Label(" MIDI OUT: "));
+ add(midiOutChoice);
+
+ midiInChoice.addItemListener(this);
+ midiOutChoice.addItemListener(this);
+
+ pack();
+ show();
+ }
+
+ public void itemStateChanged (ItemEvent e)
+ {
+ try
+ {
+ if (e.getItemSelectable() == midiInChoice)
+ {
+ if (inDevice != null)
+ inDevice.close();
+ inDevice = (MidiDevice)
+ inDevices.get(midiInChoice.getSelectedIndex());
+ }
+
+ if (e.getItemSelectable() == midiOutChoice)
+ {
+ if (outDevice != null)
+ outDevice.close();
+ outDevice = (MidiDevice)
+ outDevices.get(midiOutChoice.getSelectedIndex());
+ }
+
+ if (inDevice != null && outDevice != null)
+ {
+ if (! inDevice.isOpen())
+ inDevice.open();
+ if (! outDevice.isOpen())
+ outDevice.open();
+ Transmitter t = inDevice.getTransmitter();
+ if (t == null)
+ System.err.println (inDevice + ".getTransmitter() == null");
+ Receiver r = outDevice.getReceiver();
+ if (r == null)
+ System.err.println (outDevice + ".getReceiver() == null");
+
+ if (t != null && r != null)
+ t.setReceiver (r);
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public static void main (String args[]) throws Exception
+ {
+ new Demo();
+ }
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/ButtonDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/ButtonDemo.java
new file mode 100644
index 0000000..b53ba3b
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/swing/ButtonDemo.java
@@ -0,0 +1,284 @@
+/* ButtonDemo.java -- An example showing various buttons in Swing.
+ Copyright (C) 2005, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JToggleButton;
+import javax.swing.SwingConstants;
+import javax.swing.plaf.metal.MetalIconFactory;
+
+/**
+ * A simple button demo showing various buttons in different states.
+ */
+public class ButtonDemo
+ extends JFrame
+ implements ActionListener
+{
+
+ private JCheckBox buttonState;
+ private JButton button1;
+ private JButton button2;
+ private JButton button3;
+ private JButton button4;
+
+ private JCheckBox toggleState;
+ private JToggleButton toggle1;
+ private JToggleButton toggle2;
+ private JToggleButton toggle3;
+ private JToggleButton toggle4;
+
+ private JCheckBox checkBoxState;
+ private JCheckBox checkBox1;
+ private JCheckBox checkBox2;
+ private JCheckBox checkBox3;
+
+ private JCheckBox radioState;
+ private JRadioButton radio1;
+ private JRadioButton radio2;
+ private JRadioButton radio3;
+
+ /**
+ * Creates a new demo instance.
+ *
+ * @param title the frame title.
+ */
+ public ButtonDemo(String title)
+ {
+ super(title);
+ JPanel content = createContent();
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ content.add(closePanel, BorderLayout.SOUTH);
+ getContentPane().add(content);
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel
+ * uses a BorderLayout(), and the BorderLayout.SOUTH area
+ * is empty, to allow callers to add controls to the
+ * bottom of the panel if they want to (a close button is
+ * added if this demo is being run as a standalone demo).
+ */
+ JPanel createContent()
+ {
+ JPanel content = new JPanel(new BorderLayout());
+ JPanel panel = new JPanel(new GridLayout(4, 1));
+ panel.add(createButtonPanel());
+ panel.add(createTogglePanel());
+ panel.add(createCheckBoxPanel());
+ panel.add(createRadioPanel());
+ content.add(panel);
+ return content;
+ }
+
+ private JPanel createButtonPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.buttonState = new JCheckBox("Enabled", true);
+ this.buttonState.setActionCommand("BUTTON_STATE");
+ this.buttonState.addActionListener(this);
+ panel.add(this.buttonState, BorderLayout.EAST);
+
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setBorder(BorderFactory.createTitledBorder("JButton"));
+ this.button1 = new JButton("Button 1");
+
+ this.button2 = new JButton("Button 2");
+ this.button2.setIcon(MetalIconFactory.getInternalFrameDefaultMenuIcon());
+
+ this.button3 = new JButton("Button 3");
+ this.button3.setIcon(MetalIconFactory.getFileChooserHomeFolderIcon());
+ this.button3.setHorizontalTextPosition(SwingConstants.CENTER);
+ this.button3.setVerticalTextPosition(SwingConstants.BOTTOM);
+
+ this.button4 = new JButton("Button 4");
+ this.button4.setIcon(MetalIconFactory.getFileChooserUpFolderIcon());
+ this.button4.setText(null);
+
+ buttonPanel.add(button1);
+ buttonPanel.add(button2);
+ buttonPanel.add(button3);
+ buttonPanel.add(button4);
+
+ panel.add(buttonPanel);
+
+ return panel;
+ }
+
+ private JPanel createTogglePanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+
+ this.toggleState = new JCheckBox("Enabled", true);
+ this.toggleState.setActionCommand("TOGGLE_STATE");
+ this.toggleState.addActionListener(this);
+
+ panel.add(this.toggleState, BorderLayout.EAST);
+
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setBorder(BorderFactory.createTitledBorder("JToggleButton"));
+
+ this.toggle1 = new JToggleButton("Toggle 1");
+
+ this.toggle2 = new JToggleButton("Toggle 2");
+ this.toggle2.setIcon(MetalIconFactory.getInternalFrameDefaultMenuIcon());
+
+ this.toggle3 = new JToggleButton("Toggle 3");
+ this.toggle3.setIcon(MetalIconFactory.getFileChooserHomeFolderIcon());
+ this.toggle3.setHorizontalTextPosition(SwingConstants.CENTER);
+ this.toggle3.setVerticalTextPosition(SwingConstants.BOTTOM);
+
+ this.toggle4 = new JToggleButton("Toggle 4");
+ this.toggle4.setIcon(MetalIconFactory.getFileChooserUpFolderIcon());
+ this.toggle4.setText(null);
+
+ ButtonGroup toggleGroup = new ButtonGroup();
+ toggleGroup.add(toggle1);
+ toggleGroup.add(toggle2);
+ toggleGroup.add(toggle3);
+ toggleGroup.add(toggle4);
+
+ buttonPanel.add(toggle1);
+ buttonPanel.add(toggle2);
+ buttonPanel.add(toggle3);
+ buttonPanel.add(toggle4);
+
+ panel.add(buttonPanel);
+
+ return panel;
+ }
+
+ private JPanel createCheckBoxPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+
+ this.checkBoxState = new JCheckBox("Enabled", true);
+ this.checkBoxState.setActionCommand("CHECKBOX_STATE");
+ this.checkBoxState.addActionListener(this);
+
+ panel.add(this.checkBoxState, BorderLayout.EAST);
+
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setBorder(BorderFactory.createTitledBorder("JCheckBox"));
+ this.checkBox1 = new JCheckBox("CheckBox 1");
+
+ this.checkBox2 = new JCheckBox("CheckBox 2");
+
+ this.checkBox3 = new JCheckBox("CheckBox 3");
+
+ buttonPanel.add(checkBox1);
+ buttonPanel.add(checkBox2);
+ buttonPanel.add(checkBox3);
+
+ panel.add(buttonPanel);
+
+ return panel;
+ }
+
+ private JPanel createRadioPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+
+ this.radioState = new JCheckBox("Enabled", true);
+ this.radioState.setActionCommand("RADIO_STATE");
+ this.radioState.addActionListener(this);
+ panel.add(this.radioState, BorderLayout.EAST);
+
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setBorder(BorderFactory.createTitledBorder("JRadioButton"));
+ this.radio1 = new JRadioButton("Radio 1");
+
+ this.radio2 = new JRadioButton("Radio 2");
+
+ this.radio3 = new JRadioButton("Radio 3");
+
+ ButtonGroup radioGroup = new ButtonGroup();
+ radioGroup.add(radio1);
+ radioGroup.add(radio2);
+ radioGroup.add(radio3);
+
+ buttonPanel.add(radio1);
+ buttonPanel.add(radio2);
+ buttonPanel.add(radio3);
+
+ panel.add(buttonPanel);
+
+ return panel;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("BUTTON_STATE"))
+ {
+ button1.setEnabled(buttonState.isSelected());
+ button2.setEnabled(buttonState.isSelected());
+ button3.setEnabled(buttonState.isSelected());
+ button4.setEnabled(buttonState.isSelected());
+ }
+ else if (e.getActionCommand().equals("TOGGLE_STATE"))
+ {
+ toggle1.setEnabled(toggleState.isSelected());
+ toggle2.setEnabled(toggleState.isSelected());
+ toggle3.setEnabled(toggleState.isSelected());
+ toggle4.setEnabled(toggleState.isSelected());
+ }
+ else if (e.getActionCommand().equals("CHECKBOX_STATE"))
+ {
+ checkBox1.setEnabled(checkBoxState.isSelected());
+ checkBox2.setEnabled(checkBoxState.isSelected());
+ checkBox3.setEnabled(checkBoxState.isSelected());
+ }
+ else if (e.getActionCommand().equals("RADIO_STATE"))
+ {
+ radio1.setEnabled(radioState.isSelected());
+ radio2.setEnabled(radioState.isSelected());
+ radio3.setEnabled(radioState.isSelected());
+ }
+ else if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ ButtonDemo app = new ButtonDemo("Button Demo");
+ app.pack();
+ app.setVisible(true);
+ }
+
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/ClasspathSwingActivityBoard.launch b/libjava/classpath/examples/gnu/classpath/examples/swing/ClasspathSwingActivityBoard.launch
new file mode 100644
index 0000000..7d041a0
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/swing/ClasspathSwingActivityBoard.launch
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<launchConfiguration type="org.eclipse.cdt.launch.localCLaunch">
+<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_ID" value="org.eclipse.cdt.debug.mi.core.CDebugger"/>
+<stringAttribute key="org.eclipse.cdt.launch.protocol" value="mi"/>
+<booleanAttribute key="org.eclipse.cdt.debug.mi.core.STOP_ON_SOLIB_EVENTS" value="false"/>
+<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="run"/>
+<listAttribute key="org.eclipse.cdt.debug.mi.core.SOLIB_PATH"/>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<booleanAttribute key="org.eclipse.cdt.launch.ENABLE_REGISTER_BOOKKEEPING" value="false"/>
+<booleanAttribute key="org.eclipse.cdt.debug.mi.core.AUTO_SOLIB" value="true"/>
+<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
+<booleanAttribute key="org.eclipse.cdt.launch.use_terminal" value="true"/>
+<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="jamvm"/>
+<booleanAttribute key="org.eclipse.cdt.launch.ENABLE_VARIABLE_BOOKKEEPING" value="false"/>
+<stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="gdb"/>
+<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="src/jamvm"/>
+<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_ARGUMENTS" value="-Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel gnu.classpath.examples.swing.Demo"/>
+<stringAttribute key="org.eclipse.cdt.debug.mi.core.GDB_INIT" value=""/>
+</launchConfiguration>
diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/ComboBoxDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/ComboBoxDemo.java
new file mode 100644
index 0000000..52431cb
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/swing/ComboBoxDemo.java
@@ -0,0 +1,360 @@
+/* ComboBoxDemo.java -- An example showing various combo boxes in Swing.
+ Copyright (C) 2005, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.UIManager;
+import javax.swing.plaf.metal.MetalIconFactory;
+
+/**
+ * A simple demo showing various combo boxes in different states.
+ */
+public class ComboBoxDemo
+ extends JFrame
+ implements ActionListener
+{
+
+ class CustomCellRenderer extends DefaultListCellRenderer
+ {
+ public Component getListCellRendererComponent(JList list,
+ Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus)
+ {
+ DefaultListCellRenderer result = (DefaultListCellRenderer)
+ super.getListCellRendererComponent(list, value, index, isSelected,
+ cellHasFocus);
+ Icon icon = (Icon) value;
+ result.setIcon(icon);
+ result.setText("Index = " + index);
+ return result;
+ }
+ }
+
+ private JCheckBox comboState1;
+ private JComboBox combo1;
+ private JComboBox combo2;
+
+ private JCheckBox comboState2;
+ private JComboBox combo3;
+ private JComboBox combo4;
+
+ private JCheckBox comboState3;
+ private JComboBox combo5;
+ private JComboBox combo6;
+
+ private JCheckBox comboState4;
+ private JComboBox combo7;
+ private JComboBox combo8;
+
+ private JCheckBox comboState5;
+ private JComboBox combo9;
+ private JComboBox combo10;
+
+ private JCheckBox comboState6;
+ private JComboBox combo11;
+ private JComboBox combo12;
+
+ /**
+ * Creates a new demo instance.
+ *
+ * @param title the frame title.
+ */
+ public ComboBoxDemo(String title)
+ {
+ super(title);
+ JPanel content = createContent();
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ content.add(closePanel, BorderLayout.SOUTH);
+ getContentPane().add(content);
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel
+ * uses a BorderLayout(), and the BorderLayout.SOUTH area
+ * is empty, to allow callers to add controls to the
+ * bottom of the panel if they want to (a close button is
+ * added if this demo is being run as a standalone demo).
+ */
+ JPanel createContent()
+ {
+ JPanel content = new JPanel(new BorderLayout());
+ JPanel panel = new JPanel(new GridLayout(6, 1));
+ panel.add(createPanel1());
+ panel.add(createPanel2());
+ panel.add(createPanel3());
+ panel.add(createPanel4());
+ panel.add(createPanel5());
+ panel.add(createPanel6());
+ content.add(panel);
+ return content;
+ }
+
+ private JPanel createPanel1()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.comboState1 = new JCheckBox("Enabled", true);
+ this.comboState1.setActionCommand("COMBO_STATE1");
+ this.comboState1.addActionListener(this);
+ panel.add(this.comboState1, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Regular: "));
+ this.combo1 = new JComboBox(new Object[] {"Australia", "New Zealand",
+ "England"});
+
+ this.combo2 = new JComboBox(new Object[] {"Australia", "New Zealand",
+ "England"});
+ this.combo2.setEditable(true);
+
+ controlPanel.add(combo1);
+ controlPanel.add(combo2);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ private JPanel createPanel2()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.comboState2 = new JCheckBox("Enabled", true);
+ this.comboState2.setActionCommand("COMBO_STATE2");
+ this.comboState2.addActionListener(this);
+ panel.add(this.comboState2, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Large Font: "));
+ this.combo3 = new JComboBox(new Object[] {"Australia", "New Zealand",
+ "England"});
+ this.combo3.setFont(new Font("Dialog", Font.PLAIN, 20));
+
+ this.combo4 = new JComboBox(new Object[] {"Australia", "New Zealand",
+ "England"});
+ this.combo4.setEditable(true);
+ this.combo4.setFont(new Font("Dialog", Font.PLAIN, 20));
+
+ controlPanel.add(combo3);
+ controlPanel.add(combo4);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ private JPanel createPanel3()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.comboState3 = new JCheckBox("Enabled", true);
+ this.comboState3.setActionCommand("COMBO_STATE3");
+ this.comboState3.addActionListener(this);
+ panel.add(this.comboState3, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Colored Background: "));
+ this.combo5 = new JComboBox(new Object[] {"Australia", "New Zealand",
+ "England"});
+ this.combo5.setBackground(Color.yellow);
+
+ this.combo6 = new JComboBox(new Object[] {"Australia", "New Zealand",
+ "England"});
+ this.combo6.setEditable(true);
+ this.combo6.setBackground(Color.yellow);
+
+ controlPanel.add(combo5);
+ controlPanel.add(combo6);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ /**
+ * This panel contains combo boxes that are empty.
+ *
+ * @return A panel.
+ */
+ private JPanel createPanel4()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.comboState4 = new JCheckBox("Enabled", true);
+ this.comboState4.setActionCommand("COMBO_STATE4");
+ this.comboState4.addActionListener(this);
+ panel.add(this.comboState4, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Empty: "));
+ this.combo7 = new JComboBox();
+ this.combo8 = new JComboBox();
+ this.combo8.setEditable(true);
+
+ controlPanel.add(combo7);
+ controlPanel.add(combo8);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ /**
+ * This panel contains combo boxes that are narrow but contain long text
+ * items.
+ *
+ * @return A panel.
+ */
+ private JPanel createPanel5()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.comboState5 = new JCheckBox("Enabled", true);
+ this.comboState5.setActionCommand("COMBO_STATE5");
+ this.comboState5.addActionListener(this);
+ panel.add(this.comboState5, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Narrow: "));
+ this.combo9 = new JComboBox(new Object[] {
+ "A really long item that will be truncated when displayed"});
+ this.combo9.setPreferredSize(new Dimension(100, 30));
+ this.combo10 = new JComboBox(new Object[] {
+ "A really long item that will be truncated when displayed"});
+ this.combo10.setPreferredSize(new Dimension(100, 30));
+ this.combo10.setEditable(true);
+
+ controlPanel.add(combo9);
+ controlPanel.add(combo10);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ /**
+ * This panel contains combo boxes with a custom renderer.
+ *
+ * @return A panel.
+ */
+ private JPanel createPanel6()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.comboState6 = new JCheckBox("Enabled", true);
+ this.comboState6.setActionCommand("COMBO_STATE6");
+ this.comboState6.addActionListener(this);
+ panel.add(this.comboState6, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Custom Renderer: "));
+ this.combo11 = new JComboBox(new Object[] {
+ MetalIconFactory.getFileChooserHomeFolderIcon(),
+ MetalIconFactory.getFileChooserNewFolderIcon()});
+ this.combo11.setPreferredSize(new Dimension(100, 30));
+ this.combo11.setRenderer(new CustomCellRenderer());
+ this.combo12 = new JComboBox(new Object[] {
+ MetalIconFactory.getFileChooserHomeFolderIcon(),
+ MetalIconFactory.getFileChooserNewFolderIcon()});
+ this.combo12.setPreferredSize(new Dimension(100, 30));
+ this.combo12.setRenderer(new CustomCellRenderer());
+ this.combo12.setEditable(true);
+
+ controlPanel.add(combo11);
+ controlPanel.add(combo12);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("COMBO_STATE1"))
+ {
+ combo1.setEnabled(comboState1.isSelected());
+ combo2.setEnabled(comboState1.isSelected());
+ }
+ else if (e.getActionCommand().equals("COMBO_STATE2"))
+ {
+ combo3.setEnabled(comboState2.isSelected());
+ combo4.setEnabled(comboState2.isSelected());
+ }
+ else if (e.getActionCommand().equals("COMBO_STATE3"))
+ {
+ combo5.setEnabled(comboState3.isSelected());
+ combo6.setEnabled(comboState3.isSelected());
+ }
+ else if (e.getActionCommand().equals("COMBO_STATE4"))
+ {
+ combo7.setEnabled(comboState4.isSelected());
+ combo8.setEnabled(comboState4.isSelected());
+ }
+ else if (e.getActionCommand().equals("COMBO_STATE5"))
+ {
+ combo9.setEnabled(comboState5.isSelected());
+ combo10.setEnabled(comboState5.isSelected());
+ }
+ else if (e.getActionCommand().equals("COMBO_STATE6"))
+ {
+ combo11.setEnabled(comboState6.isSelected());
+ combo12.setEnabled(comboState6.isSelected());
+ }
+ else if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ try
+ {
+ UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ ComboBoxDemo app = new ComboBoxDemo("ComboBox Demo");
+ app.pack();
+ app.setVisible(true);
+ }
+
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/Demo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/Demo.java
index e8c428b..549a42e 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/swing/Demo.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/swing/Demo.java
@@ -24,20 +24,16 @@ package gnu.classpath.examples.swing;
import java.awt.*;
import java.awt.event.*;
-import java.awt.font.*;
-import java.awt.geom.*;
-import java.awt.image.*;
import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.*;
-import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.tree.*;
import javax.swing.border.*;
+import javax.swing.plaf.metal.DefaultMetalTheme;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+import javax.swing.plaf.metal.OceanTheme;
+
import java.net.URL;
-import java.util.*;
public class Demo
{
@@ -51,26 +47,44 @@ public class Demo
if (System.getProperty("swing.defaultlaf") == null)
{
StringBuffer text = new StringBuffer();
- text.append("\tYou may change the Look and Feel of this\n");
- text.append("\tDemo by setting the system property\n");
- text.append("\t-Dswing.defaultlaf=<LAFClassName>\n\n");
- text.append("\tPossible values for <LAFClassName> are:\n");
- text.append("\t * javax.swing.plaf.metal.MetalLookAndFeel\n");
- text.append("\t\tthe default Java L&F\n");
- text.append("\t * gnu.classpath.examples.swing.GNULookAndFeel\n");
- text.append("\tthe GNU Look and Feel\n");
- text.append("\t(derived from javax.swing.plaf.basic.BasicLookAndFeel\n\n");
- text.append("\tthe default is gnu.classpath.examples.swing.GNULookAndFeel\n");
- JEditorPane textPane = new JEditorPane();
- // temporary hack, preferred size should be computed by the
- // component
- textPane.setPreferredSize(new Dimension(400, 300));
- textPane.setText(text.toString());
- JOptionPane.showMessageDialog(null, textPane,
- "Look and Feel notice",
- JOptionPane.INFORMATION_MESSAGE);
-
- UIManager.setLookAndFeel(new GNULookAndFeel());
+ text.append("You may change the Look and Feel of this\n");
+ text.append("Demo by setting the system property\n");
+ text.append("-Dswing.defaultlaf=<LAFClassName>\n");
+ text.append("\n");
+ text.append("Possible values for <LAFClassName> are:\n");
+ text.append("\n");
+ text.append("* javax.swing.plaf.metal.MetalLookAndFeel\n");
+ text.append(" the default GNU Classpath L&F\n");
+ text.append("\n");
+ text.append("* gnu.classpath.examples.swing.GNULookAndFeel\n");
+ text.append(" the GNU Look and Feel\n");
+ text.append(" (derived from javax.swing.plaf.basic.BasicLookAndFeel)\n");
+ text.append("\n");
+ text.append("MetalLookAndFeel supports different Themes.\n");
+ text.append("DefaultMetalTheme (the default) and OceanTheme (in development)\n");
+
+ final String DEFAULT = "MetalLookAndFeel (default)";
+ final String OCEAN = "MetalLookAndFeel (Ocean)";
+ final String GNU = "GNULookAndFeel";
+ final String[] lafs = new String[] { DEFAULT, OCEAN, GNU };
+
+ int laf = JOptionPane.showOptionDialog(null, text /* textPane */,
+ "Look and Feel choice",
+ JOptionPane.OK_OPTION,
+ JOptionPane.QUESTION_MESSAGE,
+ null, lafs, DEFAULT);
+ if (laf == 0)
+ {
+ MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
+ UIManager.setLookAndFeel(new MetalLookAndFeel());
+ }
+ if (laf == 1)
+ {
+ MetalLookAndFeel.setCurrentTheme(new OceanTheme());
+ UIManager.setLookAndFeel(new MetalLookAndFeel());
+ }
+ else if (laf == 2)
+ UIManager.setLookAndFeel(new GNULookAndFeel());
}
}
catch (UnsupportedLookAndFeelException e)
@@ -147,10 +161,7 @@ public class Demo
JMenu examples = new JMenu("Examples");
new PopUpAction("Buttons",
- mkPanel(new JComponent[]
- {mkBigButton("mango"),
- mkBigButton("guava"),
- mkBigButton("lemon")}),
+ (new ButtonDemo("Button Demo")).createContent(),
examples);
new PopUpAction("Toggles",
@@ -166,9 +177,13 @@ public class Demo
examples);
new PopUpAction("Slider",
- mkSliders(),
+ (new SliderDemo("Slider Demo")).createContent(),
examples);
+ new PopUpAction("ProgressBar",
+ ProgressBarDemo.createContent(),
+ examples);
+
new PopUpAction("List",
mkListPanel(new String[] { "hello",
"this",
@@ -181,7 +196,7 @@ public class Demo
examples);
new PopUpAction("Scrollbar",
- mkScrollBar(),
+ (new ScrollBarDemo("ScrollBarDemo")).createContent(),
examples);
new PopUpAction("Viewport",
@@ -189,8 +204,8 @@ public class Demo
examples);
new PopUpAction("ScrollPane",
- mkScrollPane(mkBigButton("Scroll Me!")),
- examples);
+ mkScrollPane(mkBigButton("Scroll Me!")),
+ examples);
new PopUpAction("TabPane",
mkTabs(new String[] {"happy",
@@ -203,19 +218,19 @@ public class Demo
examples);
new PopUpAction("TextField",
- mkTextField("Hello, World!"),
+ (new TextFieldDemo("TextField Demo")).createContent(),
examples);
+ new PopUpAction("FileChooser",
+ (new FileChooserDemo("FileChooser Demo")).createContent(),
+ examples);
+
new PopUpAction("ColorChooser",
mkColorChooser(),
examples);
new PopUpAction("ComboBox",
- mkComboBox(new String[] {"Stop",
- "Software",
- "Hoarders",
- "Support",
- "GNU!"}),
+ (new ComboBoxDemo("ComboBox Demo")).createContent(),
examples);
new PopUpAction("Editor",
@@ -317,6 +332,7 @@ public class Demo
else
b = new JButton(title, icon);
+ b.setToolTipText(title);
if (hAlign != -1) b.setHorizontalAlignment(hAlign);
if (vAlign != -1) b.setVerticalAlignment(vAlign);
if (hPos != -1) b.setHorizontalTextPosition(hPos);
@@ -640,6 +656,14 @@ public class Demo
panel.add(but, BorderLayout.NORTH);
but.doClick();
but.doClick();
+ JInternalFrame palette = new JInternalFrame("Palette", true, true, true,
+ true);
+ palette.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
+ desk.add(palette, JDesktopPane.PALETTE_LAYER);
+ JLabel label = new JLabel("This is a floating palette!");
+ palette.getContentPane().add(label);
+ palette.pack();
+ palette.setVisible(true);
return panel;
}
@@ -678,26 +702,6 @@ public class Demo
return tabs;
}
- static JComponent mkSliders()
- {
- JSlider slider = new JSlider();
- slider.setPaintTrack(true);
- slider.setPaintTicks(true);
- slider.setMajorTickSpacing(30);
- slider.setMinorTickSpacing(5);
- slider.setPaintLabels(true);
- slider.setInverted(false);
- JProgressBar progress = new JProgressBar();
- BoundedRangeModel model = new DefaultBoundedRangeModel(10, 1, 0, 100);
- progress.setModel(model);
- slider.setModel(model);
- JPanel panel = new JPanel();
- panel.setLayout(new GridLayout(1, 2));
- panel.add(slider);
- panel.add(progress);
- return panel;
- }
-
public Demo()
{
frame = new JFrame("Swing Activity Board");
@@ -735,11 +739,17 @@ public class Demo
return c;
}
- public static JRadioButton mkRadio(String label)
+ public static JPanel mkRadio(String label)
{
+ JPanel p = new JPanel();
JRadioButton c = new JRadioButton(label);
- c.setFont(new Font("Luxi", Font.PLAIN, 14));
- return c;
+ JRadioButton d = new JRadioButton("not " + label);
+ ButtonGroup bg = new ButtonGroup();
+ bg.add(c);
+ bg.add(d);
+ p.add(c);
+ p.add(d);
+ return p;
}
public static JList mkList(Object[] elts)
@@ -1002,31 +1012,34 @@ public class Demo
private JPanel mkButtonBar()
{
- JPanel panel = new JPanel ();
- panel.setLayout(new FlowLayout());
+ JPanel panel = new JPanel (new GridLayout(2, 1));
+ JPanel panelA = new JPanel(new FlowLayout());
+ JPanel panelB = new JPanel(new FlowLayout());
new PopUpAction("Buttons",
- mkPanel(new JComponent[]
- {mkBigButton("mango"),
- mkBigButton("guava"),
- mkBigButton("lemon")}),
- panel);
+ (new ButtonDemo("Button Demo")).createContent(),
+ panelA);
new PopUpAction("Toggles",
mkToggle("cool and refreshing"),
- panel);
+ panelA);
new PopUpAction("Checkbox",
mkCheckbox("ice cold"),
- panel);
+ panelA);
new PopUpAction("Radio",
mkRadio("delicious"),
- panel);
+ panelA);
new PopUpAction("Slider",
- mkSliders(),
- panel);
+ (new SliderDemo("Slider Demo")).createContent(),
+ panelA);
+
+ new PopUpAction("ProgressBar",
+ ProgressBarDemo.createContent(),
+ panelA);
+
new PopUpAction("List",
mkListPanel(new String[] { "hello",
@@ -1037,60 +1050,60 @@ public class Demo
"that",
"wraps",
"over"}),
- panel);
+ panelA);
new PopUpAction("Scrollbar",
- mkScrollBar(),
- panel);
+ (new ScrollBarDemo("ScrollBar Demo")).createContent(),
+ panelA);
new PopUpAction("Viewport",
mkViewportBox(mkBigButton("View Me!")),
- panel);
+ panelA);
new PopUpAction("ScrollPane",
mkScrollPane(mkBigButton("Scroll Me!")),
- panel);
+ panelA);
new PopUpAction("TabPane",
mkTabs(new String[] {"happy",
"sad",
"indifferent"}),
- panel);
+ panelB);
new PopUpAction("Spinner",
mkSpinner(),
- panel);
+ panelB);
new PopUpAction("TextField",
- mkTextField("Hello, World!"),
- panel);
+ (new TextFieldDemo("TextField Demo")).createContent(),
+ panelB);
+
+ new PopUpAction("FileChooser",
+ (new FileChooserDemo("FileChooser Demo")).createContent(),
+ panelB);
new PopUpAction("ColorChooser",
mkColorChooser(),
- panel);
+ panelB);
new PopUpAction("ComboBox",
- mkComboBox(new String[] {"Stop",
- "Software",
- "Hoarders",
- "Support",
- "GNU!"}),
- panel);
+ (new ComboBoxDemo("ComboBox Demo")).createContent(),
+ panelB);
new PopUpAction("Editor",
mkEditorPane(),
- panel);
+ panelB);
new PopUpAction("Tree",
mkTree(),
- panel);
+ panelB);
new PopUpAction("Table",
mkTable(),
- panel);
+ panelB);
JButton exitDisposer = mkDisposerButton(frame);
- panel.add(exitDisposer);
+ panelB.add(exitDisposer);
exitDisposer.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
@@ -1098,11 +1111,8 @@ public class Demo
System.exit(1);
}
});
+ panel.add(panelA);
+ panel.add(panelB);
return panel;
}
-
- public static JTextField mkTextField(String sometext)
- {
- return new JTextField(sometext, 40);
- }
}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/FileChooserDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/FileChooserDemo.java
new file mode 100644
index 0000000..70bb56d
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/swing/FileChooserDemo.java
@@ -0,0 +1,228 @@
+/* FileChooserDemo.java -- An example showing file choosers in Swing.
+ Copyright (C) 2005, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+
+import javax.swing.BorderFactory;
+import javax.swing.DefaultListModel;
+import javax.swing.JButton;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.filechooser.FileFilter;
+
+/**
+ * A simple demo showing the {@link JFileChooser} component used in different
+ * ways.
+ */
+public class FileChooserDemo extends JFrame implements ActionListener
+{
+ /**
+ * A file filter for Java source files.
+ */
+ static class JavaFileFilter extends FileFilter
+ {
+ public String getDescription()
+ {
+ return "Java Source Files (.java)";
+ }
+ public boolean accept(File f)
+ {
+ if (f != null)
+ {
+ return f.getName().endsWith(".java") || f.isDirectory();
+ }
+ else
+ return false;
+ }
+ }
+
+ /** A label to display the selected file. */
+ JLabel selectedFileLabel;
+
+ /**
+ * A list showing the selected files (where multi selections are
+ * allowed).
+ */
+ JList selectedFilesList;
+
+ /** A label to display the return code for the JFileChooser. */
+ JLabel returnCodeLabel;
+
+ /**
+ * Creates a new demo instance.
+ *
+ * @param frameTitle the frame title.
+ */
+ public FileChooserDemo(String frameTitle)
+ {
+ super(frameTitle);
+ JPanel content = createContent();
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ content.add(closePanel, BorderLayout.SOUTH);
+ getContentPane().add(content);
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel
+ * uses a BorderLayout(), and the BorderLayout.SOUTH area
+ * is empty, to allow callers to add controls to the
+ * bottom of the panel if they want to (a close button is
+ * added if this demo is being run as a standalone demo).
+ */
+ JPanel createContent()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+
+ // create a panel of buttons to select the different styles of file
+ // chooser...
+ JPanel buttonPanel = new JPanel(new GridLayout(5, 1));
+ JButton openButton = new JButton("Open...");
+ openButton.setActionCommand("OPEN");
+ openButton.addActionListener(this);
+ buttonPanel.add(openButton);
+ JButton saveButton = new JButton("Save...");
+ saveButton.setActionCommand("SAVE");
+ saveButton.addActionListener(this);
+ buttonPanel.add(saveButton);
+ JButton queryButton = new JButton("Select Directory...");
+ queryButton.setActionCommand("SELECT_DIRECTORY");
+ queryButton.addActionListener(this);
+ buttonPanel.add(queryButton);
+ JButton openJavaButton = new JButton("Open Java file...");
+ openJavaButton.setActionCommand("OPEN_JAVA");
+ openJavaButton.addActionListener(this);
+ buttonPanel.add(openJavaButton);
+ JButton openMultiButton = new JButton("Open multiple files...");
+ openMultiButton.setActionCommand("OPEN_MULTI");
+ openMultiButton.addActionListener(this);
+ buttonPanel.add(openMultiButton);
+ panel.add(buttonPanel, BorderLayout.WEST);
+
+ // create a panel to display the selected file(s) and the return code
+ JPanel displayPanel = new JPanel(new BorderLayout());
+
+ selectedFileLabel = new JLabel("-");
+ selectedFileLabel.setBorder(BorderFactory.createTitledBorder("Selected File/Directory: "));
+ displayPanel.add(selectedFileLabel, BorderLayout.NORTH);
+
+ selectedFilesList = new JList();
+ JScrollPane sp = new JScrollPane(selectedFilesList);
+ sp.setBorder(BorderFactory.createTitledBorder("Selected Files: "));
+ displayPanel.add(sp);
+
+ returnCodeLabel = new JLabel("0");
+ returnCodeLabel.setBorder(BorderFactory.createTitledBorder("Return Code:"));
+ displayPanel.add(returnCodeLabel, BorderLayout.SOUTH);
+
+ panel.add(displayPanel);
+ return panel;
+ }
+
+ /**
+ * When the user clicks on a button, launch the appropriate file chooser
+ * and report the results.
+ *
+ * @param e the event.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ int option = 0;
+ File selectedFile = null;
+ File[] selectedFiles = new File[0];
+
+ if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ else if (e.getActionCommand().equals("OPEN"))
+ {
+ JFileChooser chooser = new JFileChooser();
+ option = chooser.showOpenDialog(this);
+ selectedFile = chooser.getSelectedFile();
+ selectedFiles = chooser.getSelectedFiles();
+ }
+ else if (e.getActionCommand().equals("OPEN_MULTI"))
+ {
+ JFileChooser chooser = new JFileChooser();
+ chooser.setMultiSelectionEnabled(true);
+ option = chooser.showOpenDialog(this);
+ selectedFile = chooser.getSelectedFile();
+ selectedFiles = chooser.getSelectedFiles();
+ }
+ else if (e.getActionCommand().equals("OPEN_JAVA"))
+ {
+ JFileChooser chooser = new JFileChooser();
+ chooser.setAcceptAllFileFilterUsed(false);
+ chooser.setFileFilter(new JavaFileFilter());
+ option = chooser.showOpenDialog(this);
+ selectedFile = chooser.getSelectedFile();
+ selectedFiles = chooser.getSelectedFiles();
+ }
+ else if (e.getActionCommand().equals("SAVE"))
+ {
+ JFileChooser chooser = new JFileChooser();
+ option = chooser.showSaveDialog(this);
+ selectedFile = chooser.getSelectedFile();
+ selectedFiles = chooser.getSelectedFiles();
+ }
+ else if (e.getActionCommand().equals("SELECT_DIRECTORY"))
+ {
+ JFileChooser chooser = new JFileChooser();
+ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ option = chooser.showDialog(this, "Select");
+ selectedFile = chooser.getSelectedFile();
+ selectedFiles = chooser.getSelectedFiles();
+ }
+
+ // display the selection and return code
+ if (selectedFile != null)
+ selectedFileLabel.setText(selectedFile.toString());
+ else
+ selectedFileLabel.setText("null");
+ DefaultListModel listModel = new DefaultListModel();
+ for (int i = 0; i < selectedFiles.length; i++)
+ listModel.addElement(selectedFiles[i]);
+ selectedFilesList.setModel(listModel);
+ returnCodeLabel.setText(Integer.toString(option));
+ }
+
+ public static void main(String[] args)
+ {
+ FileChooserDemo app = new FileChooserDemo("File Chooser Demo");
+ app.pack();
+ app.setVisible(true);
+ }
+
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/GNULookAndFeel.java b/libjava/classpath/examples/gnu/classpath/examples/swing/GNULookAndFeel.java
index 97e91a8..c8fd09d 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/swing/GNULookAndFeel.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/swing/GNULookAndFeel.java
@@ -22,8 +22,13 @@ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
package gnu.classpath.examples.swing;
import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import javax.swing.Icon;
import javax.swing.ImageIcon;
+import javax.swing.JCheckBox;
+import javax.swing.JRadioButton;
import javax.swing.UIDefaults;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.IconUIResource;
@@ -64,8 +69,10 @@ public class GNULookAndFeel extends BasicLookAndFeel
"MenuBar.background", new ColorUIResource(blueGray),
"MenuItem.background", new ColorUIResource(blueGray),
"ScrollBar.background", new ColorUIResource(blueGray),
-
- "Tree.closedIcon",
+ "CheckBox.icon", new CheckBoxIcon(),
+ "RadioButton.icon", new RadioButtonIcon(),
+
+ "Tree.closedIcon",
new IconUIResource(new ImageIcon
(getClass().getResource
(iconspath + "TreeClosed.png"))),
@@ -82,4 +89,177 @@ public class GNULookAndFeel extends BasicLookAndFeel
}
return LAF_defaults;
}
+
+ /**
+ * The icon used for CheckBoxes in the BasicLookAndFeel. This is an empty
+ * icon with a size of 13x13 pixels.
+ */
+ static class CheckBoxIcon
+ implements Icon
+ {
+ /**
+ * Returns the height of the icon. The BasicLookAndFeel CheckBox icon
+ * has a height of 13 pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconHeight()
+ {
+ return 13;
+ }
+
+ /**
+ * Returns the width of the icon. The BasicLookAndFeel CheckBox icon
+ * has a width of 13 pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconWidth()
+ {
+ return 13;
+ }
+
+ /**
+ * Paints the icon. The BasicLookAndFeel CheckBox icon is empty and does
+ * not need to be painted.
+ *
+ * @param c the component to be painted
+ * @param g the Graphics context to be painted with
+ * @param x the x position of the icon
+ * @param y the y position of the icon
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color save = g.getColor();
+ g.setColor(c.getForeground());
+ g.drawRect(x, y, getIconWidth(), getIconHeight());
+
+ JCheckBox item = (JCheckBox) c;
+ if (item.isSelected())
+ {
+ g.drawLine(3 + x, 5 + y, 3 + x, 9 + y);
+ g.drawLine(4 + x, 5 + y, 4 + x, 9 + y);
+ g.drawLine(5 + x, 7 + y, 9 + x, 3 + y);
+ g.drawLine(5 + x, 8 + y, 9 + x, 4 + y);
+ }
+
+ g.setColor(save);
+ }
+ }
+
+ /**
+ * The icon used for RadioButtons in the GNULookAndFeel. This is an empty
+ * icon with a size of 13x13 pixels.
+ */
+ static class RadioButtonIcon
+ implements Icon
+ {
+ /**
+ * Returns the height of the icon. The GNULookAndFeel RadioButton icon
+ * has a height of 13 pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconHeight()
+ {
+ return 13;
+ }
+
+ /**
+ * Returns the width of the icon. The GNULookAndFeel RadioButton icon
+ * has a width of 13 pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconWidth()
+ {
+ return 13;
+ }
+
+ /**
+ * Paints the icon. The GNULookAndFeel RadioButton icon is empty and does
+ * not need to be painted.
+ *
+ * @param c the component to be painted
+ * @param g the Graphics context to be painted with
+ * @param x the x position of the icon
+ * @param y the y position of the icon
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color savedColor = g.getColor();
+ JRadioButton b = (JRadioButton) c;
+
+ // draw outer circle
+ if (b.isEnabled())
+ g.setColor(Color.GRAY);
+ else
+ g.setColor(Color.GRAY);
+ g.drawLine(x + 2, y + 1, x + 3, y + 1);
+ g.drawLine(x + 4, y, x + 7, y);
+ g.drawLine(x + 8, y + 1, x + 9, y + 1);
+ g.drawLine(x + 10, y + 2, x + 10, y + 3);
+ g.drawLine(x + 11, y + 4, x + 11, y + 7);
+ g.drawLine(x + 10, y + 8, x + 10, y + 9);
+ g.drawLine(x + 8, y + 10, x + 9, y + 10);
+ g.drawLine(x + 4, y + 11, x + 7, y + 11);
+ g.drawLine(x + 2, y + 10, x + 3, y + 10);
+ g.drawLine(x + 1, y + 9, x + 1, y + 8);
+ g.drawLine(x, y + 7, x, y + 4);
+ g.drawLine(x + 1, y + 2, x + 1, y + 3);
+
+ if (b.getModel().isArmed())
+ {
+ g.setColor(Color.GRAY);
+ g.drawLine(x + 4, y + 1, x + 7, y + 1);
+ g.drawLine(x + 4, y + 10, x + 7, y + 10);
+ g.drawLine(x + 1, y + 4, x + 1, y + 7);
+ g.drawLine(x + 10, y + 4, x + 10, y + 7);
+ g.fillRect(x + 2, y + 2, 8, 8);
+ }
+ else
+ {
+ // only draw inner highlight if not filled
+ if (b.isEnabled())
+ {
+ g.setColor(Color.WHITE);
+
+ g.drawLine(x + 2, y + 8, x + 2, y + 9);
+ g.drawLine(x + 1, y + 4, x + 1, y + 7);
+ g.drawLine(x + 2, y + 2, x + 2, y + 3);
+ g.drawLine(x + 3, y + 2, x + 3, y + 2);
+ g.drawLine(x + 4, y + 1, x + 7, y + 1);
+ g.drawLine(x + 8, y + 2, x + 9, y + 2);
+ }
+ }
+
+ // draw outer highlight
+ if (b.isEnabled())
+ {
+ g.setColor(Color.WHITE);
+
+ // outer
+ g.drawLine(x + 10, y + 1, x + 10, y + 1);
+ g.drawLine(x + 11, y + 2, x + 11, y + 3);
+ g.drawLine(x + 12, y + 4, x + 12, y + 7);
+ g.drawLine(x + 11, y + 8, x + 11, y + 9);
+ g.drawLine(x + 10, y + 10, x + 10, y + 10);
+ g.drawLine(x + 8, y + 11, x + 9, y + 11);
+ g.drawLine(x + 4, y + 12, x + 7, y + 12);
+ g.drawLine(x + 2, y + 11, x + 3, y + 11);
+ }
+
+ if (b.isSelected())
+ {
+ if (b.isEnabled())
+ g.setColor(Color.BLACK);
+ else
+ g.setColor(Color.GRAY);
+ g.drawLine(x + 4, y + 3, x + 7, y + 3);
+ g.fillRect(x + 3, y + 4, 6, 4);
+ g.drawLine(x + 4, y + 8, x + 7, y + 8);
+ }
+ g.setColor(savedColor);
+ }
+ }
}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/ProgressBarDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/ProgressBarDemo.java
new file mode 100644
index 0000000..d62175b
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/swing/ProgressBarDemo.java
@@ -0,0 +1,219 @@
+/* ProgressBarDemo.java -- A demonstration of JProgressBars
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JProgressBar;
+import javax.swing.JSlider;
+import javax.swing.SwingUtilities;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class ProgressBarDemo
+ extends JFrame
+ implements ActionListener
+{
+
+ /**
+ * Creates a new ProgressBarDemo window with the specified title.
+ *
+ * @param title the title of the program window
+ */
+ ProgressBarDemo(String title)
+ {
+ super(title);
+ JPanel content = createContent();
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ getContentPane().add(content);
+ getContentPane().add(closePanel, BorderLayout.SOUTH);
+ }
+
+ static JPanel createContent()
+ {
+ JPanel content = new JPanel();
+ content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
+ JPanel horizontalProgressBar = createHorizontalProgressBar();
+ content.add(horizontalProgressBar);
+ content.add(Box.createVerticalStrut(10));
+ JPanel verticalProgressBar = createVerticalProgressBar();
+ content.add(verticalProgressBar);
+ return content;
+ }
+
+ private static JPanel createHorizontalProgressBar()
+ {
+ JPanel panel = new JPanel();
+ panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
+
+ // Plain progress bar.
+ final JProgressBar hor1 = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
+ panel.add(hor1);
+ final JSlider slider1 = new JSlider(JSlider.HORIZONTAL, 0, 100, 0);
+ slider1.addChangeListener(new ChangeListener()
+ {
+ public void stateChanged(ChangeEvent event)
+ {
+ hor1.setValue(slider1.getValue());
+ }
+ });
+ panel.add(slider1);
+
+ panel.add(Box.createVerticalStrut(5));
+
+ // Plain progress bar with some text.
+ final JProgressBar hor2 = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
+ hor2.setString("ProgressBar Demo");
+ hor2.setStringPainted(true);
+ panel.add(hor2);
+ final JSlider slider2 = new JSlider(JSlider.HORIZONTAL, 0, 100, 0);
+ slider2.addChangeListener(new ChangeListener()
+ {
+ public void stateChanged(ChangeEvent event)
+ {
+ hor2.setValue(slider2.getValue());
+ }
+ });
+ panel.add(slider2);
+
+ panel.add(Box.createVerticalStrut(5));
+
+ // Indeterminate progress bar.
+ final JProgressBar hor3 = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
+ hor3.setIndeterminate(true);
+ panel.add(hor3);
+
+ panel.add(Box.createVerticalStrut(5));
+
+ // Indeterminate progress bar with text.
+ final JProgressBar hor4 = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
+ hor4.setIndeterminate(true);
+ hor4.setString("Indeterminate ProgressBar");
+ hor4.setStringPainted(true);
+ panel.add(hor4);
+
+ return panel;
+ }
+
+ private static JPanel createVerticalProgressBar()
+ {
+ JPanel panel = new JPanel();
+ panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
+ final JProgressBar vert = new JProgressBar(JProgressBar.VERTICAL, 0, 100);
+ panel.add(vert);
+ final JSlider slider = new JSlider(JSlider.VERTICAL, 0, 100, 0);
+ slider.addChangeListener(new ChangeListener()
+ {
+ public void stateChanged(ChangeEvent event)
+ {
+ vert.setValue(slider.getValue());
+ }
+ });
+ panel.add(slider);
+
+ panel.add(Box.createHorizontalStrut(5));
+
+ final JProgressBar vert2 = new JProgressBar(JProgressBar.VERTICAL, 0, 100);
+ vert2.setString("ProgressBar Demo");
+ panel.add(vert2);
+ vert2.setStringPainted(true);
+ final JSlider slider2 = new JSlider(JSlider.VERTICAL, 0, 100, 0);
+ slider2.addChangeListener(new ChangeListener()
+ {
+ public void stateChanged(ChangeEvent event)
+ {
+ vert2.setValue(slider2.getValue());
+ }
+ });
+ panel.add(slider2);
+
+ panel.add(Box.createHorizontalStrut(5));
+
+ // Indeterminate progress bar.
+ final JProgressBar vert3 = new JProgressBar(JProgressBar.VERTICAL, 0, 100);
+ vert3.setIndeterminate(true);
+ panel.add(vert3);
+
+ panel.add(Box.createHorizontalStrut(5));
+
+ // Indeterminate progress bar with text.
+ final JProgressBar vert4 = new JProgressBar(JProgressBar.VERTICAL, 0, 100);
+ vert4.setIndeterminate(true);
+ vert4.setString("Indeterminate ProgressBar");
+ vert4.setStringPainted(true);
+ panel.add(vert4);
+ return panel;
+ }
+
+ public void actionPerformed(ActionEvent event)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * The entry point when running as a standalone program.
+ *
+ * @param args command line arguments
+ */
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater(
+ new Runnable()
+ {
+ public void run()
+ {
+ ProgressBarDemo app = new ProgressBarDemo("ProgressBar Demo");
+ app.pack();
+ app.setVisible(true);
+ }
+ });
+ }
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/ScrollBarDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/ScrollBarDemo.java
new file mode 100644
index 0000000..fce1373
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/swing/ScrollBarDemo.java
@@ -0,0 +1,141 @@
+/* ScrollBarDemo.java -- An example showing scroll bars in Swing.
+ Copyright (C) 2005, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollBar;
+
+/**
+ * A simple scroll bar demo showing various scroll bars in different states.
+ */
+public class ScrollBarDemo
+ extends JFrame
+ implements ActionListener
+{
+
+ /**
+ * Creates a new demo instance.
+ *
+ * @param title the frame title.
+ */
+ public ScrollBarDemo(String title)
+ {
+ super(title);
+ JPanel content = createContent();
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ content.add(closePanel, BorderLayout.SOUTH);
+ getContentPane().add(content);
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel
+ * uses a BorderLayout(), and the BorderLayout.SOUTH area
+ * is empty, to allow callers to add controls to the
+ * bottom of the panel if they want to (a close button is
+ * added if this demo is being run as a standalone demo).
+ */
+ JPanel createContent()
+ {
+ JPanel content = new JPanel(new BorderLayout());
+ JPanel panel = createScrollBarPanel();
+ content.add(panel);
+ return content;
+ }
+
+ private JPanel createScrollBarPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+
+ JPanel horizontalPanel = new JPanel();
+
+ JScrollBar scroll1a = new JScrollBar(JScrollBar.HORIZONTAL);
+ JScrollBar scroll1b = new JScrollBar(JScrollBar.HORIZONTAL);
+ scroll1b.setEnabled(false);
+ JScrollBar scroll1c = new JScrollBar(JScrollBar.HORIZONTAL);
+ scroll1c.putClientProperty("JScrollBar.isFreeStanding", Boolean.FALSE);
+ JScrollBar scroll1d = new JScrollBar(JScrollBar.HORIZONTAL);
+ scroll1d.putClientProperty("JScrollBar.isFreeStanding", Boolean.FALSE);
+ scroll1d.setEnabled(false);
+ horizontalPanel.add(scroll1a);
+ horizontalPanel.add(scroll1b);
+ horizontalPanel.add(scroll1c);
+ horizontalPanel.add(scroll1d);
+
+ panel.add(horizontalPanel, BorderLayout.NORTH);
+
+ JPanel verticalPanel = new JPanel();
+ verticalPanel.setLayout(new GridLayout(1, 7));
+
+ JScrollBar scroll2a = new JScrollBar(JScrollBar.VERTICAL);
+ JScrollBar scroll2b = new JScrollBar(JScrollBar.VERTICAL);
+ scroll2b.setEnabled(false);
+ JScrollBar scroll2c = new JScrollBar(JScrollBar.VERTICAL);
+ scroll2c.putClientProperty("JScrollBar.isFreeStanding", Boolean.FALSE);
+ JScrollBar scroll2d = new JScrollBar(JScrollBar.VERTICAL);
+ scroll2d.setEnabled(false);
+ scroll2d.putClientProperty("JScrollBar.isFreeStanding", Boolean.FALSE);
+
+ verticalPanel.add(scroll2a);
+ verticalPanel.add(new JPanel());
+ verticalPanel.add(scroll2b);
+ verticalPanel.add(new JPanel());
+ verticalPanel.add(scroll2c);
+ verticalPanel.add(new JPanel());
+ verticalPanel.add(scroll2d);
+
+ panel.add(verticalPanel, BorderLayout.EAST);
+
+ JPanel centerPanel = new JPanel(new GridLayout(1, 2));
+ centerPanel.add(new JScrollBar(JScrollBar.HORIZONTAL));
+ centerPanel.add(new JScrollBar(JScrollBar.VERTICAL));
+ panel.add(centerPanel);
+ return panel;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ ScrollBarDemo app = new ScrollBarDemo("ScrollBar Demo");
+ app.pack();
+ app.setVisible(true);
+ }
+
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/SliderDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/SliderDemo.java
new file mode 100644
index 0000000..736024c
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/swing/SliderDemo.java
@@ -0,0 +1,249 @@
+/* SliderDemo.java -- An example showing JSlider in various configurations.
+ Copyright (C) 2005, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JSlider;
+
+public class SliderDemo extends JFrame implements ActionListener
+{
+
+ JSlider hslider1;
+ JSlider hslider2;
+ JSlider hslider3;
+ JSlider hslider4;
+ JSlider hslider5;
+ JSlider hslider6;
+ JSlider hslider7;
+ JSlider hslider8;
+
+ JSlider vslider1;
+ JSlider vslider2;
+ JSlider vslider3;
+ JSlider vslider4;
+ JSlider vslider5;
+ JSlider vslider6;
+ JSlider vslider7;
+ JSlider vslider8;
+
+ JCheckBox enabledCheckBox;
+
+ public SliderDemo(String frameTitle)
+ {
+ super(frameTitle);
+ JPanel content = createContent();
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ content.add(closePanel, BorderLayout.SOUTH);
+ getContentPane().add(content);
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel
+ * uses a BorderLayout(), and the BorderLayout.SOUTH area
+ * is empty, to allow callers to add controls to the
+ * bottom of the panel if they want to (a close button is
+ * added if this demo is being run as a standalone demo).
+ */
+ JPanel createContent()
+ {
+ JPanel content = new JPanel(new BorderLayout());
+ JPanel panel = new JPanel(new GridLayout(1, 2));
+ panel.add(createHorizontalPanel());
+ panel.add(createVerticalPanel());
+ enabledCheckBox = new JCheckBox("Enabled");
+ enabledCheckBox.setSelected(true);
+ enabledCheckBox.setActionCommand("TOGGLE_ENABLED");
+ enabledCheckBox.addActionListener(this);
+ JPanel checkBoxPanel = new JPanel();
+ checkBoxPanel.add(enabledCheckBox);
+ JPanel panel2 = new JPanel(new BorderLayout());
+ panel2.add(panel);
+ panel2.add(checkBoxPanel, BorderLayout.SOUTH);
+ content.add(panel2);
+ return content;
+ }
+
+ private JPanel createHorizontalPanel()
+ {
+ JPanel panel = new JPanel(new GridLayout(8, 1));
+
+ hslider1 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ panel.add(hslider1);
+
+ hslider2 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider2.setMajorTickSpacing(20);
+ hslider2.setMinorTickSpacing(5);
+ hslider2.setPaintTicks(true);
+ panel.add(hslider2);
+
+ hslider3 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider3.setMajorTickSpacing(20);
+ hslider3.setMinorTickSpacing(5);
+ hslider3.setPaintLabels(true);
+ hslider3.setPaintTicks(true);
+ panel.add(hslider3);
+
+ hslider4 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider4.putClientProperty("JSlider.isFilled", Boolean.TRUE);
+ hslider4.setMajorTickSpacing(20);
+ hslider4.setMinorTickSpacing(5);
+ hslider4.setPaintLabels(true);
+ hslider4.setPaintTicks(true);
+ panel.add(hslider4);
+
+ hslider5 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider5.setInverted(true);
+ panel.add(hslider5);
+
+ hslider6 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider6.setInverted(true);
+ hslider6.setMajorTickSpacing(20);
+ hslider6.setMinorTickSpacing(5);
+ hslider6.setPaintTicks(true);
+ panel.add(hslider6);
+
+ hslider7 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider7.setInverted(true);
+ hslider7.setMajorTickSpacing(20);
+ hslider7.setMinorTickSpacing(5);
+ hslider7.setPaintLabels(true);
+ hslider7.setPaintTicks(true);
+ panel.add(hslider7);
+
+ hslider8 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider8.putClientProperty("JSlider.isFilled", Boolean.TRUE);
+ hslider8.setInverted(true);
+ hslider8.setMajorTickSpacing(20);
+ hslider8.setMinorTickSpacing(5);
+ hslider8.setPaintLabels(true);
+ hslider8.setPaintTicks(true);
+ panel.add(hslider8);
+
+ return panel;
+ }
+
+ private JPanel createVerticalPanel()
+ {
+ JPanel panel = new JPanel(new GridLayout(1, 8));
+
+ vslider1 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ panel.add(vslider1);
+
+ vslider2 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider2.setMajorTickSpacing(20);
+ vslider2.setMinorTickSpacing(5);
+ vslider2.setPaintTicks(true);
+ panel.add(vslider2);
+
+ vslider3 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider3.setMajorTickSpacing(20);
+ vslider3.setMinorTickSpacing(5);
+ vslider3.setPaintLabels(true);
+ vslider3.setPaintTicks(true);
+ panel.add(vslider3);
+
+ vslider4 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider4.putClientProperty("JSlider.isFilled", Boolean.TRUE);
+ vslider4.setMajorTickSpacing(20);
+ vslider4.setMinorTickSpacing(5);
+ vslider4.setPaintLabels(true);
+ vslider4.setPaintTicks(true);
+ panel.add(vslider4);
+
+ vslider5 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider5.setInverted(true);
+ panel.add(vslider5);
+
+ vslider6 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider6.setInverted(true);
+ vslider6.setMajorTickSpacing(20);
+ vslider6.setMinorTickSpacing(5);
+ vslider6.setPaintTicks(true);
+ panel.add(vslider6);
+
+ vslider7 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider7.setInverted(true);
+ vslider7.setMajorTickSpacing(20);
+ vslider7.setMinorTickSpacing(5);
+ vslider7.setPaintLabels(true);
+ vslider7.setPaintTicks(true);
+ panel.add(vslider7);
+
+ vslider8 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider8.putClientProperty("JSlider.isFilled", Boolean.TRUE);
+ vslider8.setInverted(true);
+ vslider8.setMajorTickSpacing(20);
+ vslider8.setMinorTickSpacing(5);
+ vslider8.setPaintLabels(true);
+ vslider8.setPaintTicks(true);
+ panel.add(vslider8);
+ return panel;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ else if (e.getActionCommand().equals("TOGGLE_ENABLED"))
+ {
+ boolean enabled = enabledCheckBox.isSelected();
+ hslider1.setEnabled(enabled);
+ hslider2.setEnabled(enabled);
+ hslider3.setEnabled(enabled);
+ hslider4.setEnabled(enabled);
+ hslider5.setEnabled(enabled);
+ hslider6.setEnabled(enabled);
+ hslider7.setEnabled(enabled);
+ hslider8.setEnabled(enabled);
+ vslider1.setEnabled(enabled);
+ vslider2.setEnabled(enabled);
+ vslider3.setEnabled(enabled);
+ vslider4.setEnabled(enabled);
+ vslider5.setEnabled(enabled);
+ vslider6.setEnabled(enabled);
+ vslider7.setEnabled(enabled);
+ vslider8.setEnabled(enabled);
+ }
+ }
+ public static void main(String[] args)
+ {
+ SliderDemo app = new SliderDemo("Slider Demo");
+ app.pack();
+ app.setVisible(true);
+ }
+
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/TextFieldDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/TextFieldDemo.java
new file mode 100644
index 0000000..5ddf116
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/swing/TextFieldDemo.java
@@ -0,0 +1,488 @@
+/* TextFieldDemo.java -- An example showing various textfields in Swing.
+ Copyright (C) 2005, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.GridLayout;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.DefaultCaret;
+import javax.swing.text.JTextComponent;
+
+/**
+ * A simple textfield demo showing various textfields in different states.
+ */
+public class TextFieldDemo
+ extends JFrame
+ implements ActionListener
+{
+
+ /**
+ * A custom caret for demonstration purposes. This class is inspired by the
+ * CornerCaret from the OReilly Swing book.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ static class CornerCaret extends DefaultCaret
+ {
+ public CornerCaret()
+ {
+ super();
+ setBlinkRate(500);
+ }
+
+ protected synchronized void damage(Rectangle r)
+ {
+ if (r == null) return;
+ x = r.x;
+ y = r.y + (r.height * 4 / 5 - 3);
+ width = 5;
+ height = 5;
+ repaint();
+ }
+
+ public void paint(Graphics g)
+ {
+ JTextComponent comp = getComponent();
+ if (comp == null) return;
+ int dot = getDot();
+ Rectangle r = null;
+ try
+ {
+ r = comp.modelToView(dot);
+ }
+ catch (BadLocationException e)
+ {
+ return;
+ }
+ if (r == null) return;
+ int dist = r.height * 4 / 5 - 3;
+ if ((x != r.x) || (y != r.y + dist))
+ {
+ repaint();
+ x = r.x;
+ y = r.y + dist;
+ width = 5;
+ height = 5;
+ }
+ if (isVisible())
+ {
+ g.drawLine(r.x, r.y + dist, r.x, r.y + dist + 4);
+ g.drawLine(r.x, r.y + dist + 4, r.x + 4, r.y + dist + 4);
+ }
+ }
+ }
+
+ /**
+ * The left aligned textfields and state buttons.
+ */
+ JTextField textfield1;
+ JTextField textfield2;
+ JTextField textfield3;
+ JCheckBox enabled1;
+ JCheckBox editable1;
+JPanel textFieldPanel1;
+ /**
+ * The right aligned textfields and state buttons.
+ */
+ JTextField textfield4;
+ JTextField textfield5;
+ JTextField textfield6;
+ JCheckBox enabled2;
+ JCheckBox editable2;
+
+ /**
+ * The centered textfields and state buttons.
+ */
+ JTextField textfield7;
+ JTextField textfield8;
+ JTextField textfield9;
+ JCheckBox enabled3;
+ JCheckBox editable3;
+
+ /**
+ * The custom colored textfields and state buttons.
+ */
+ JTextField textfield10;
+ JTextField textfield11;
+ JTextField textfield12;
+ JTextField textfield13;
+ JTextField textfield14;
+ JCheckBox enabled4;
+ JCheckBox editable4;
+
+ /**
+ * Some miscallenous textfield demos.
+ */
+ JTextField textfield15;
+ JTextField textfield16;
+ JCheckBox enabled5;
+ JCheckBox editable5;
+
+ /**
+ * Creates a new demo instance.
+ *
+ * @param title the frame title.
+ */
+ public TextFieldDemo(String title)
+ {
+ super(title);
+ JPanel content = createContent();
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ content.add(closePanel, BorderLayout.SOUTH);
+ getContentPane().add(content);
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel
+ * uses a BorderLayout(), and the BorderLayout.SOUTH area
+ * is empty, to allow callers to add controls to the
+ * bottom of the panel if they want to (a close button is
+ * added if this demo is being run as a standalone demo).
+ */
+ JPanel createContent()
+ {
+ JPanel content = new JPanel(new BorderLayout());
+ JPanel panel = new JPanel(new GridLayout(5, 1));
+ panel.add(createLeftAlignedPanel());
+ panel.add(createRightAlignedPanel());
+ panel.add(createCenteredPanel());
+ panel.add(createCustomColoredPanel());
+ panel.add(createMiscPanel());
+ content.add(panel);
+ //content.setPreferredSize(new Dimension(400, 300));
+ return content;
+ }
+
+ private JPanel createLeftAlignedPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ panel.setBorder(BorderFactory.createTitledBorder("Left aligned"));
+
+ textFieldPanel1 = new JPanel();
+ textFieldPanel1.setLayout(new BoxLayout(textFieldPanel1, BoxLayout.X_AXIS));
+
+ textfield1 = new JTextField("Hello World!");
+ textfield1.setHorizontalAlignment(JTextField.LEFT);
+ textfield1.setFont(new Font("Dialog", Font.PLAIN, 8));
+ textFieldPanel1.add(textfield1);
+
+ textfield2 = new JTextField("Hello World!");
+ textfield2.setHorizontalAlignment(JTextField.LEFT);
+ textfield2.setFont(new Font("Dialog", Font.ITALIC, 12));
+ textFieldPanel1.add(textfield2);
+
+ textfield3 = new JTextField("Hello World!");
+ textfield3.setHorizontalAlignment(JTextField.LEFT);
+ textfield3.setFont(new Font("Dialog", Font.BOLD, 14));
+ textFieldPanel1.add(textfield3);
+
+ panel.add(textFieldPanel1);
+
+ JPanel statePanel = new JPanel();
+ statePanel.setLayout(new BoxLayout(statePanel, BoxLayout.Y_AXIS));
+ statePanel.add(Box.createVerticalGlue());
+ enabled1 = new JCheckBox("enabled");
+ enabled1.setSelected(true);
+ enabled1.addActionListener(this);
+ enabled1.setActionCommand("ENABLED1");
+ statePanel.add(enabled1);
+ editable1 = new JCheckBox("editable");
+ editable1.setSelected(true);
+ editable1.addActionListener(this);
+ editable1.setActionCommand("EDITABLE1");
+ statePanel.add(editable1);
+ statePanel.add(Box.createVerticalGlue());
+ panel.add(statePanel, BorderLayout.EAST);
+
+ return panel;
+ }
+
+ private JPanel createRightAlignedPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ panel.setBorder(BorderFactory.createTitledBorder("Right aligned"));
+
+ JPanel textFieldPanel = new JPanel();
+ textFieldPanel.setLayout(new BoxLayout(textFieldPanel, BoxLayout.X_AXIS));
+
+ textfield4 = new JTextField("Hello World!");
+ textfield4.setHorizontalAlignment(JTextField.RIGHT);
+ textfield4.setFont(new Font("Dialog", Font.PLAIN, 8));
+ textFieldPanel.add(textfield4);
+
+ textfield5 = new JTextField("Hello World!");
+ textfield5.setHorizontalAlignment(JTextField.RIGHT);
+ textfield5.setFont(new Font("Dialog", Font.ITALIC, 12));
+ textFieldPanel.add(textfield5);
+
+ textfield6 = new JTextField("Hello World!");
+ textfield6.setHorizontalAlignment(JTextField.RIGHT);
+ textfield6.setFont(new Font("Dialog", Font.BOLD, 14));
+ textFieldPanel.add(textfield6);
+
+ panel.add(textFieldPanel);
+
+ JPanel statePanel = new JPanel();
+ statePanel.setLayout(new BoxLayout(statePanel, BoxLayout.Y_AXIS));
+ statePanel.add(Box.createVerticalGlue());
+ enabled2 = new JCheckBox("enabled");
+ enabled2.setSelected(true);
+ enabled2.addActionListener(this);
+ enabled2.setActionCommand("ENABLED2");
+ statePanel.add(enabled2);
+ editable2 = new JCheckBox("editable");
+ editable2.setSelected(true);
+ editable2.addActionListener(this);
+ editable2.setActionCommand("EDITABLE2");
+ statePanel.add(editable2);
+ statePanel.add(Box.createVerticalGlue());
+ panel.add(statePanel, BorderLayout.EAST);
+
+ return panel;
+ }
+
+ private JPanel createCenteredPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ panel.setBorder(BorderFactory.createTitledBorder("Centered"));
+
+ JPanel textFieldPanel = new JPanel();
+ textFieldPanel.setLayout(new BoxLayout(textFieldPanel, BoxLayout.X_AXIS));
+
+ textfield7 = new JTextField("Hello World!");
+ textfield7.setHorizontalAlignment(JTextField.CENTER);
+ textfield7.setFont(new Font("Dialog", Font.PLAIN, 8));
+ textFieldPanel.add(textfield7);
+
+ textfield8 = new JTextField("Hello World!");
+ textfield8.setHorizontalAlignment(JTextField.CENTER);
+ textfield8.setFont(new Font("Dialog", Font.ITALIC, 12));
+ textFieldPanel.add(textfield8);
+
+ textfield9 = new JTextField("Hello World!");
+ textfield9.setHorizontalAlignment(JTextField.CENTER);
+ textfield9.setFont(new Font("Dialog", Font.BOLD, 14));
+ textFieldPanel.add(textfield9);
+
+ panel.add(textFieldPanel);
+
+ JPanel statePanel = new JPanel();
+ statePanel.setLayout(new BoxLayout(statePanel, BoxLayout.Y_AXIS));
+ statePanel.add(Box.createVerticalGlue());
+ enabled3 = new JCheckBox("enabled");
+ enabled3.setSelected(true);
+ enabled3.addActionListener(this);
+ enabled3.setActionCommand("ENABLED3");
+ statePanel.add(enabled3);
+ editable3 = new JCheckBox("editable");
+ editable3.setSelected(true);
+ editable3.addActionListener(this);
+ editable3.setActionCommand("EDITABLE3");
+ statePanel.add(editable3);
+ statePanel.add(Box.createVerticalGlue());
+ panel.add(statePanel, BorderLayout.EAST);
+
+ return panel;
+ }
+
+ private JPanel createCustomColoredPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+
+ JPanel textFieldPanel = new JPanel();
+ panel.setBorder(BorderFactory.createTitledBorder("Custom colors"));
+ textFieldPanel.setLayout(new BoxLayout(textFieldPanel, BoxLayout.X_AXIS));
+
+ textfield10 = new JTextField("custom foreground");
+ textfield10.setForeground(Color.GREEN);
+ textFieldPanel.add(textfield10);
+
+ textfield11 = new JTextField("custom background");
+ textfield11.setForeground(Color.YELLOW);
+ textFieldPanel.add(textfield11);
+
+ textfield12 = new JTextField("custom disabled textcolor");
+ textfield12.setDisabledTextColor(Color.BLUE);
+ textFieldPanel.add(textfield12);
+
+ textfield13 = new JTextField("custom selected text color");
+ textfield13.setSelectedTextColor(Color.RED);
+ textFieldPanel.add(textfield13);
+
+ textfield14 = new JTextField("custom selection color");
+ textfield14.setSelectionColor(Color.CYAN);
+ textFieldPanel.add(textfield14);
+
+ panel.add(textFieldPanel);
+
+ JPanel statePanel = new JPanel();
+ statePanel.setLayout(new BoxLayout(statePanel, BoxLayout.Y_AXIS));
+ statePanel.add(Box.createVerticalGlue());
+ enabled4 = new JCheckBox("enabled");
+ enabled4.setSelected(true);
+ enabled4.addActionListener(this);
+ enabled4.setActionCommand("ENABLED4");
+ statePanel.add(enabled4);
+ editable4 = new JCheckBox("editable");
+ editable4.setSelected(true);
+ editable4.addActionListener(this);
+ editable4.setActionCommand("EDITABLE4");
+ statePanel.add(editable4);
+ statePanel.add(Box.createVerticalGlue());
+ panel.add(statePanel, BorderLayout.EAST);
+
+ return panel;
+ }
+
+ private JPanel createMiscPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ panel.setBorder(BorderFactory.createTitledBorder("Miscallenous"));
+
+ JPanel textFieldPanel = new JPanel();
+ textFieldPanel.setLayout(new BoxLayout(textFieldPanel, BoxLayout.X_AXIS));
+
+ textfield15 = new JTextField("Custom Caret");
+ textfield15.setCaret(new CornerCaret());
+ textFieldPanel.add(textfield15);
+
+ textfield16 = new JTextField("Custom Caret color");
+ textfield16.setCaretColor(Color.MAGENTA);
+ textFieldPanel.add(textfield16);
+
+ panel.add(textFieldPanel);
+
+ JPanel statePanel = new JPanel();
+ statePanel.setLayout(new BoxLayout(statePanel, BoxLayout.Y_AXIS));
+ statePanel.add(Box.createVerticalGlue());
+ enabled5 = new JCheckBox("enabled");
+ enabled5.setSelected(true);
+ enabled5.addActionListener(this);
+ enabled5.setActionCommand("ENABLED5");
+ statePanel.add(enabled5);
+ editable5 = new JCheckBox("editable");
+ editable5.setSelected(true);
+ editable5.addActionListener(this);
+ editable5.setActionCommand("EDITABLE5");
+ statePanel.add(editable5);
+ statePanel.add(Box.createVerticalGlue());
+ panel.add(statePanel, BorderLayout.EAST);
+
+ return panel;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ else if (e.getActionCommand().equals("ENABLED1"))
+ {
+ boolean enabled = enabled1.isSelected();
+ textfield1.setEnabled(enabled);
+ textfield2.setEnabled(enabled);
+ textfield3.setEnabled(enabled);
+ }
+ else if (e.getActionCommand().equals("EDITABLE1"))
+ {
+ boolean editable = editable1.isSelected();
+ textfield1.setEditable(editable);
+ textfield2.setEditable(editable);
+ textfield3.setEditable(editable);
+ }
+ else if (e.getActionCommand().equals("ENABLED2"))
+ {
+ boolean enabled = enabled2.isSelected();
+ textfield4.setEnabled(enabled);
+ textfield5.setEnabled(enabled);
+ textfield6.setEnabled(enabled);
+ }
+ else if (e.getActionCommand().equals("EDITABLE2"))
+ {
+ boolean editable = editable2.isSelected();
+ textfield4.setEditable(editable);
+ textfield5.setEditable(editable);
+ textfield6.setEditable(editable);
+ }
+ else if (e.getActionCommand().equals("ENABLED3"))
+ {
+ boolean enabled = enabled3.isSelected();
+ textfield7.setEnabled(enabled);
+ textfield8.setEnabled(enabled);
+ textfield9.setEnabled(enabled);
+ }
+ else if (e.getActionCommand().equals("EDITABLE3"))
+ {
+ boolean editable = editable3.isSelected();
+ textfield7.setEditable(editable);
+ textfield8.setEditable(editable);
+ textfield9.setEditable(editable);
+ }
+ else if (e.getActionCommand().equals("ENABLED4"))
+ {
+ boolean enabled = enabled4.isSelected();
+ textfield10.setEnabled(enabled);
+ textfield11.setEnabled(enabled);
+ textfield12.setEnabled(enabled);
+ textfield13.setEnabled(enabled);
+ textfield14.setEnabled(enabled);
+ }
+ else if (e.getActionCommand().equals("EDITABLE4"))
+ {
+ boolean editable = editable4.isSelected();
+ textfield10.setEditable(editable);
+ textfield11.setEditable(editable);
+ textfield12.setEditable(editable);
+ textfield13.setEditable(editable);
+ textfield14.setEditable(editable);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ TextFieldDemo app = new TextFieldDemo("TextField Demo");
+ app.pack();
+ app.setVisible(true);
+ }
+
+}