diff options
Diffstat (limited to 'libjava/classpath/examples')
64 files changed, 1552 insertions, 1561 deletions
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 38c4ecb..f71c24f 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java @@ -89,7 +89,7 @@ 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 f53609c..944f661 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java @@ -90,7 +90,7 @@ public class Demo System.out.print("."); } System.out.println("ok."); - System.out.println(); + System.out.println(); // Test the stream oriented communication. DirectTest.main(args); diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPass.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPass.java index d17e91f..eecf6f3 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPass.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPass.java @@ -47,11 +47,11 @@ package gnu.classpath.examples.CORBA.SimpleCommunication.communication; public class StructureToPass implements org.omg.CORBA.portable.IDLEntity { - /** - * Use serialVersionUID for interoperability. + /** + * 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/StructureToReturn.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturn.java index 5dc843a..2f497cb 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturn.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturn.java @@ -47,11 +47,11 @@ import org.omg.CORBA.portable.IDLEntity; public class StructureToReturn implements IDLEntity { - /** - * Use serialVersionUID for interoperability. + /** + * 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/TreeNode.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNode.java index b267f39..4fb2834 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNode.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNode.java @@ -47,11 +47,11 @@ package gnu.classpath.examples.CORBA.SimpleCommunication.communication; public class TreeNode implements org.omg.CORBA.portable.IDLEntity { - /** - * Use serialVersionUID for interoperability. + /** + * Use serialVersionUID for interoperability. */ private static final long serialVersionUID = 1; - + /** The TreeNode name */ public String name = null; diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisException.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisException.java index cf20d61..fcf632b 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisException.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisException.java @@ -53,11 +53,11 @@ public class WeThrowThisException extends UserException implements IDLEntity { - /** - * Use serialVersionUID for interoperability. + /** + * Use serialVersionUID for interoperability. */ private static final long serialVersionUID = 1; - + /** * Our specific field, transferred to client. */ diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java index adf4d25..23ebc82 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java @@ -114,4 +114,4 @@ public abstract class WeThrowThisExceptionHelper ostream.write_string(id()); ostream.write_long(value.ourField); } -}
\ No newline at end of file +} diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterImplBase.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterImplBase.java index 237c230..02e5e1a 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterImplBase.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterImplBase.java @@ -54,7 +54,7 @@ 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 DemoServant} of our case). - * + * * Following CORBA standards, the name of this class must start from * underscore and end by the "ImplBase". * diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterStub.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterStub.java index c8e0ccd..7481c4e 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterStub.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterStub.java @@ -55,7 +55,7 @@ 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". * diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/CanvasWorld.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/CanvasWorld.java index 9e1a70f..5ec902d 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/CanvasWorld.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/CanvasWorld.java @@ -56,8 +56,8 @@ import javax.swing.JScrollPane; * The purpose of this simple example is to check if the mouse events are * correctly received in a scrollable canvas and also if the canvas are * correctly repainted. The similar canvas are used in various games and - * interactive demonstrations. - * + * interactive demonstrations. + * * The user can set one of the three possible figures with the different * mouse buttons. The figure must be set where the user have clicked the * mouse. @@ -82,17 +82,17 @@ public class CanvasWorld * Black cross, set by the right mouse button. */ public static final int BLACK = 1; - + /** * Blue and smaller oval, set by the middle mouse button. */ public static final int HINT = 2; - + /** * The message string is displayed at the top of the window. */ String message = "Click left, right or middle button in to set the figure"; - + /** * The additinal message, related to the mouse events. */ @@ -117,7 +117,7 @@ public class CanvasWorld * The collection of the black crosses. */ ArrayList blacks = new ArrayList(); - + /** * The collection of the smaller blue crosses. */ @@ -147,12 +147,12 @@ public class CanvasWorld g.fillRect(0, 0, w, h); drawGrid(w, h, g); - + g.setColor(Color.black); - + g.drawString(message, W, W); g.drawString(mouse, W, 2*W); - + drawFigures(g); } @@ -177,7 +177,7 @@ public class CanvasWorld g.setColor(Color.lightGray); int xs = 2*W+W/2; - + // Draw vertical lines: for (int x = 0; x < w; x += W) { @@ -189,7 +189,7 @@ public class CanvasWorld { g.drawLine(0, y, w, y); } - + g.setColor(Color.gray); } @@ -200,7 +200,7 @@ public class CanvasWorld g.setColor(Color.black); drawDots(blacks, g, BLACK); - + g.setColor(Color.blue); drawDots(hints, g, HINT); } @@ -273,7 +273,7 @@ public class CanvasWorld public void mouseEntered(MouseEvent m) { mouse = "Mouse entered."; - repaint(); + repaint(); } public void mousePressed(MouseEvent m) @@ -284,7 +284,7 @@ public class CanvasWorld public void mouseReleased(MouseEvent m) { - mouse = "Mouse released at "+m.getX()+","+m.getY(); + mouse = "Mouse released at "+m.getX()+","+m.getY(); repaint(); } @@ -293,7 +293,7 @@ public class CanvasWorld mouse = "Mouse exited"; repaint(); } - + public static void main(String[] args) { JFrame frame = new JFrame(); @@ -304,4 +304,4 @@ public class CanvasWorld frame.setVisible(true); } -}
\ No newline at end of file +} diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ChatConstants.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ChatConstants.java index b0552b4..5b3d755 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ChatConstants.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ChatConstants.java @@ -44,8 +44,8 @@ import java.awt.Color; * The chat color code constants, used to indicate who is talking. * Additionally, the red color is reseved for the most important messages, * related to the start and end of the game. - * - * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ public class ChatConstants { @@ -68,7 +68,7 @@ public class ChatConstants * Messages from the game server/ */ public static byte GAME_SERVER = 3; - + /** * The array of the used colors. */ @@ -77,4 +77,4 @@ public class ChatConstants { Color.black, new Color(0, 80, 0), new Color(0, 0, 128), Color.blue }; -}
\ No newline at end of file +} diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ClientFrame.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ClientFrame.java index c3d8300b..04b8dd9 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ClientFrame.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ClientFrame.java @@ -63,8 +63,8 @@ public class ClientFrame /** * The size of the playing field. */ - public final Dimension DESK_SIZE = - new Dimension(624, 352-PlayingDesk.W); + public final Dimension DESK_SIZE = + new Dimension(624, 352-PlayingDesk.W); /** * Use serialVersionUID for interoperability. @@ -123,7 +123,7 @@ public class ClientFrame JLabel lbState = new JLabel(); JButton bChat = new JButton(); - + JButton bPaste = new JButton(); public ClientFrame() @@ -204,7 +204,7 @@ public class ClientFrame bChat_actionPerformed(e); } }); - + bPaste.setText("Paste"); bPaste.setToolTipText("Paste, same as Ctrl-V"); bPaste.addActionListener(new java.awt.event.ActionListener() @@ -214,10 +214,10 @@ public class ClientFrame bPaste_actionPerformed(e); } }); - + desk.setMaximumSize(DESK_SIZE); desk.setPreferredSize(DESK_SIZE); - + scroll.getViewport().add(desk, null); getContentPane().add(scroll, BorderLayout.CENTER); getContentPane().add(pnBottom, BorderLayout.SOUTH); @@ -235,7 +235,7 @@ public class ClientFrame pnButtons.add(bLeave, null); pnButtons.add(bReset, null); pnButtons.add(bExit, null); - pnButtons.add(bPaste, null); + pnButtons.add(bPaste, null); desk.player.set_current_state(State.DISCONNECTED); } @@ -405,7 +405,7 @@ public class ClientFrame ex.printStackTrace(); } } - + /** * Work around our keyboard shortcut handling that is still not working * properly. @@ -413,5 +413,5 @@ public class ClientFrame void bPaste_actionPerformed(ActionEvent e) { taUrl.paste(); - } -}
\ No newline at end of file + } +} diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Demo.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Demo.java index b832178..3461f02 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Demo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Demo.java @@ -46,8 +46,8 @@ import java.io.FileReader; /** * The main executable class of the game client. - * - * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ public class Demo { @@ -96,4 +96,4 @@ public class Demo e.printStackTrace(); } } -}
\ No newline at end of file +} diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManager.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManager.java index 4d632e8..c08f49a 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManager.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManager.java @@ -43,11 +43,11 @@ import java.rmi.RemoteException; /** * The game manager interface. - * + * * Defines the operations of the game server that connects two players into * the game. The game server does not participate in the game itself. - * - * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ public interface GameManager extends Remote { @@ -65,4 +65,4 @@ public interface GameManager extends Remote * @throws RemoteException */ void unregister(Player player) throws RemoteException; -}
\ No newline at end of file +} diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManagerImpl.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManagerImpl.java index fc449bc..cf30531 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManagerImpl.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManagerImpl.java @@ -44,8 +44,8 @@ import org.omg.CORBA.Object; /** * The manager connects two players into the game. - * - * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ public class GameManagerImpl implements GameManager @@ -132,4 +132,4 @@ public class GameManagerImpl } System.out.println("Unregistering player"); } -}
\ No newline at end of file +} diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/IorReader.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/IorReader.java index 73a8eec..4afd475 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/IorReader.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/IorReader.java @@ -49,14 +49,14 @@ import org.omg.CORBA.BAD_PARAM; import org.omg.CORBA.DATA_CONVERSION; /** - * Reads the remote URL. Following formal/04-03-12, CORBA should be able to do + * Reads the remote URL. Following formal/04-03-12, CORBA should be able to do * this without the help of this class. However some popular class libraries - * are written using the older CORBA specifications and may not handle + * are written using the older CORBA specifications and may not handle * functionality, require by this game. This class substitutes the functionality, * ensuring that these implementations will also start and we will be able * to test the interoperability. - * - * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ public class IorReader { @@ -93,7 +93,7 @@ public class IorReader throw d; } } - + /** * Read IOR from the file in the local file system. */ @@ -120,5 +120,5 @@ public class IorReader d.initCause(ex); throw (d); } - } + } } diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/OrbStarter.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/OrbStarter.java index 3852945..5463265 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/OrbStarter.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/OrbStarter.java @@ -51,7 +51,7 @@ import org.omg.PortableServer.Servant; /** * Starts the ORBs, involved into this application. - * + * * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ public class OrbStarter @@ -61,12 +61,12 @@ public class OrbStarter * manager by host (IP) and port rather than by the rather long IOR string. */ static int MANAGER_NAMER_PORT = 1500; - + /** * The used port range (understood and used by GNU Classpath only). */ static String USED_PORT_RANGE = "1501-1503"; - + /** * Specify the file where under start the game manager writes its IOR. * You may specify the path if the game manager and player clients have @@ -74,8 +74,8 @@ public class OrbStarter * floppy and then read from the floppy on the client side. Both clients * and server will use this constant. Set to null not to write the IOR. */ - static String WRITE_URL_TO_FILE = "game_manager_ior.txt"; - + static String WRITE_URL_TO_FILE = "game_manager_ior.txt"; + /** * Start the manager ORB. * @return the manager URL if it starts. @@ -148,7 +148,7 @@ public class OrbStarter return "Exception: " + e; } } - + /** * Start the client ORB. */ @@ -156,10 +156,10 @@ public class OrbStarter { desk.ior = null; desk.ok = false; - + final Properties p = new Properties(); p.put("gnu.CORBA.ListenerPort", USED_PORT_RANGE); - + try { new Thread() @@ -232,5 +232,5 @@ public class OrbStarter } }); return desk.ior; - } + } } diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Player.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Player.java index ff5624b..ced7d5d 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Player.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Player.java @@ -45,8 +45,8 @@ import java.rmi.RemoteException; /** * Defines remote methods that are invoked by another player or by the * challenge server. - * - * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ public interface Player extends Remote { @@ -93,4 +93,4 @@ public interface Player extends Remote * containing the ends of the builded line. */ void receive_move(int x, int y, Point[] victory) throws RemoteException; -}
\ No newline at end of file +} diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayerImpl.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayerImpl.java index c30f7d5..30b32c4 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayerImpl.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayerImpl.java @@ -47,8 +47,8 @@ import java.rmi.RemoteException; * The implementation of the PlayerCommunicator, providing the local * functionality. Apart remote methods, the class also defines some local * methods, needed for the co-ordinated work with the game user interface. - * - * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ public class PlayerImpl implements Player, State @@ -107,10 +107,10 @@ public class PlayerImpl /** * Called when we make the move. The PlayingTable is responsible for checking * the correctness of the move and detecting the victory. - * + * * @param x x position of the new dot. * @param y y position of the new dot. - * + * * @param victory array of two memebers, representing the endpoints of the * drawn line (victory detected) or null if no such yet exists. */ @@ -189,14 +189,14 @@ public class PlayerImpl /** * Receive the invitation to play from the patner or the game manager. - * + * * @param address the address (host and port) of the remote partner. * @param youStart if true, the game manager instructs to start the game first * (another side is instructed to start the game second). - * + * * Game server may also chat a little bit with both players, saying that the * game has started. - * + * * @return true on success. */ public boolean start_game(Player otherPlayer, boolean youStart) @@ -232,7 +232,7 @@ public class PlayerImpl /** * Receive the chat message from the friend or challenge server (remote). * Possible at any state, always remote. - * + * * @param color the color code, used to highlight the message. * @param text the message text. */ @@ -260,7 +260,7 @@ public class PlayerImpl /** * Receive friends move (possible at I_WAIT_FOR_YOUR_MOVE). - * + * * @param x grid position. * @param y grid position. * @param victory if not a null, the friend thinks that it has won, the @@ -272,4 +272,4 @@ public class PlayerImpl // The state changes are handled by the PlayingTable desk.friendsMove(x, y, victory); } -}
\ No newline at end of file +} diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayingDesk.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayingDesk.java index fa8966f..681d42e 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayingDesk.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayingDesk.java @@ -269,10 +269,10 @@ public class PlayingDesk { g.drawLine(0, y, w, y); } - + g.setColor(Color.gray); g.drawRect(0,0, frame.DESK_SIZE.width, frame.DESK_SIZE.height); - g.drawRect(0,0, frame.DESK_SIZE.width+3, frame.DESK_SIZE.height+3); + g.drawRect(0,0, frame.DESK_SIZE.width+3, frame.DESK_SIZE.height+3); } public void drawFigures(Graphics g) @@ -446,8 +446,8 @@ public class PlayingDesk frame.talk(Color.black, "Partner goes " + x + "-" + y + ". Your move?"); player.set_current_state(I_THINK); - } - repaint(); + } + repaint(); } } catch (RemoteException rex) @@ -509,4 +509,4 @@ public class PlayingDesk ex.printStackTrace(); } } -}
\ No newline at end of file +} diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/State.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/State.java index 7285396..a759225 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/State.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/State.java @@ -40,15 +40,15 @@ package gnu.classpath.examples.CORBA.swing.x5; /** * Defines the states in that the player can be. - * - * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ public interface State { /** * The initial ("disconnected") state. */ int DISCONNECTED = 0; - + /** * The state, indicating that the player has been queued for the game and * waiting for the partner to come. @@ -74,9 +74,9 @@ public interface State { * States that we have lost. */ int I_HAVE_LOST = 5; - + /** * The "inconsistent" state when it is not possible to continue the game. */ int ERROR = -1; -}
\ No newline at end of file +} diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/X5Server.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/X5Server.java index 7717834..516c701 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/X5Server.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/X5Server.java @@ -49,22 +49,22 @@ import java.net.Socket; /** * The main executable class of the game manager server. - * + * * The manager address server returns the IOR address string of the game * manager. Hence the user does not need to enter the rather long IOR address * string and only needs to specify the host and port of the machine where the * game manager is running. - * + * * The manager address server starts the main game manager as well. - * + * * This server acts as a HTTP server that always returns the same response. This * primitive functionality is sufficient for its task. - * + * * The more complex CORBA applications should use the name service instead. We * do not use the name service as this would require to start additional * external application, specific for the different java platforms. - * - * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ public class X5Server { diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManagerImpl_Tie.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManagerImpl_Tie.java index a0c33df..54ef1e9 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManagerImpl_Tie.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManagerImpl_Tie.java @@ -56,14 +56,14 @@ import org.omg.PortableServer.Servant; * Normally generated with rmic compiler, this class represents the GameManager * Tie on the client side. The Game Manager methods contain the code for remote * invocation. - * - * This class is normally generated with rmic or grmic from the + * + * This class is normally generated with rmic or grmic from the * {@link GameManagerImpl}. See tools/gnu/classpath/tools/giop/README. - * + * * In this example the class was manually edited and commented for better * understanding of functionality. - * - * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ public class _GameManagerImpl_Tie extends Servant @@ -77,7 +77,7 @@ public class _GameManagerImpl_Tie /** * The GameManager repository Id. */ - private static final String[] _type_ids = + private static final String[] _type_ids = { "RMI:gnu.classpath.examples.CORBA.swing.x5.GameManager:0000000000000000" }; /** @@ -161,7 +161,7 @@ public class _GameManagerImpl_Tie /** * This method is invoked by CORBA system to handle the remote invocation. - * + * * @param method the name of the method being invoked. * @param _in the stream to read the method parameters. * @param reply the responsed handler that can create the output stream to @@ -173,7 +173,7 @@ public class _GameManagerImpl_Tie { try { - org.omg.CORBA_2_3.portable.InputStream in = + org.omg.CORBA_2_3.portable.InputStream in = (org.omg.CORBA_2_3.portable.InputStream) _in; if (method.equals("requestTheGame")) { @@ -206,4 +206,4 @@ public class _GameManagerImpl_Tie throw new UnknownException(ex); } } -}
\ No newline at end of file +} diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManager_Stub.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManager_Stub.java index e927996..52fd103 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManager_Stub.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManager_Stub.java @@ -54,22 +54,22 @@ import org.omg.CORBA.portable.ServantObject; * Normally generated with rmic compiler, this class represents the GameManager * Stub on the client side. The Game Manager methods contain the code for * remote invocation. - * + * * This class is normally generated with rmic from the {@link GameManagerImpl}: * <pre> * rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.GameManagerImpl * </pre> * (the compiled package must be present in the current folder). - * - * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ public class _GameManager_Stub extends Stub implements GameManager { - /** - * Use serialVersionUID for interoperability. + /** + * Use serialVersionUID for interoperability. */ private static final long serialVersionUID = 1; - + private static final String[] _type_ids = { "RMI:gnu.classpath.examples.CORBA.swing.x5.GameManager:0000000000000000" }; @@ -77,7 +77,7 @@ public class _GameManager_Stub extends Stub implements GameManager { return _type_ids; } - + /** * Notify the manager that the player is no longer willing to play and * should be removed from the queue. @@ -141,7 +141,7 @@ public class _GameManager_Stub extends Stub implements GameManager } } } - + /** * The method that the user should invoke. */ @@ -204,4 +204,4 @@ public class _GameManager_Stub extends Stub implements GameManager } } } -}
\ No newline at end of file +} diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_PlayerImpl_Tie.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_PlayerImpl_Tie.java index f6c5f47..bc2333c 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_PlayerImpl_Tie.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_PlayerImpl_Tie.java @@ -57,14 +57,14 @@ import org.omg.PortableServer.Servant; * Generate with rmic, command line * rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.PlayerImpl * (the compiled package must be present in the current folder). - * - * This class is normally generated with rmic or grmic from the + * + * This class is normally generated with rmic or grmic from the * {@link PlayerImpl}. See tools/gnu/classpath/tools/giop/README. - * - * In this example the class was manually edited and commented for better + * + * In this example the class was manually edited and commented for better * understanding of functionality. - * - * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ public class _PlayerImpl_Tie extends Servant implements Tie { @@ -206,4 +206,4 @@ public class _PlayerImpl_Tie extends Servant implements Tie throw new UnknownException(ex); } } -}
\ No newline at end of file +} diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_Player_Stub.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_Player_Stub.java index eeb5cf0..c5a2089 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_Player_Stub.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_Player_Stub.java @@ -56,25 +56,25 @@ import org.omg.CORBA.portable.ServantObject; * Generate with rmic, command line * rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.PlayerImpl * (the compiled package must be present in the current folder). - * + * * This class is normally generated with rmic from the {@link GameManagerImpl}: * <pre> * rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.GameManagerImpl * </pre> * (the compiled package must be present in the current folder). - * - * In this example the class was manually edited and commented for better + * + * In this example the class was manually edited and commented for better * understanding of functionality. - * - * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ public class _Player_Stub extends Stub implements Player { - /** - * Use serialVersionUID for interoperability. + /** + * Use serialVersionUID for interoperability. */ private static final long serialVersionUID = 1; - + private static final String[] _type_ids = { "RMI:gnu.classpath.examples.CORBA.swing.x5.Player:0000000000000000" }; @@ -82,7 +82,7 @@ public class _Player_Stub extends Stub implements Player { return _type_ids; } - + public boolean start_game(Player arg0, boolean arg1) throws RemoteException { @@ -394,4 +394,4 @@ public class _Player_Stub extends Stub implements Player { return (Serializable) obj; } -}
\ No newline at end of file +} diff --git a/libjava/classpath/examples/gnu/classpath/examples/awt/AicasGraphicsBenchmark.java b/libjava/classpath/examples/gnu/classpath/examples/awt/AicasGraphicsBenchmark.java index 5bb4ec4..20cd592 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/awt/AicasGraphicsBenchmark.java +++ b/libjava/classpath/examples/gnu/classpath/examples/awt/AicasGraphicsBenchmark.java @@ -82,8 +82,8 @@ public class AicasGraphicsBenchmark extends Panel ; int iterations = 1; - private int screenWidth = DEFAULT_SCREEN_WIDTH; - private int screenHeight = DEFAULT_SCREEN_HEIGHT; + private int screenWidth = DEFAULT_SCREEN_WIDTH; + private int screenHeight = DEFAULT_SCREEN_HEIGHT; boolean doubleBufferFlag = true; private int awtTests = AWTTEST_ALL; @@ -693,7 +693,7 @@ public class AicasGraphicsBenchmark extends Panel "Skipping 'test_drawImage' due to missing resource."); return; } - + int maxTests = DEFAULT_TEST_SIZE / 2; if(maxTests == 0) maxTests = 1; @@ -726,7 +726,7 @@ public class AicasGraphicsBenchmark extends Panel return; } - + int maxTests = DEFAULT_TEST_SIZE / 5; if(maxTests == 0) maxTests = 1; @@ -757,7 +757,7 @@ public class AicasGraphicsBenchmark extends Panel String testString = "HelloWorld"; int stringWidth = g.getFontMetrics().stringWidth(testString); int stringHeight = g.getFontMetrics().getHeight(); - + long startTime = System.currentTimeMillis(); for(int i = 0; i < maxTests; i += 1) { diff --git a/libjava/classpath/examples/gnu/classpath/examples/awt/Demo.java b/libjava/classpath/examples/gnu/classpath/examples/awt/Demo.java index bd5e755..62bee8f 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/awt/Demo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/awt/Demo.java @@ -92,16 +92,16 @@ class Demo MainWindow f = new MainWindow(); f.show(); } - + static interface SubWindow { public void init (); } - + static class PrettyPanel extends Panel { Insets myInsets; - + public PrettyPanel () { myInsets = new Insets (10, 10, 10, 10); @@ -111,7 +111,7 @@ class Demo return myInsets; } } - + static abstract class PrettyFrame extends Frame { public PrettyFrame () @@ -119,46 +119,46 @@ class Demo ((BorderLayout) getLayout ()).setHgap (5); ((BorderLayout) getLayout ()).setVgap (5); } - + public Insets getInsets() { Insets oldInsets = super.getInsets (); return new Insets (oldInsets.top+10, - oldInsets.left+10, - oldInsets.bottom+10, - oldInsets.right+10); + oldInsets.left+10, + oldInsets.bottom+10, + oldInsets.right+10); } } static abstract class SubFrame extends PrettyFrame implements SubWindow { boolean initted = false; - + public void setVisible (boolean visible) { if (!initted && visible) - init(); + init(); super.setVisible (visible); - } + } } - static class MainWindow extends PrettyFrame implements ActionListener + static class MainWindow extends PrettyFrame implements ActionListener { Button closeButton; - + Hashtable windows; Vector buttons; - + void addSubWindow (String name, SubWindow w) { Button b = new Button (name); b.addActionListener (this); - + buttons.addElement (b); - windows.put (b, w); + windows.put (b, w); } - - MainWindow () + + MainWindow () { MenuBar mb = new MenuBar (); Menu menu = new Menu ("File"); @@ -188,20 +188,20 @@ class Demo helpMenu.add(new MenuItem("About")); mb.add(helpMenu); mb.setHelpMenu(helpMenu); - + setMenuBar (mb); - + String version = System.getProperty("gnu.classpath.version"); add (new Label ("GNU Classpath " + version), "North"); - + closeButton = new Button ("Close"); closeButton.addActionListener (this); closeButton.setFont (new Font ("Serif", Font.BOLD | Font.ITALIC, 18)); add (closeButton, "South"); - + windows = new Hashtable (); buttons = new Vector (); - + addSubWindow ("Buttons", new ButtonsWindow ()); addSubWindow ("Cursors", new CursorsWindow ()); addSubWindow ("Dialog", new DialogWindow (this)); @@ -220,62 +220,62 @@ class Demo Panel sp = new Panel(); PrettyPanel p = new PrettyPanel(); p.setLayout (new GridLayout (windows.size(), 1)); - + for (Enumeration e = buttons.elements (); e.hasMoreElements (); ) - { - p.add ((Button) e.nextElement ()); - } - + { + p.add ((Button) e.nextElement ()); + } + sp.add (p); add (sp, "Center"); - + setTitle ("AWT Demo"); pack(); } - + public void actionPerformed (ActionEvent evt) { Button source = (Button) evt.getSource (); - + if (source==closeButton) - { - dispose(); - System.exit (0); - } - + { + dispose(); + System.exit (0); + } + Window w = (Window) windows.get (source); if (w.isVisible ()) - w.dispose (); - else - { - if (w instanceof Dialog) - { - w.show(); - } - else - { - w.setVisible (true); - } - } + w.dispose (); + else + { + if (w instanceof Dialog) + { + w.show(); + } + else + { + w.setVisible (true); + } + } } } - + static class ButtonsWindow extends SubFrame implements ActionListener { Button b[] = new Button [9]; - + public void init () { initted = true; Panel p = new Panel (); p.setLayout (new GridLayout (0, 3, 5, 5)); - - for (int i=0; i<9; i++) - { - b[i]=new Button ("button" + (i+1)); - b[i].addActionListener (this); - } - + + for (int i=0; i<9; i++) + { + b[i]=new Button ("button" + (i+1)); + b[i].addActionListener (this); + } + p.add (b[0]); p.add (b[6]); p.add (b[4]); @@ -285,135 +285,135 @@ class Demo p.add (b[3]); p.add (b[5]); p.add (b[2]); - + add (p, "North"); - + Button cb = new Button ("close"); cb.addActionListener(new ActionListener () { - public void actionPerformed (ActionEvent e) { - dispose(); - } - }); + public void actionPerformed (ActionEvent e) { + dispose(); + } + }); add (cb, "South"); setTitle ("Buttons"); pack(); } - + public void actionPerformed (ActionEvent evt) { Button source = (Button) evt.getSource (); - + for (int i = 0; i < 9; i++) - { - if (source == b[i]) - { - int i2 = ((i + 1) == 9) ? 0 : (i + 1); - if (b[i2].isVisible()) - b[i2].setVisible(false); - else - b[i2].setVisible(true); - } - } + { + if (source == b[i]) + { + int i2 = ((i + 1) == 9) ? 0 : (i + 1); + if (b[i2].isVisible()) + b[i2].setVisible(false); + else + b[i2].setVisible(true); + } + } } } - - + + static class DialogWindow extends Dialog implements SubWindow { Label text; Frame parent; boolean initted = false; - + public DialogWindow (Frame f) { super (f, true); - + this.parent = f; - + addWindowListener (new WindowAdapter () - { - public void windowClosing (WindowEvent e) - { - text.setVisible (false); - hide (); - } - }); + { + public void windowClosing (WindowEvent e) + { + text.setVisible (false); + hide (); + } + }); } - + public void setVisible (boolean visible) { if (!initted && visible) - init(); + init(); super.setVisible (visible); } - + public void show () { if (!initted) - init(); + init(); super.show (); } - + public void init () { text = new Label ("Dialog Test"); text.setAlignment (Label.CENTER); - + add (text, "North"); text.setVisible (false); - + Panel p = new PrettyPanel(); - + Button cb = new Button ("OK"); cb.addActionListener(new ActionListener () { - public void actionPerformed (ActionEvent e) - { - text.setVisible (false); - hide(); - } - }); - + public void actionPerformed (ActionEvent e) + { + text.setVisible (false); + hide(); + } + }); + p.setLayout (new GridLayout (1, 3)); ((GridLayout) p.getLayout ()).setHgap (5); ((GridLayout) p.getLayout ()).setVgap (5); p.add (cb); - + Button toggle = new Button ("Toggle"); p.add (toggle); - + toggle.addActionListener(new ActionListener () { - public void actionPerformed (ActionEvent e) - { - if (text.isVisible ()) - text.setVisible (false); - else - text.setVisible (true); - doLayout(); - } - }); - + public void actionPerformed (ActionEvent e) + { + if (text.isVisible ()) + text.setVisible (false); + else + text.setVisible (true); + doLayout(); + } + }); + Button subdlg = new Button ("SubDialog"); p.add (subdlg); - + subdlg.addActionListener(new ActionListener () { - public void actionPerformed (ActionEvent e) - { + public void actionPerformed (ActionEvent e) + { DialogWindow sw = new DialogWindow (parent); sw.show (); - } - }); - + } + }); + add (p, "South"); setTitle ("Dialog"); pack(); } } - + static class CursorsWindow extends SubFrame implements ItemListener { Choice cursorChoice; Canvas cursorCanvas; - + public void init () { cursorChoice = new Choice(); @@ -431,253 +431,253 @@ class Demo cursorChoice.add ("East Resize"); cursorChoice.add ("Hand"); cursorChoice.add ("Move"); - + cursorChoice.addItemListener(this); - + add (cursorChoice, "North"); - - cursorCanvas = new Canvas () - { - public void paint (Graphics g) - { - Dimension d = this.getSize(); - g.setColor(Color.white); - g.fillRect(0, 0, d.width, d.height/2); - g.setColor(Color.black); - g.fillRect(0, d.height/2, d.width, d.height/2); - g.setColor(this.getBackground()); - g.fillRect(d.width/3, d.height/3, d.width/3, - d.height/3); - } - }; - + + cursorCanvas = new Canvas () + { + public void paint (Graphics g) + { + Dimension d = this.getSize(); + g.setColor(Color.white); + g.fillRect(0, 0, d.width, d.height/2); + g.setColor(Color.black); + g.fillRect(0, d.height/2, d.width, d.height/2); + g.setColor(this.getBackground()); + g.fillRect(d.width/3, d.height/3, d.width/3, + d.height/3); + } + }; + cursorCanvas.setSize (80,80); - + add (cursorCanvas, "Center"); - + Button cb = new Button ("Close"); cb.addActionListener(new ActionListener () { - public void actionPerformed (ActionEvent e) { - dispose(); - } - }); - + public void actionPerformed (ActionEvent e) { + dispose(); + } + }); + add (cb, "South"); setTitle ("Cursors"); pack(); } - + public void itemStateChanged (ItemEvent e) { int index = cursorChoice.getSelectedIndex(); cursorCanvas.setCursor(Cursor.getPredefinedCursor(index)); } } - + static class TextFieldWindow extends SubFrame implements ItemListener { Checkbox editable, visible, sensitive; TextField text; - + public void init () { initted = true; text = new TextField ("hello world"); add (text, "North"); - + Panel p = new Panel(); p.setLayout (new GridLayout (3, 1)); ((GridLayout) p.getLayout ()).setHgap (5); ((GridLayout) p.getLayout ()).setVgap (5); - + editable = new Checkbox("Editable", true); p.add (editable); editable.addItemListener (this); - + visible = new Checkbox("Visible", true); p.add (visible); visible.addItemListener (this); - + sensitive = new Checkbox("Sensitive", true); p.add (sensitive); sensitive.addItemListener (this); - + add (p, "Center"); - + Button cb = new Button ("Close"); cb.addActionListener(new ActionListener () { - public void actionPerformed (ActionEvent e) { - dispose(); - } - }); - + public void actionPerformed (ActionEvent e) { + dispose(); + } + }); + add (cb, "South"); setTitle ("TextField"); pack(); } - + public void itemStateChanged (ItemEvent e) { boolean on=true; - + if (e.getStateChange () == ItemEvent.DESELECTED) - on=false; + on=false; if (e.getSource() == editable) - text.setEditable (on); + text.setEditable (on); if (e.getSource() == visible) - if (on) - text.setEchoChar ((char) 0); - else - text.setEchoChar ('*'); + if (on) + text.setEchoChar ((char) 0); + else + text.setEchoChar ('*'); if (e.getSource() == sensitive) - text.setEnabled (on); - + text.setEnabled (on); + } } - + static class FileWindow extends FileDialog implements SubWindow { boolean initted = false; - + public FileWindow (MainWindow mw) { super (mw); } - + public void setVisible (boolean visible) { if (!initted && visible) - init(); + init(); super.setVisible (visible); } - - public void init() + + public void init() { initted = true; } } - + static class LabelWindow extends SubFrame { public void init () { initted = true; - + Panel p = new Panel(); p.setLayout (new GridLayout (3, 1)); ((GridLayout) p.getLayout ()).setHgap (5); ((GridLayout) p.getLayout ()).setVgap (5); - + p.add (new Label ("left justified label", Label.LEFT)); p.add (new Label ("center justified label", Label.CENTER)); p.add (new Label ("right justified label", Label.RIGHT)); - + add (p, "Center"); - + Button cb = new Button ("Close"); cb.addActionListener(new ActionListener () { - public void actionPerformed (ActionEvent e) { - dispose(); - } - }); - + public void actionPerformed (ActionEvent e) { + dispose(); + } + }); + add (cb, "South"); setTitle ("Labels"); pack(); } } - + static class ListWindow extends SubFrame { public void init () { initted = true; - + Panel p = new Panel (); p.setLayout (new GridLayout (3, 1)); - + List l = new List (5, true); for (int i = 0; i < 10; i++) - l.add ("List item " + i); + l.add ("List item " + i); p.add (l); add (p, "Center"); - + Button cb = new Button ("Close"); cb.addActionListener(new ActionListener () { - public void actionPerformed (ActionEvent e) { - dispose(); - } - }); - + public void actionPerformed (ActionEvent e) { + dispose(); + } + }); + add (cb, "South"); setTitle ("List"); pack(); } - } - - + } + + static class RadioWindow extends SubFrame { public void init () { initted = true; - + Panel p = new Panel(); p.setLayout (new GridLayout (3, 1)); ((GridLayout) p.getLayout ()).setHgap (5); ((GridLayout) p.getLayout ()).setVgap (5); - + final CheckboxGroup cg = new CheckboxGroup(); final Checkbox[] boxes = new Checkbox[3]; for (int i = 0; i < 3; ++i) - { - boxes[i] = new Checkbox("button" + i, cg, i == 0); - p.add(boxes[i]); - } - + { + boxes[i] = new Checkbox("button" + i, cg, i == 0); + p.add(boxes[i]); + } + add (p, "North"); - + p = new Panel(); p.setLayout (new GridLayout (1, 3)); ((GridLayout) p.getLayout ()).setHgap (5); ((GridLayout) p.getLayout ()).setVgap (5); - + for (int i = 0; i < 3; ++i) - { - final int val = i; - Button tweak = new Button ("Set " + i); - tweak.addActionListener(new ActionListener () - { - public void actionPerformed (ActionEvent e) - { - cg.setSelectedCheckbox(boxes[val]); - } - }); - p.add(tweak); - } - + { + final int val = i; + Button tweak = new Button ("Set " + i); + tweak.addActionListener(new ActionListener () + { + public void actionPerformed (ActionEvent e) + { + cg.setSelectedCheckbox(boxes[val]); + } + }); + p.add(tweak); + } + add (p, "Center"); - + Button cb = new Button ("Close"); cb.addActionListener(new ActionListener () { - public void actionPerformed (ActionEvent e) { - dispose(); - } - }); - + public void actionPerformed (ActionEvent e) { + dispose(); + } + }); + add (cb, "South"); setTitle ("Radio Buttons"); pack(); } } - + static class TestWindow extends SubFrame { static int xs = 5, ys = 5; final Frame parent; - + public TestWindow(Frame f) { parent = f; @@ -686,7 +686,7 @@ class Demo public void init() { initted = true; - + addWindowListener (new WindowAdapter () { public void windowClosing (WindowEvent e) @@ -696,37 +696,37 @@ class Demo }); Panel pan = new Panel(); - + final Label l = new Label ("Pithy Message:"); l.setCursor (Cursor.getPredefinedCursor (Cursor.WAIT_CURSOR)); pan.add (l); - + TextField tf = new TextField("Hello world!"); pan.add(tf); add(pan,"North"); - + final Image img; URL imageurl; imageurl = this.getClass() - .getResource("/gnu/classpath/examples/icons/big-warning.png"); + .getResource("/gnu/classpath/examples/icons/big-warning.png"); img = Toolkit.getDefaultToolkit().createImage(imageurl); final Canvas ch = new Canvas() - { - public void paint (Graphics g) - { - g.drawImage(img, xs + 25, ys + 25, this); - - Font font = new Font ("Serif", Font.PLAIN, 18); - g.setFont (font); - g.setXORMode (Color.red); - - g.drawString("Hi Red!", xs + 15, ys + 10); - g.setColor (Color.blue); - g.drawLine (xs, ys, xs + 100, ys + 100); - - } - }; + { + public void paint (Graphics g) + { + g.drawImage(img, xs + 25, ys + 25, this); + + Font font = new Font ("Serif", Font.PLAIN, 18); + g.setFont (font); + g.setXORMode (Color.red); + + g.drawString("Hi Red!", xs + 15, ys + 10); + g.setColor (Color.blue); + g.drawLine (xs, ys, xs + 100, ys + 100); + + } + }; ch.setSize(150, 150); add(ch, "Center"); @@ -755,70 +755,70 @@ class Demo final Button wb = new Button(); wb.setLabel("Hello World!"); wb.addActionListener(new ActionListener() - { - public void actionPerformed (ActionEvent e) - { - l.setText ("Hello World!"); - - final Dialog d = new Dialog(parent); - d.setLayout(new FlowLayout()); - d.setModal(true); - Button b = new Button("foobar"); - b.addMouseListener(new MouseAdapter() - { - public void mousePressed (MouseEvent me) - { - d.hide (); - } - }); - d.add (b); - - List ch = new List(); - ch.add("Ding"); - ch.add("September"); - ch.add("Red"); - ch.add("Quassia"); - ch.add("Pterodactyl"); - d.add(ch); - - d.pack (); - d.show (); - } - }); + { + public void actionPerformed (ActionEvent e) + { + l.setText ("Hello World!"); + + final Dialog d = new Dialog(parent); + d.setLayout(new FlowLayout()); + d.setModal(true); + Button b = new Button("foobar"); + b.addMouseListener(new MouseAdapter() + { + public void mousePressed (MouseEvent me) + { + d.hide (); + } + }); + d.add (b); + + List ch = new List(); + ch.add("Ding"); + ch.add("September"); + ch.add("Red"); + ch.add("Quassia"); + ch.add("Pterodactyl"); + d.add(ch); + + d.pack (); + d.show (); + } + }); wb.addMouseListener(new MouseAdapter() - { - public void mousePressed(MouseEvent e) { - xs++; - ys++; - ch.repaint (); - } - }); - + { + public void mousePressed(MouseEvent e) { + xs++; + ys++; + ch.repaint (); + } + }); + add(wb,"West"); - + pack(); show(); - + sp.setScrollPosition (10,0); - + Toolkit t = Toolkit.getDefaultToolkit(); t.beep(); } } - + static class ResolutionWindow extends SubFrame { GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); - + public void init () { initted = true; - + setTitle("Change Screen Resolution"); final List list = new List(); DisplayMode[] modes = gd.getDisplayModes(); - + for (int i=0;i<modes.length;i++ ) list.add(modes[i].getWidth() + "x" + modes[i].getHeight() @@ -828,7 +828,7 @@ class Demo + ((modes[i].getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN) ? "@" + modes[i].getRefreshRate() + "Hz" : "")); - + ActionListener al = new ActionListener() { public void actionPerformed(ActionEvent ae) @@ -837,24 +837,24 @@ class Demo gd.setDisplayMode(gd.getDisplayModes()[i]); } }; - + Button b = new Button("Switch"); Button c = new Button("Close"); - + list.addActionListener(al); b.addActionListener(al); - + c.addActionListener(new ActionListener () { public void actionPerformed (ActionEvent e) { dispose(); } }); - + setLayout(new GridLayout(3, 1, 5, 5)); add(list); add(b); add(c); - + pack(); } } @@ -993,15 +993,15 @@ class Demo } } } - + static class FullscreenWindow extends SubFrame { GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); - + public void init () { initted = true; - + setTitle("Fullscreen Exclusive Mode"); ActionListener al = new ActionListener() @@ -1014,23 +1014,23 @@ class Demo gd.setFullScreenWindow(FullscreenWindow.this); } }; - + Button b = new Button("Toggle Fullscreen"); Button c = new Button("Close"); - + b.addActionListener(al); - + c.addActionListener(new ActionListener () { public void actionPerformed (ActionEvent e) { gd.setFullScreenWindow(null); dispose(); } }); - + setLayout(new GridLayout(3, 1, 5, 5)); add(b); add(c); - + pack(); } } @@ -1054,104 +1054,104 @@ class Demo pack(); } - static class DrawRoundRect extends Panel - { - - public Dimension getPreferredSize() - { - return new Dimension(500, 500); - } - - public void paint( Graphics g ) - { - // left side - - // rectangles should be identical - g.setColor(Color.red); - g.drawRect(50, 50, 300, 100); - g.setColor(Color.black); - g.drawRoundRect(50, 50, 300, 100, 0, 0); - - // small round corners - g.setColor(Color.red); - g.drawRect(50, 200, 300, 100); - g.setColor(Color.black); - g.drawRoundRect(50, 200, 300, 100, 25, 25); - - // round ends - g.setColor(Color.red); - g.drawRect(50, 350, 300, 100); - g.setColor(Color.black); - g.drawRoundRect(50, 350, 300, 100, 25, 100); - - // right side - - // circle only - g.setColor(Color.blue); - g.drawOval(375, 50, 100, 100); - - // round rectangle should exactly cover circle - g.setColor(Color.blue); - g.drawOval(375, 200, 100, 100); - g.setColor(Color.black); - g.drawRoundRect(375, 200, 100, 100, 100, 100); - - // round rectangle should look like a circle - g.setColor(Color.red); - g.drawRect(375, 350, 100, 100); - g.setColor(Color.black); - g.drawRoundRect(375, 350, 100, 100, 100, 100); - } + static class DrawRoundRect extends Panel + { + + public Dimension getPreferredSize() + { + return new Dimension(500, 500); + } + + public void paint( Graphics g ) + { + // left side + + // rectangles should be identical + g.setColor(Color.red); + g.drawRect(50, 50, 300, 100); + g.setColor(Color.black); + g.drawRoundRect(50, 50, 300, 100, 0, 0); + + // small round corners + g.setColor(Color.red); + g.drawRect(50, 200, 300, 100); + g.setColor(Color.black); + g.drawRoundRect(50, 200, 300, 100, 25, 25); + + // round ends + g.setColor(Color.red); + g.drawRect(50, 350, 300, 100); + g.setColor(Color.black); + g.drawRoundRect(50, 350, 300, 100, 25, 100); + + // right side + + // circle only + g.setColor(Color.blue); + g.drawOval(375, 50, 100, 100); + + // round rectangle should exactly cover circle + g.setColor(Color.blue); + g.drawOval(375, 200, 100, 100); + g.setColor(Color.black); + g.drawRoundRect(375, 200, 100, 100, 100, 100); + + // round rectangle should look like a circle + g.setColor(Color.red); + g.drawRect(375, 350, 100, 100); + g.setColor(Color.black); + g.drawRoundRect(375, 350, 100, 100, 100, 100); + } } - static class FillRoundRect extends Panel - { - - public Dimension getPreferredSize() - { - return new Dimension(500, 500); - } - - public void paint( Graphics g ) - { - // left side - - // rectangles should be identical - g.setColor(Color.red); - g.fillRect(50, 50, 300, 100); - g.setColor(Color.black); - g.fillRoundRect(50, 50, 300, 100, 0, 0); - - // small round corners - g.setColor(Color.red); - g.fillRect(50, 200, 300, 100); - g.setColor(Color.black); - g.fillRoundRect(50, 200, 300, 100, 25, 25); - - // round ends - g.setColor(Color.red); - g.fillRect(50, 350, 300, 100); - g.setColor(Color.black); - g.fillRoundRect(50, 350, 300, 100, 25, 100); - - // right side - - // circle only - g.setColor(Color.blue); - g.fillOval(375, 50, 100, 100); - - // round rectangle should exactly cover circle - g.setColor(Color.blue); - g.fillOval(375, 200, 100, 100); - g.setColor(Color.black); - g.fillRoundRect(375, 200, 100, 100, 100, 100); - - // round rectangle should look like a circle - g.setColor(Color.red); - g.fillRect(375, 350, 100, 100); - g.setColor(Color.black); - g.fillRoundRect(375, 350, 100, 100, 100, 100); - } + static class FillRoundRect extends Panel + { + + public Dimension getPreferredSize() + { + return new Dimension(500, 500); + } + + public void paint( Graphics g ) + { + // left side + + // rectangles should be identical + g.setColor(Color.red); + g.fillRect(50, 50, 300, 100); + g.setColor(Color.black); + g.fillRoundRect(50, 50, 300, 100, 0, 0); + + // small round corners + g.setColor(Color.red); + g.fillRect(50, 200, 300, 100); + g.setColor(Color.black); + g.fillRoundRect(50, 200, 300, 100, 25, 25); + + // round ends + g.setColor(Color.red); + g.fillRect(50, 350, 300, 100); + g.setColor(Color.black); + g.fillRoundRect(50, 350, 300, 100, 25, 100); + + // right side + + // circle only + g.setColor(Color.blue); + g.fillOval(375, 50, 100, 100); + + // round rectangle should exactly cover circle + g.setColor(Color.blue); + g.fillOval(375, 200, 100, 100); + g.setColor(Color.black); + g.fillRoundRect(375, 200, 100, 100, 100, 100); + + // round rectangle should look like a circle + g.setColor(Color.red); + g.fillRect(375, 350, 100, 100); + g.setColor(Color.black); + g.fillRoundRect(375, 350, 100, 100, 100, 100); + } } } @@ -1164,7 +1164,7 @@ class Demo setTitle("Animation"); Button cb = new Button ("Close"); cb.addActionListener(new ActionListener () { - public void actionPerformed (ActionEvent e) + public void actionPerformed (ActionEvent e) { if (a != null) { diff --git a/libjava/classpath/examples/gnu/classpath/examples/awt/HintingDemo.java b/libjava/classpath/examples/gnu/classpath/examples/awt/HintingDemo.java index 99c262b..5ba44f6 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/awt/HintingDemo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/awt/HintingDemo.java @@ -346,7 +346,7 @@ public class HintingDemo extends JFrame { flags &= ~FontDelegate.FLAG_NO_HINT_WEAK_POINTS; else flags |= FontDelegate.FLAG_NO_HINT_WEAK_POINTS; - + refresh(); } diff --git a/libjava/classpath/examples/gnu/classpath/examples/datatransfer/Demo.java b/libjava/classpath/examples/gnu/classpath/examples/datatransfer/Demo.java index 4f789c9..3bf9431 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/datatransfer/Demo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/datatransfer/Demo.java @@ -78,10 +78,10 @@ class Demo interested in. */ addWindowListener(new WindowAdapter () { - public void windowClosing (WindowEvent e) - { - dispose(); - } + public void windowClosing (WindowEvent e) + { + dispose(); + } }); flavors.addItemListener(this); Toolkit t = Toolkit.getDefaultToolkit(); @@ -101,8 +101,8 @@ class Demo Panel textPanel = new Panel(); textPanel.setLayout(new BorderLayout()); text = new TextArea("GNU Everywhere!", - 2, 80, - TextArea.SCROLLBARS_VERTICAL_ONLY); + 2, 80, + TextArea.SCROLLBARS_VERTICAL_ONLY); text.setEditable(false); text.setEnabled(true); Panel textButtons = new Panel(); @@ -167,7 +167,7 @@ class Demo objectPanel.add(objectButtons, BorderLayout.SOUTH); return objectPanel; } - + /** * The Files Panel shows the files from the current working * directory. They can be copied and pasted between other @@ -189,7 +189,7 @@ class Demo filesPanel.add(filesButtons, BorderLayout.SOUTH); return filesPanel; } - + /** * The Flavors Panel shows the different formats (mime-types) that * data on the clipboard is available in. By clicking on a flavor @@ -235,18 +235,18 @@ class Demo String s = flavors.getSelectedItem(); if (s != null) { - try - { - df = new DataFlavor(s); - } - catch (ClassNotFoundException cnfe) - { - cnfe.printStackTrace(); - } + try + { + df = new DataFlavor(s); + } + catch (ClassNotFoundException cnfe) + { + cnfe.printStackTrace(); + } } details.setDataFlavor(df); } - + /** * ActionListener implementations that will copy or past data * to/from the clipboard when the user requests that for the text, @@ -262,24 +262,24 @@ class Demo if (b == pasteText) { - String s = null; - try - { - s = (String) c.getData(DataFlavor.stringFlavor); - } - catch (UnsupportedFlavorException dfnse) - { - } - catch (IOException ioe) - { - } - catch (ClassCastException cce) - { - } - if (s == null) - t.beep(); - else - text.setText(s); + String s = null; + try + { + s = (String) c.getData(DataFlavor.stringFlavor); + } + catch (UnsupportedFlavorException dfnse) + { + } + catch (IOException ioe) + { + } + catch (ClassCastException cce) + { + } + if (s == null) + t.beep(); + else + text.setText(s); } if (b == copyImage) @@ -287,24 +287,24 @@ class Demo if (b == pasteImage) { - Image i = null; - try - { - i = (Image) c.getData(DataFlavor.imageFlavor); - } - catch (UnsupportedFlavorException dfnse) - { - } - catch (IOException ioe) - { - } - catch (ClassCastException cce) - { - } - if (i == null) - t.beep(); - else - image.setImage(i); + Image i = null; + try + { + i = (Image) c.getData(DataFlavor.imageFlavor); + } + catch (UnsupportedFlavorException dfnse) + { + } + catch (IOException ioe) + { + } + catch (ClassCastException cce) + { + } + if (i == null) + t.beep(); + else + image.setImage(i); } if (b == copyObject) @@ -312,24 +312,24 @@ class Demo if (b == pasteObject) { - Serializable o = null; - try - { - o = (Serializable) c.getData(ObjectSelection.objFlavor); - } - catch (UnsupportedFlavorException dfnse) - { - } - catch (IOException ioe) - { - } - catch (ClassCastException cce) - { - } - if (o == null) - t.beep(); - else - object.setObject(o); + Serializable o = null; + try + { + o = (Serializable) c.getData(ObjectSelection.objFlavor); + } + catch (UnsupportedFlavorException dfnse) + { + } + catch (IOException ioe) + { + } + catch (ClassCastException cce) + { + } + if (o == null) + t.beep(); + else + object.setObject(o); } if (b == copyFiles) @@ -337,24 +337,24 @@ class Demo if (b == pasteFiles) { - java.util.List fs = null; - try - { - fs = (java.util.List) c.getData(DataFlavor.javaFileListFlavor); - } - catch (UnsupportedFlavorException dfnse) - { - } - catch (IOException ioe) - { - } - catch (ClassCastException cce) - { - } - if (fs == null) - t.beep(); - else - files.setFiles(fs); + java.util.List fs = null; + try + { + fs = (java.util.List) c.getData(DataFlavor.javaFileListFlavor); + } + catch (UnsupportedFlavorException dfnse) + { + } + catch (IOException ioe) + { + } + catch (ClassCastException cce) + { + } + if (fs == null) + t.beep(); + else + files.setFiles(fs); } } @@ -412,8 +412,8 @@ class Demo { this.object = object; setText("Class: " + object.getClass().getName() - + "\n" - + "toString(): " + object.toString()); + + "\n" + + "toString(): " + object.toString()); repaint(); } } @@ -424,44 +424,44 @@ class Demo static class FilesComponent extends List { private File[] files; - + FilesComponent(File[] files) { super(4, true); setFiles(files); } - + File[] getFiles() { String[] strings = getSelectedItems(); if (strings == null || strings.length == 0) - return (File[]) files.clone(); - + return (File[]) files.clone(); + File[] fs = new File[strings.length]; for (int i = 0; i < strings.length; i++) - fs[i] = new File(strings[i]); + fs[i] = new File(strings[i]); return fs; } - + void setFiles(File[] files) { this.files = files; removeAll(); for (int i = 0; i < files.length; i++) { - addItem(files[i].toString()); - select(i); + addItem(files[i].toString()); + select(i); } } - + void setFiles(java.util.List list) { File[] fs = new File[list.size()]; int i = 0; Iterator it = list.iterator(); while (it.hasNext()) - fs[i++] = (File) it.next(); - + fs[i++] = (File) it.next(); + setFiles(fs); } } @@ -481,9 +481,9 @@ class Demo { removeAll(); for (int i = 0; i < flavors.length; i++) - { - addItem(flavors[i].getMimeType()); - } + { + addItem(flavors[i].getMimeType()); + } } } @@ -507,40 +507,40 @@ class Demo void setDataFlavor(DataFlavor df) { if (df == this.df - || (df != null && df.equals(this.df))) - return; + || (df != null && df.equals(this.df))) + return; this.df = df; if (df == null) - setText("No flavor selected"); + setText("No flavor selected"); else - { - Object o = null; - Throwable exception = null; - try - { - Toolkit t = Toolkit.getDefaultToolkit(); - Clipboard c = t.getSystemClipboard(); - o = c.getData(df); - } - catch (Throwable t) - { - exception = t; - } - if (o != null) - { - setText("Data: " + o.getClass().getName() - + "\n" - + o); - } - else - { - setText("Error retrieving: " + df - + "\n" - + exception != null ? exception.toString() : ""); - } - } + { + Object o = null; + Throwable exception = null; + try + { + Toolkit t = Toolkit.getDefaultToolkit(); + Clipboard c = t.getSystemClipboard(); + o = c.getData(df); + } + catch (Throwable t) + { + exception = t; + } + if (o != null) + { + setText("Data: " + o.getClass().getName() + + "\n" + + o); + } + else + { + setText("Error retrieving: " + df + + "\n" + + exception != null ? exception.toString() : ""); + } + } repaint(); } } @@ -573,7 +573,7 @@ class Demo throws UnsupportedFlavorException { if (!isDataFlavorSupported(flavor)) - throw new UnsupportedFlavorException(flavor); + throw new UnsupportedFlavorException(flavor); return img; } @@ -593,7 +593,7 @@ class Demo } static DataFlavor objFlavor = new DataFlavor(Serializable.class, - "Serialized Object"); + "Serialized Object"); static DataFlavor[] flavors = new DataFlavor[] { objFlavor }; public DataFlavor[] getTransferDataFlavors() { @@ -609,7 +609,7 @@ class Demo throws UnsupportedFlavorException { if (!isDataFlavorSupported(flavor)) - throw new UnsupportedFlavorException(flavor); + throw new UnsupportedFlavorException(flavor); return obj; } @@ -644,7 +644,7 @@ class Demo throws UnsupportedFlavorException { if (!isDataFlavorSupported(flavor)) - throw new UnsupportedFlavorException(flavor); + throw new UnsupportedFlavorException(flavor); return Arrays.asList(files); } diff --git a/libjava/classpath/examples/gnu/classpath/examples/html/Demo.java b/libjava/classpath/examples/gnu/classpath/examples/html/Demo.java index 3d77b12..0a3c512 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/html/Demo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/html/Demo.java @@ -1,4 +1,4 @@ -/* Demo.java -- +/* Demo.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -60,8 +60,8 @@ public class Demo /** * The sample HTML to parse. */ - static String input = "<!--2-->a<b iD=1>x</b>y<b><i>c</b>d</i>e"; - + static String input = "<!--2-->a<b iD=1>x</b>y<b><i>c</b>d</i>e"; + public static void main(String[] args) { try @@ -69,10 +69,10 @@ public class Demo // Create a parser, using our DTD. DomHTMLParser p = new DomHTMLParser(HTML_401F.getInstance()); HTMLDocument d = p.parseDocument(new StringReader(input)); - + // Print the input HTML. System.out.println(input); - + // Print the parsed data structure. print(System.out, d, 0); } @@ -84,7 +84,7 @@ public class Demo /** * Print the parsed data structure. - * + * * @param stream the output * @param node the node * @param ident the identation diff --git a/libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmark.java b/libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmark.java index a0b51f0..4f6b9f4 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmark.java +++ b/libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmark.java @@ -594,7 +594,7 @@ public class J2dBenchmark /** * Executes the test methods. - * + * * @param g The Graphics2D object that is used to paint. * @param size The size of the canvas. */ @@ -658,7 +658,7 @@ public class J2dBenchmark /** * Reset all graphics settings to the standard, default values - * + * * @param g the object to apply settings to */ private void resetGraphics(Graphics2D g) @@ -670,7 +670,7 @@ public class J2dBenchmark /** * Sets initial user graphics options - * + * * @param g the object to apply settings to */ private void prepareGraphics(Graphics2D g) @@ -712,7 +712,7 @@ public class J2dBenchmark /** * Gets new random settings - * + * * @param g the object to set parameters for * @param size the screen size */ @@ -776,7 +776,7 @@ public class J2dBenchmark /** * Draws random arcs within the given dimensions. - * + * * @param g The Graphics2D object that is used to paint. * @param size The size of the canvas. */ @@ -809,7 +809,7 @@ public class J2dBenchmark /** * Draws random filled arcs within the given dimensions. - * + * * @param g The Graphics2D object that is used to paint. * @param size The size of the canvas. */ @@ -842,7 +842,7 @@ public class J2dBenchmark /** * Draws random cubic curves within the given dimensions. - * + * * @param g The Graphics2D object that is used to paint. * @param size The size of the canvas. */ @@ -874,7 +874,7 @@ public class J2dBenchmark /** * Draws random ellipses within the given dimensions. - * + * * @param g The Graphics2D object that is used to paint. * @param size The size of the canvas. */ @@ -900,7 +900,7 @@ public class J2dBenchmark /** * Draws random ellipses within the given dimensions. - * + * * @param g The Graphics2D object that is used to paint. * @param size The size of the canvas. */ @@ -927,7 +927,7 @@ public class J2dBenchmark // TODO: fix the GeneralPath methods. /** * Draws random polygons within the given dimensions. - * + * * @param g The Graphics2D object that is used to paint. * @param size The size of the canvas. */ @@ -957,7 +957,7 @@ public class J2dBenchmark /** * Draws random filled polygons within the given dimensions. - * + * * @param g The Graphics2D object that is used to paint. * @param size The size of the canvas. */ @@ -988,7 +988,7 @@ public class J2dBenchmark /** * Draws random lines within the given dimensions. - * + * * @param g The Graphics2D object that is used to paint. * @param size The size of the canvas. */ @@ -1014,7 +1014,7 @@ public class J2dBenchmark /** * Draws random quadratic curves within the given dimensions. - * + * * @param g The Graphics2D object that is used to paint. * @param size The size of the canvas. */ @@ -1043,7 +1043,7 @@ public class J2dBenchmark /** * Draws random rectangles within the given dimensions. - * + * * @param g The Graphics2D object that is used to paint. * @param size The size of the canvas. */ @@ -1069,7 +1069,7 @@ public class J2dBenchmark /** * Draws random rectangles within the given dimensions. - * + * * @param g The Graphics2D object that is used to paint. * @param size The size of the canvas. */ @@ -1095,7 +1095,7 @@ public class J2dBenchmark /** * Draws random rounded rectangles within the given dimensions. - * + * * @param g The Graphics2D object that is used to paint. * @param size The size of the canvas. */ @@ -1128,7 +1128,7 @@ public class J2dBenchmark /** * Draws random filled rounded rectangles within the given dimensions. - * + * * @param g The Graphics2D object that is used to paint. * @param size The size of the canvas. */ @@ -1161,7 +1161,7 @@ public class J2dBenchmark /** * Draws random images within the given dimensions. - * + * * @param g The Graphics2D object that is used to paint. * @param size The size of the canvas. */ @@ -1193,7 +1193,7 @@ public class J2dBenchmark /** * Draws random transparent images within the given dimensions. - * + * * @param g The Graphics object that is used to paint. * @param size The size of the canvas. */ diff --git a/libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmarkGUI.java b/libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmarkGUI.java index bb583cb..ce12fa1 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmarkGUI.java +++ b/libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmarkGUI.java @@ -406,7 +406,7 @@ public class J2dBenchmarkGUI } /** - * Parses GUI input and sets options in the benchmarker + * Parses GUI input and sets options in the benchmarker */ private class Harness implements ActionListener @@ -417,7 +417,7 @@ public class J2dBenchmarkGUI /** * Creates a new Harness object - * + * * @param elements Hashtable containing the swing elements from the GUI * @param errorLabel JLabel on which to display any error messages */ @@ -432,7 +432,7 @@ public class J2dBenchmarkGUI /** * Handles user button-clicks, parsing the form, setting options, and * starting the J2dBenchmark - * + * * @param ae event that triggered this action */ public void actionPerformed(ActionEvent ae) @@ -484,7 +484,7 @@ public class J2dBenchmarkGUI if (((JCheckBox) elements.get("test_ellipseDraw")).isSelected()) testSuite |= J2dBenchmarkWrapper.J2DTEST_ELLIPSE; //if (((JCheckBox)elements.get("test_pathDraw")).isSelected()) - // testSuite |= J2dBenchmarkWrapper.J2DTEST_GENERALPATH; + // testSuite |= J2dBenchmarkWrapper.J2DTEST_GENERALPATH; if (((JCheckBox) elements.get("test_lineDraw")).isSelected()) testSuite |= J2dBenchmarkWrapper.J2DTEST_LINE; if (((JCheckBox) elements.get("test_qcurveDraw")).isSelected()) @@ -546,7 +546,7 @@ public class J2dBenchmarkGUI /** * Create new J2dBenchmarkWrapper object - * + * * @param frame parent frame */ public J2dBenchmarkWrapper(JFrame frame) @@ -562,7 +562,7 @@ public class J2dBenchmarkGUI /** * Set dimensions of benchmarking canvas - * + * * @param width width of canvas * @param height height of canvas */ @@ -575,7 +575,7 @@ public class J2dBenchmarkGUI /** * Set number of iterations - * + * * @param it number of iterations */ public void setIterations(int it) @@ -585,7 +585,7 @@ public class J2dBenchmarkGUI /** * Set size of each test - * + * * @param size size of test */ public void setTestSize(int size) @@ -595,7 +595,7 @@ public class J2dBenchmarkGUI /** * Set clipping options - * + * * @param no run test with no clipping * @param with run test with clipping * @param zero run test with clipping to zero @@ -609,7 +609,7 @@ public class J2dBenchmarkGUI /** * Set buffering options - * + * * @param single run test without double-buffering * @param doubleb run test with double-buffering */ @@ -621,7 +621,7 @@ public class J2dBenchmarkGUI /** * Set fill options - * + * * @param type fill type: "solid", "gradient", or "texture" * @param file filename to use if texturing */ @@ -637,7 +637,7 @@ public class J2dBenchmarkGUI /** * Set stroke options - * + * * @param stroke boolean flag to use random stroking or not */ public void setStroke(boolean stroke) @@ -647,7 +647,7 @@ public class J2dBenchmarkGUI /** * Set anti-aliasing options - * + * * @param alias boolean flag to use anti-aliasing or not */ public void setAlias(boolean alias) @@ -657,7 +657,7 @@ public class J2dBenchmarkGUI /** * Set alpha composite - * + * * @param alpha alpha composite */ public void setComposite(float alpha) @@ -667,7 +667,7 @@ public class J2dBenchmarkGUI /** * Set translation values - * + * * @param x x-axis translation * @param y y-axis translation */ @@ -679,7 +679,7 @@ public class J2dBenchmarkGUI /** * Set rotation - * + * * @param theta angle to rotate by (radians) */ public void setRotation(double theta) @@ -689,7 +689,7 @@ public class J2dBenchmarkGUI /** * Set shear values - * + * * @param x x-axis shear value * @param y-axis shear value */ @@ -701,7 +701,7 @@ public class J2dBenchmarkGUI /** * Set tests to run - * + * * @param tests bit-shifted list of tests (see J2dBenchmark constants) */ public void setTests(int tests) @@ -828,7 +828,7 @@ public class J2dBenchmarkGUI /** * This overrides the logger publish method, which accepts log messages and * saves them for later display - * + * * @param record information about the log event */ public void publish(LogRecord record) @@ -838,7 +838,7 @@ public class J2dBenchmarkGUI /** * Accepts a test summary report, generated after each iteration of a test - * + * * @param results test results */ public void report(ArrayList results) diff --git a/libjava/classpath/examples/gnu/classpath/examples/java2d/JNIOverhead.java b/libjava/classpath/examples/gnu/classpath/examples/java2d/JNIOverhead.java index efa57d2..4999649 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/java2d/JNIOverhead.java +++ b/libjava/classpath/examples/gnu/classpath/examples/java2d/JNIOverhead.java @@ -37,12 +37,12 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingUtilities; -/** +/** * @author Norman Hendrich */ public class JNIOverhead extends JPanel - implements ActionListener + implements ActionListener { static JNIOverhead fillRectDemo; @@ -63,18 +63,18 @@ public class JNIOverhead long lastMillis = System.currentTimeMillis(); boolean enableRepaints = true; - + /** * If true, test translation. */ boolean testTranslation = false; - + /** * If true, paint lines rather than rectangles */ boolean paintLines; - public void actionPerformed(ActionEvent e) + public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("CLOSE")) { @@ -96,7 +96,7 @@ public class JNIOverhead lcd = new LCDCanvas(); label = new JLabel(); label.setText("not running"); - + translate = new JCheckBox("translate"); translate.addActionListener(new ActionListener() { @@ -105,7 +105,7 @@ public class JNIOverhead testTranslation = translate.isSelected(); } }); - + lines = new JCheckBox("lines"); lines.addActionListener(new ActionListener() { @@ -114,11 +114,11 @@ public class JNIOverhead paintLines = lines.isSelected(); } }); - + JPanel bottom = new JPanel(); bottom.add(lines); bottom.add(translate); - + p.add(lcd, BorderLayout.CENTER); p.add(bottom, BorderLayout.SOUTH); p.add(label, BorderLayout.NORTH); @@ -270,7 +270,7 @@ public class JNIOverhead } } - /** + /** * stupid animation algorithm: show binary representation of current * iteration. */ @@ -286,9 +286,9 @@ public class JNIOverhead // count neighbors long tmp2 = (1L << j); - + long tmp3 = generation & tmp1 & tmp2; - if (tmp3 != 0) + if (tmp3 != 0) matrix[i][j] = 1; else matrix[i][j] = 0; @@ -312,7 +312,7 @@ public class JNIOverhead public static void usage() { - System.out.println( + System.out.println( "Usage: <java> FillRect2 [-sleep <millis>] [-size <int>] [-nopaint]\n" + "Example: jamvm FillRect2 -sleep 10 -size 100\n" ); @@ -342,7 +342,7 @@ public class JNIOverhead } if ("-nopaint".equals(args[i])) { - fillRectDemo.enableRepaints = false; + fillRectDemo.enableRepaints = false; } } @@ -368,7 +368,7 @@ public class JNIOverhead * @return a DemoFactory that creates a SliderDemo */ public static DemoFactory createDemoFactory() - { + { return new DemoFactory() { public JComponent createDemo() diff --git a/libjava/classpath/examples/gnu/classpath/examples/jawt/DemoJAWT.java b/libjava/classpath/examples/gnu/classpath/examples/jawt/DemoJAWT.java index ff688964..c8f931e 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/jawt/DemoJAWT.java +++ b/libjava/classpath/examples/gnu/classpath/examples/jawt/DemoJAWT.java @@ -52,10 +52,10 @@ public class DemoJAWT extends Canvas f.addWindowListener (new WindowAdapter () { - public void windowClosing (WindowEvent evt) - { - System.exit (0); - } + public void windowClosing (WindowEvent evt) + { + System.exit (0); + } }); f.show (); @@ -63,13 +63,13 @@ public class DemoJAWT extends Canvas while (true) { try - { - Thread.sleep (500); - } + { + Thread.sleep (500); + } catch (InterruptedException ie) - { - // ignored - } + { + // ignored + } jawtDemo.on = ! jawtDemo.on; f.repaint(); } diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestClassLoading.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestClassLoading.java index b4e8d98..8465510 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/management/TestClassLoading.java +++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestClassLoading.java @@ -51,19 +51,19 @@ public class TestClassLoading System.out.println("Bean: " + classBean); System.out.println("Loaded classes: " + server.getAttribute(classBean, "LoadedClassCount")); System.out.println("Unloaded classes: " + server.getAttribute(classBean, - "UnloadedClassCount")); + "UnloadedClassCount")); System.out.println("Total loaded classes: " + server.getAttribute(classBean, - "TotalLoadedClassCount")); + "TotalLoadedClassCount")); verbosity = (Boolean) server.getAttribute(classBean, "Verbose"); System.out.println("Verbose class output: " + (verbosity ? "yes" : "no")); System.out.println("Changing verbose setting..."); server.setAttribute(classBean, new Attribute("Verbose", !verbosity)); System.out.println("Verbose class output: " + ((Boolean) - server.getAttribute(classBean, "Verbose") ? - "yes" : "no")); + server.getAttribute(classBean, "Verbose") ? + "yes" : "no")); System.out.println("Testing via the proxy..."); bean = ManagementFactory.newPlatformMXBeanProxy(server, CLASS_LOADING_MXBEAN_NAME, - ClassLoadingMXBean.class); + ClassLoadingMXBean.class); System.out.println("Bean: " + bean); System.out.println("Loaded classes: " + bean.getLoadedClassCount()); System.out.println("Unloaded classes: " + bean.getUnloadedClassCount()); diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestCompilation.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestCompilation.java index ea8f45f..b8c4475 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/management/TestCompilation.java +++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestCompilation.java @@ -31,8 +31,8 @@ public class TestCompilation CompilationMXBean bean = ManagementFactory.getCompilationMXBean(); if (bean == null) { - System.out.println("The compilation bean is not supported by this VM."); - System.exit(-1); + System.out.println("The compilation bean is not supported by this VM."); + System.exit(-1); } System.out.println("Bean: " + bean); System.out.println("JIT compiler name: " + bean.getName()); @@ -40,8 +40,8 @@ public class TestCompilation System.out.println("Compilation time monitoring supported: " + timeMonitoring); if (timeMonitoring) { - System.out.println("Compilation time: " - + bean.getTotalCompilationTime() + "ms"); + System.out.println("Compilation time: " + + bean.getTotalCompilationTime() + "ms"); } } diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestGarbageCollector.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestGarbageCollector.java index 5d6d567..ddb22c3 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/management/TestGarbageCollector.java +++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestGarbageCollector.java @@ -34,20 +34,17 @@ public class TestGarbageCollector Iterator beans = ManagementFactory.getGarbageCollectorMXBeans().iterator(); while (beans.hasNext()) { - GarbageCollectorMXBean bean = (GarbageCollectorMXBean) beans.next(); - System.out.println("Bean: " + bean); - System.out.println("Name: " + bean.getName()); - System.out.println("Memory pool names: " - + Arrays.toString(bean.getMemoryPoolNames())); - System.out.println("Is valid: " - + (bean.isValid() ? "yes" : "no")); - System.out.println("Collection count: " - + bean.getCollectionCount()); - System.out.println("Collection time: " - + bean.getCollectionTime() + "ms"); + GarbageCollectorMXBean bean = (GarbageCollectorMXBean) beans.next(); + System.out.println("Bean: " + bean); + System.out.println("Name: " + bean.getName()); + System.out.println("Memory pool names: " + + Arrays.toString(bean.getMemoryPoolNames())); + System.out.println("Is valid: " + + (bean.isValid() ? "yes" : "no")); + System.out.println("Collection count: " + + bean.getCollectionCount()); + System.out.println("Collection time: " + + bean.getCollectionTime() + "ms"); } } } - - - diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestMemory.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestMemory.java index ca25d62..7a5065f 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/management/TestMemory.java +++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestMemory.java @@ -29,20 +29,20 @@ public class TestMemory { MemoryMXBean bean = ManagementFactory.getMemoryMXBean(); System.out.println("Bean: " + bean); - System.out.println("Heap memory usage: " - + bean.getHeapMemoryUsage()); - System.out.println("Non-heap memory usage: " - + bean.getNonHeapMemoryUsage()); - System.out.println("Objects pending finalization: " - + bean.getObjectPendingFinalizationCount()); + System.out.println("Heap memory usage: " + + bean.getHeapMemoryUsage()); + System.out.println("Non-heap memory usage: " + + bean.getNonHeapMemoryUsage()); + System.out.println("Objects pending finalization: " + + bean.getObjectPendingFinalizationCount()); System.out.println("Running garbage collector via bean..."); bean.gc(); - System.out.println("Heap memory usage: " - + bean.getHeapMemoryUsage()); - System.out.println("Non-heap memory usage: " - + bean.getNonHeapMemoryUsage()); - System.out.println("Objects pending finalization: " - + bean.getObjectPendingFinalizationCount()); + System.out.println("Heap memory usage: " + + bean.getHeapMemoryUsage()); + System.out.println("Non-heap memory usage: " + + bean.getNonHeapMemoryUsage()); + System.out.println("Objects pending finalization: " + + bean.getObjectPendingFinalizationCount()); boolean verbosity = bean.isVerbose(); System.out.println("Verbose memory output: " + (verbosity ? "yes" : "no")); System.out.println("Changing verbose setting..."); diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryManager.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryManager.java index 30a0c98..8e98acd 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryManager.java +++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryManager.java @@ -34,16 +34,13 @@ public class TestMemoryManager Iterator beans = ManagementFactory.getMemoryManagerMXBeans().iterator(); while (beans.hasNext()) { - MemoryManagerMXBean bean = (MemoryManagerMXBean) beans.next(); - System.out.println("Bean: " + bean); - System.out.println("Name: " + bean.getName()); - System.out.println("Memory pool names: " - + Arrays.toString(bean.getMemoryPoolNames())); - System.out.println("Is valid: " - + (bean.isValid() ? "yes" : "no")); + MemoryManagerMXBean bean = (MemoryManagerMXBean) beans.next(); + System.out.println("Bean: " + bean); + System.out.println("Name: " + bean.getName()); + System.out.println("Memory pool names: " + + Arrays.toString(bean.getMemoryPoolNames())); + System.out.println("Is valid: " + + (bean.isValid() ? "yes" : "no")); } } } - - - diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryPool.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryPool.java index 1836c30..a5e24fd 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryPool.java +++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryPool.java @@ -38,54 +38,54 @@ public class TestMemoryPool Iterator beans = ManagementFactory.getMemoryPoolMXBeans().iterator(); while (beans.hasNext()) { - MemoryPoolMXBean bean = (MemoryPoolMXBean) beans.next(); - System.out.println("Bean: " + bean); - System.out.println("Name: " + bean.getName()); - System.out.println("Collection usage: " + bean.getCollectionUsage()); - boolean collectionUsage = bean.isCollectionUsageThresholdSupported(); - System.out.println("Collection usage threshold supported: " - + collectionUsage); - if (collectionUsage) - { - System.out.println("Collection usage threshold: " - + bean.getCollectionUsageThreshold()); - System.out.println("Setting collection usage threshold to 1MB (" - + MB + " bytes)"); - bean.setCollectionUsageThreshold(MB); - System.out.println("Collection usage threshold: " - + bean.getCollectionUsageThreshold()); - System.out.println("Collection usage threshold count: " - + bean.getCollectionUsageThresholdCount()); - System.out.println("Collection usage threshold exceeded: " - + (bean.isCollectionUsageThresholdExceeded() - ? "yes" : "no")); - } - System.out.println("Memory manager names: " - + Arrays.toString(bean.getMemoryManagerNames())); - System.out.println("Peak usage: " + bean.getPeakUsage()); - System.out.println("Current usage: " + bean.getUsage()); - System.out.println("Resetting peak usage..."); - bean.resetPeakUsage(); - System.out.println("Peak usage: " + bean.getPeakUsage()); - System.out.println("Current usage: " + bean.getUsage()); - boolean usage = bean.isUsageThresholdSupported(); - System.out.println("Usage threshold supported: " + usage); - if (usage) - { - System.out.println("Usage threshold: " - + bean.getUsageThreshold()); - System.out.println("Setting usage threshold to 1MB (" - + MB + " bytes)"); - bean.setUsageThreshold(MB); - System.out.println("Usage threshold: " - + bean.getUsageThreshold()); - System.out.println("Usage threshold count: " - + bean.getUsageThresholdCount()); - System.out.println("Usage threshold exceeded: " - + (bean.isUsageThresholdExceeded() - ? "yes" : "no")); - } - System.out.println("Valid: " + (bean.isValid() ? "yes" : "no")); + MemoryPoolMXBean bean = (MemoryPoolMXBean) beans.next(); + System.out.println("Bean: " + bean); + System.out.println("Name: " + bean.getName()); + System.out.println("Collection usage: " + bean.getCollectionUsage()); + boolean collectionUsage = bean.isCollectionUsageThresholdSupported(); + System.out.println("Collection usage threshold supported: " + + collectionUsage); + if (collectionUsage) + { + System.out.println("Collection usage threshold: " + + bean.getCollectionUsageThreshold()); + System.out.println("Setting collection usage threshold to 1MB (" + + MB + " bytes)"); + bean.setCollectionUsageThreshold(MB); + System.out.println("Collection usage threshold: " + + bean.getCollectionUsageThreshold()); + System.out.println("Collection usage threshold count: " + + bean.getCollectionUsageThresholdCount()); + System.out.println("Collection usage threshold exceeded: " + + (bean.isCollectionUsageThresholdExceeded() + ? "yes" : "no")); + } + System.out.println("Memory manager names: " + + Arrays.toString(bean.getMemoryManagerNames())); + System.out.println("Peak usage: " + bean.getPeakUsage()); + System.out.println("Current usage: " + bean.getUsage()); + System.out.println("Resetting peak usage..."); + bean.resetPeakUsage(); + System.out.println("Peak usage: " + bean.getPeakUsage()); + System.out.println("Current usage: " + bean.getUsage()); + boolean usage = bean.isUsageThresholdSupported(); + System.out.println("Usage threshold supported: " + usage); + if (usage) + { + System.out.println("Usage threshold: " + + bean.getUsageThreshold()); + System.out.println("Setting usage threshold to 1MB (" + + MB + " bytes)"); + bean.setUsageThreshold(MB); + System.out.println("Usage threshold: " + + bean.getUsageThreshold()); + System.out.println("Usage threshold count: " + + bean.getUsageThresholdCount()); + System.out.println("Usage threshold exceeded: " + + (bean.isUsageThresholdExceeded() + ? "yes" : "no")); + } + System.out.println("Valid: " + (bean.isValid() ? "yes" : "no")); } } } diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestThread.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestThread.java index e49776c..ff57ee5 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/management/TestThread.java +++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestThread.java @@ -40,26 +40,26 @@ public class TestThread System.out.println("Current thread CPU time monitoring supported: " + currentTimeMonitoring); if (currentTimeMonitoring) { - boolean timeEnabled = bean.isThreadCpuTimeEnabled(); - System.out.println("Is time monitoring enabled... " + - (timeEnabled ? "yes" : "no")); - if (!timeEnabled) - { - System.out.println("Enabling..."); - bean.setThreadCpuTimeEnabled(true); - timeEnabled = bean.isThreadCpuTimeEnabled(); - System.out.println("Should now be enabled... " + - (timeEnabled ? "yes" : "no")); - } - if (timeEnabled) - { - System.out.println("Current thread CPU time: " - + bean.getCurrentThreadCpuTime() - + "ns"); - System.out.println("Current thread user time: " - + bean.getCurrentThreadUserTime() - + "ns"); - } + boolean timeEnabled = bean.isThreadCpuTimeEnabled(); + System.out.println("Is time monitoring enabled... " + + (timeEnabled ? "yes" : "no")); + if (!timeEnabled) + { + System.out.println("Enabling..."); + bean.setThreadCpuTimeEnabled(true); + timeEnabled = bean.isThreadCpuTimeEnabled(); + System.out.println("Should now be enabled... " + + (timeEnabled ? "yes" : "no")); + } + if (timeEnabled) + { + System.out.println("Current thread CPU time: " + + bean.getCurrentThreadCpuTime() + + "ns"); + System.out.println("Current thread user time: " + + bean.getCurrentThreadUserTime() + + "ns"); + } } System.out.println("Daemon thread count: " + bean.getDaemonThreadCount()); System.out.println("Peak thread count: " + bean.getPeakThreadCount()); @@ -71,48 +71,48 @@ public class TestThread System.out.println("Thread CPU time monitoring supported: " + timeMonitoring); if (timeMonitoring) { - for (int a = 0; a < ids.length; ++a) - { - System.out.println("Thread " + a - + " CPU time: " - + bean.getThreadCpuTime(ids[a]) + "ns"); - System.out.println("Thread " - + a + " user time: " - + bean.getThreadUserTime(ids[a]) + "ns"); - } + for (int a = 0; a < ids.length; ++a) + { + System.out.println("Thread " + a + + " CPU time: " + + bean.getThreadCpuTime(ids[a]) + "ns"); + System.out.println("Thread " + + a + " user time: " + + bean.getThreadUserTime(ids[a]) + "ns"); + } } System.out.println("Current thread info: " - + bean.getThreadInfo(Thread.currentThread().getId())); + + bean.getThreadInfo(Thread.currentThread().getId())); System.out.println("All thread info: " + Arrays.toString(bean.getThreadInfo(ids))); System.out.println("Total started threads: " + bean.getTotalStartedThreadCount()); boolean contentionMonitoring = bean.isThreadContentionMonitoringSupported(); System.out.println("Thread contention monitoring supported: " + contentionMonitoring); if (contentionMonitoring) { - boolean contentionEnabled = bean.isThreadContentionMonitoringEnabled(); - System.out.println("Thread contention monitoring shouldn't be enabled... " + - (contentionEnabled ? "but it is" : "true")); - if (!contentionEnabled) - { - System.out.println("Enabling..."); - bean.setThreadContentionMonitoringEnabled(true); - contentionEnabled = bean.isThreadContentionMonitoringEnabled(); - System.out.println("Should now be enabled... " + - (contentionEnabled ? "it is" : "nope")); - } - if (contentionEnabled) - { - ThreadInfo[] info = bean.getThreadInfo(ids); - for (int a = 0; a < info.length; ++a) - { - System.out.println("Blocked time for thread " - + info[a].getThreadId() + ": " - + info[a].getBlockedTime() + "ms"); - System.out.println("Waited time for thread " - + info[a].getThreadId() + ": " - + info[a].getWaitedTime() + "ms"); - } - } + boolean contentionEnabled = bean.isThreadContentionMonitoringEnabled(); + System.out.println("Thread contention monitoring shouldn't be enabled... " + + (contentionEnabled ? "but it is" : "true")); + if (!contentionEnabled) + { + System.out.println("Enabling..."); + bean.setThreadContentionMonitoringEnabled(true); + contentionEnabled = bean.isThreadContentionMonitoringEnabled(); + System.out.println("Should now be enabled... " + + (contentionEnabled ? "it is" : "nope")); + } + if (contentionEnabled) + { + ThreadInfo[] info = bean.getThreadInfo(ids); + for (int a = 0; a < info.length; ++a) + { + System.out.println("Blocked time for thread " + + info[a].getThreadId() + ": " + + info[a].getBlockedTime() + "ms"); + System.out.println("Waited time for thread " + + info[a].getThreadId() + ": " + + info[a].getWaitedTime() + "ms"); + } + } } } } diff --git a/libjava/classpath/examples/gnu/classpath/examples/midi/Demo.java b/libjava/classpath/examples/gnu/classpath/examples/midi/Demo.java index 7e403d8..81c71dc 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/midi/Demo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/midi/Demo.java @@ -35,7 +35,7 @@ public class Demo extends Frame implements ItemListener MidiDevice inDevice = null; MidiDevice outDevice = null; - + ArrayList inDevices = new ArrayList(); ArrayList outDevices = new ArrayList(); @@ -46,32 +46,32 @@ public class Demo extends Frame implements ItemListener MenuItem quit = new MenuItem("Quit", new MenuShortcut('Q')); quit.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) - { - System.exit(0); - } + 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); - } + 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); @@ -86,47 +86,47 @@ public class Demo extends Frame implements ItemListener 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); - } + 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(); + ex.printStackTrace(); } } diff --git a/libjava/classpath/examples/gnu/classpath/examples/print/Demo.java b/libjava/classpath/examples/gnu/classpath/examples/print/Demo.java index 0f6a5c8..fb4d743 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/print/Demo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/print/Demo.java @@ -76,12 +76,12 @@ import javax.swing.JTextField; * A simple demo showing the use of the Java Print Service API. * @author Wolfgang Baer (WBaer@gmx.de) */ -public class Demo extends JFrame +public class Demo extends JFrame implements ActionListener { // The discovered print services private static PrintService[] services; - + // variables for the PrintPanel demo private HashPrintRequestAttributeSet atts; private PrintService dialogSelectedService; @@ -90,102 +90,102 @@ public class Demo extends JFrame private JComboBox dialogSelectedServicedocFormat; private JTextField selectedFileTf; private File selectedFile; - + // variables for the PrintServicePanel demo private JComboBox serviceBox; private JList docFormat; private JList attCategories; - + static { // lookup all services without any constraints - services = PrintServiceLookup.lookupPrintServices(null, null); + services = PrintServiceLookup.lookupPrintServices(null, null); } - + /** * Constructs the Print Demo * @param title - the demo title. */ - public Demo(String title) + public Demo(String title) { super(title); JPanel content = new JPanel(new BorderLayout()); - + JTabbedPane tabbed = new JTabbedPane(); tabbed.addTab("Discover print services", createPrintServicePanel()); tabbed.addTab("Print a file", createPrintPanel()); - + JPanel closePanel = new JPanel(); JButton closeButton = new JButton("Close"); closeButton.setActionCommand("CLOSE"); closeButton.addActionListener(this); closePanel.add(closeButton); - + content.add(tabbed, BorderLayout.CENTER); content.add(closePanel, BorderLayout.SOUTH); getContentPane().add(content); } - - private JPanel createPrintServicePanel() - { + + private JPanel createPrintServicePanel() + { JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); - + c.insets = new Insets(5,5,5,5); c.gridx = 0; - c.gridy = 0; + c.gridy = 0; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; JLabel serviceBoxLb = new JLabel("Available print services: "); - panel.add(serviceBoxLb, c); - + panel.add(serviceBoxLb, c); + c.gridx = 1; c.gridy = 0; serviceBox = new JComboBox(services); serviceBox.setActionCommand("SERVICE"); serviceBox.addActionListener(this); - panel.add(serviceBox, c); - + panel.add(serviceBox, c); + c.gridx = 0; c.gridy = 1; JLabel docFormatLb = new JLabel("Supported DocFormat: "); - panel.add(docFormatLb, c); - + panel.add(docFormatLb, c); + c.gridx = 1; c.gridy = 1; docFormat = new JList(services[0].getSupportedDocFlavors()); docFormat.setVisibleRowCount(3); JScrollPane scrollPane = new JScrollPane(docFormat); - panel.add(scrollPane, c); - + panel.add(scrollPane, c); + c.gridx = 0; c.gridy = 2; JLabel categoriesLb = new JLabel("Supported Attribute categories: "); - panel.add(categoriesLb, c); - + panel.add(categoriesLb, c); + c.gridx = 1; c.gridy = 2; attCategories = new JList(services[0].getSupportedAttributeCategories()); attCategories.setVisibleRowCount(3); - JScrollPane scrollPane2 = new JScrollPane(attCategories); - panel.add(scrollPane2, c); - + JScrollPane scrollPane2 = new JScrollPane(attCategories); + panel.add(scrollPane2, c); + return panel; } - - private JPanel createPrintPanel() + + private JPanel createPrintPanel() { - JPanel panel = new JPanel(new GridBagLayout()); + JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); - + c.insets = new Insets(5,5,5,5); c.gridx = 0; c.gridy = 0; - c.gridwidth = 2; + c.gridwidth = 2; JButton serviceBtn = new JButton("Show print dialog ..."); serviceBtn.addActionListener(this); - panel.add(serviceBtn, c); - + panel.add(serviceBtn, c); + c.gridx = 0; c.gridy = 1; c.gridwidth = 1; @@ -193,55 +193,55 @@ public class Demo extends JFrame c.fill = GridBagConstraints.HORIZONTAL; JLabel selectedLb = new JLabel("Selected print service: "); panel.add(selectedLb, c); - + c.gridx = 1; c.gridy = 1; dialogSelectedService_Tf = new JTextField(25); panel.add(dialogSelectedService_Tf, c); - + c.gridx = 0; c.gridy = 2; JLabel selectedAttsLb = new JLabel("Selected Attributes: "); panel.add(selectedAttsLb, c); - + c.gridx = 1; c.gridy = 2; c.weighty = 1.5; c.fill = GridBagConstraints.BOTH; dialogSelectedServiceAtts = new JList(); - dialogSelectedServiceAtts.setVisibleRowCount(3); + dialogSelectedServiceAtts.setVisibleRowCount(3); JScrollPane scrollPane = new JScrollPane(dialogSelectedServiceAtts); panel.add(scrollPane, c); - + c.gridx = 0; c.gridy = 3; c.fill = GridBagConstraints.HORIZONTAL; JLabel fileLb = new JLabel("File to print: "); panel.add(fileLb, c); - + c.gridx = 1; c.gridy = 3; selectedFileTf = new JTextField(25); panel.add(selectedFileTf, c); - + c.gridx = 2; c.gridy = 3; c.fill = GridBagConstraints.NONE; JButton fileBt = new JButton("Choose file"); fileBt.addActionListener(this); panel.add(fileBt, c); - + c.gridx = 0; c.gridy = 4; c.fill = GridBagConstraints.HORIZONTAL; JLabel docFormatLb = new JLabel("Document format of file: "); panel.add(docFormatLb, c); - + c.gridx = 1; c.gridy = 4; dialogSelectedServicedocFormat = new JComboBox(); panel.add(dialogSelectedServicedocFormat, c); - + c.gridx = 0; c.gridy = 5; c.gridwidth = 2; @@ -251,7 +251,7 @@ public class Demo extends JFrame printBt.setActionCommand("PRINT"); printBt.addActionListener(this); panel.add(printBt, c); - + return panel; } @@ -264,14 +264,14 @@ public class Demo extends JFrame if (event.getActionCommand().equals("CLOSE")) { System.exit(0); - } + } else if (event.getActionCommand().equals("Choose file")) { JFileChooser chooser = new JFileChooser(); chooser.showOpenDialog(this); - + selectedFile = chooser.getSelectedFile(); - + if (selectedFile != null) selectedFileTf.setText(selectedFile.getName()); else @@ -279,17 +279,17 @@ public class Demo extends JFrame } else if (event.getActionCommand().equals("Show print dialog ...")) { - atts = new HashPrintRequestAttributeSet(); + atts = new HashPrintRequestAttributeSet(); dialogSelectedService = ServiceUI.printDialog(null, 50, 50, services, null, null, atts); - + if (dialogSelectedService != null) { dialogSelectedService_Tf.setText(dialogSelectedService.getName()); - + // we do not want to have the class representation in the dialog // as we later always use an InputStream to open the file selected - + // use set to remove duplicates DocFlavor[] docflavors = dialogSelectedService.getSupportedDocFlavors(); HashSet set = new HashSet(); @@ -301,8 +301,8 @@ public class Demo extends JFrame mimetype += "; charset=" + charset; set.add(mimetype); } - - dialogSelectedServicedocFormat.removeAllItems(); + + dialogSelectedServicedocFormat.removeAllItems(); for (Iterator it = set.iterator(); it.hasNext(); ) dialogSelectedServicedocFormat.addItem(it.next()); } @@ -314,19 +314,19 @@ public class Demo extends JFrame for (int i = 0; i < attsSTr.length; i++) attsSTr[i] = attsArray[i].getName() + " - " + attsArray[i].toString(); - dialogSelectedServiceAtts.setListData(attsSTr); - - validate(); - } + dialogSelectedServiceAtts.setListData(attsSTr); + + validate(); + } else if (event.getActionCommand().equals("PRINT")) - { - if (selectedFile != null && dialogSelectedService != null) + { + if (selectedFile != null && dialogSelectedService != null) { DocPrintJob job = dialogSelectedService.createPrintJob(); - + // choose correct docflavor String mimetype = (String) dialogSelectedServicedocFormat.getSelectedItem(); - + DocFlavor flavor = null; if (mimetype.equals(DocFlavor.INPUT_STREAM.GIF.getMimeType())) flavor = DocFlavor.INPUT_STREAM.GIF; @@ -348,7 +348,7 @@ public class Demo extends JFrame flavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_HOST; else flavor = new DocFlavor(mimetype, "java.io.InputStream"); - + try { SimpleDoc doc = new SimpleDoc(new FileInputStream(selectedFile), flavor, null); @@ -363,7 +363,7 @@ public class Demo extends JFrame { JOptionPane.showMessageDialog(this, e, "PrintException", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); - } + } } else JOptionPane.showMessageDialog(this, "Please select a file to print using the FileChooser", "No file selected", JOptionPane.INFORMATION_MESSAGE); @@ -371,7 +371,7 @@ public class Demo extends JFrame else if (event.getActionCommand().equals("SERVICE")) { // A new service was selected PrintService selected = (PrintService) serviceBox.getSelectedItem(); - + DocFlavor[] flavors = selected.getSupportedDocFlavors(); docFormat.setListData(flavors); attCategories.setListData(selected.getSupportedAttributeCategories()); diff --git a/libjava/classpath/examples/gnu/classpath/examples/sound/AudioPlayerSample.java b/libjava/classpath/examples/gnu/classpath/examples/sound/AudioPlayerSample.java index 5c44c9a..4518e25 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/sound/AudioPlayerSample.java +++ b/libjava/classpath/examples/gnu/classpath/examples/sound/AudioPlayerSample.java @@ -52,15 +52,15 @@ import javax.sound.sampled.UnsupportedAudioFileException; * A simple demo to show the use of the Java Sound API. * It plays the given file (up to the end, so don't pass the 26 minutes long * Pink Floyd's Echoes unless you really want!!). - * + * * See: http://jsresources.org/examples/SimpleAudioPlayer.java.html - * + * * @author Mario Torre <neugens@limasoftware.net> */ public class AudioPlayerSample { private static final int EXTERNAL_BUFFER_SIZE = 128000; - + /** * @param args */ @@ -72,12 +72,12 @@ public class AudioPlayerSample "AudioPlayerSample [file]"); return; } - + String file = args[0]; - + System.out.println("Welcome to Radio Classpath, only great music for you!"); System.out.println("Today's DJ Tap The WaterDroplet"); - + // now create the AudioInputStream AudioInputStream audioInputStream = null; try @@ -98,15 +98,15 @@ public class AudioPlayerSample e.printStackTrace(); return; } - + // get informations about the kind of file we are about to play AudioFormat audioFormat = audioInputStream.getFormat(); - + System.out.println("Playing file: " + file); System.out.println("format: " + audioFormat.toString()); - + System.out.print("Additional properties: "); - + // now, we try to get all the properties we have in this AudioFormat // and display them Map<String, Object> properties = audioFormat.properties(); @@ -122,18 +122,18 @@ public class AudioPlayerSample System.out.println(key + ": " + properties.get(key)); } } - + // let's setup things for playing // first, we require a Line. As we are doing playing, we will ask for a // SourceDataLine SourceDataLine line = null; - + // To get the source line, we first need to build an Info object // this is done in one line: DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat); - + System.out.println("searching line..."); - + // usually, if a backend can parse a file type, it can also // create a line to handle it, but that's not guaranteed // so we need to take care and to handle a possible @@ -141,9 +141,9 @@ public class AudioPlayerSample try { line = (SourceDataLine) AudioSystem.getLine(info); - + System.out.println("line found, opening..."); - + // once created, a line must be opened to let data flow // though it. line.open(audioFormat); @@ -160,24 +160,24 @@ public class AudioPlayerSample e.printStackTrace(); return; } - + // an open line pass data to the backend only when it is in // a state called "started" ("playing" or "play" in some other // framework) System.out.print("starting line... "); - + line.start(); System.out.println("done"); - + // now we can start reading data from the AudioStream and writing // data to the pipeline. The Java Sound API is rather low level // so let you pass up to one byte of data at a time // (with some constraints, refer to the API documentation to know more) // We will do some buffering. You may want to check the frame size // to allow a better buffering, also. - + System.out.println("now playing..."); - + int nBytesRead = 0; byte[] abData = new byte[EXTERNAL_BUFFER_SIZE]; while (nBytesRead != - 1) @@ -190,7 +190,7 @@ public class AudioPlayerSample { e.printStackTrace(); } - + if (nBytesRead >= 0) { // this method returns the number of bytes actuall written @@ -200,9 +200,9 @@ public class AudioPlayerSample line.write(abData, 0, nBytesRead); } } - + System.out.print("stream finished, draining line... "); - + // call this method to ensure that all the data in the internal buffer // reach the audio backend, otherwise your application will // cut the last frames of audio data (and users will not enjoy the last @@ -212,10 +212,10 @@ public class AudioPlayerSample // Once done, we can close the line. Note that a line, once closed // may not be reopened (depends on the backend, in some cases a "reopen", // if allowed, really opens a new line, reallocating all the resources) - + System.out.println("line drained, now exiting"); line.close(); - + System.out.println("We hope you enjoyed Radio Classpath!"); } diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/BrowserEditorKit.java b/libjava/classpath/examples/gnu/classpath/examples/swing/BrowserEditorKit.java index f61275e..a929683 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/BrowserEditorKit.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/BrowserEditorKit.java @@ -54,4 +54,3 @@ public class BrowserEditorKit setAutoFormSubmission(false); } } - diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/ButtonDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/ButtonDemo.java index 1c6dfa0..8b05dac 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/ButtonDemo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/ButtonDemo.java @@ -43,23 +43,23 @@ import javax.swing.plaf.metal.MetalIconFactory; /** * A simple button demo showing various buttons in different states. */ -public class ButtonDemo - extends JPanel - implements ActionListener +public class ButtonDemo + extends JPanel + implements ActionListener { - private JCheckBox buttonState; + private JCheckBox buttonState; private JButton button1; private JButton button2; private JButton button3; private JButton button4; - private JCheckBox toggleState; + private JCheckBox toggleState; private JToggleButton toggle1; private JToggleButton toggle2; private JToggleButton toggle3; private JToggleButton toggle4; - + private JCheckBox checkBoxState; private JCheckBox checkBox1; private JCheckBox checkBox2; @@ -73,16 +73,16 @@ public class ButtonDemo /** * Creates a new demo instance. */ - public ButtonDemo() + public ButtonDemo() { createContent(); - // initFrameContent() is only called (from main) when running this app + // initFrameContent() is only called (from main) when running this app // standalone } - + /** * When the demo is run independently, the frame is displayed, so we should - * initialise the content panel (including the demo content and a close + * initialise the content panel (including the demo content and a close * button). But when the demo is run as part of the Swing activity board, * only the demo content panel is used, the frame itself is never displayed, * so we can avoid this step. @@ -100,10 +100,10 @@ public class ButtonDemo /** * 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 + * 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). - */ + */ private void createContent() { setLayout(new BorderLayout()); @@ -114,64 +114,64 @@ public class ButtonDemo panel.add(createRadioPanel()); add(panel); } - - private JPanel createButtonPanel() + + 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() + + 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); @@ -181,98 +181,98 @@ public class ButtonDemo 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() + 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() + 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) + + public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("BUTTON_STATE")) + 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")) + 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")) + 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")) + else if (e.getActionCommand().equals("RADIO_STATE")) { radio1.setEnabled(radioState.isSelected()); radio2.setEnabled(radioState.isSelected()); @@ -284,7 +284,7 @@ public class ButtonDemo } } - public static void main(String[] args) + public static void main(String[] args) { SwingUtilities.invokeLater (new Runnable() diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/ComboBoxDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/ComboBoxDemo.java index 61dee06..682af0b 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/ComboBoxDemo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/ComboBoxDemo.java @@ -47,11 +47,11 @@ import javax.swing.plaf.metal.MetalIconFactory; /** * A simple demo showing various combo boxes in different states. */ -public class ComboBoxDemo +public class ComboBoxDemo extends JPanel - implements ActionListener + implements ActionListener { - + class CustomCellRenderer extends DefaultListCellRenderer { public Component getListCellRendererComponent(JList list, @@ -60,9 +60,9 @@ public class ComboBoxDemo boolean isSelected, boolean cellHasFocus) { - DefaultListCellRenderer result = (DefaultListCellRenderer) - super.getListCellRendererComponent(list, value, index, isSelected, - cellHasFocus); + DefaultListCellRenderer result = (DefaultListCellRenderer) + super.getListCellRendererComponent(list, value, index, isSelected, + cellHasFocus); Icon icon = (Icon) value; result.setIcon(icon); result.setText("Index = " + index); @@ -70,47 +70,47 @@ public class ComboBoxDemo } } - private JCheckBox comboState1; + private JCheckBox comboState1; private JComboBox combo1; private JComboBox combo2; - private JCheckBox comboState2; + private JCheckBox comboState2; private JComboBox combo3; private JComboBox combo4; - - private JCheckBox comboState3; + + private JCheckBox comboState3; private JComboBox combo5; private JComboBox combo6; - private JCheckBox comboState4; + private JCheckBox comboState4; private JComboBox combo7; private JComboBox combo8; - private JCheckBox comboState5; + private JCheckBox comboState5; private JComboBox combo9; private JComboBox combo10; - + private JCheckBox comboState6; private JComboBox combo11; private JComboBox combo12; - + /** * Creates a new demo instance. */ - public ComboBoxDemo() + public ComboBoxDemo() { super(); createContent(); } - + /** * When the demo is run independently, the frame is displayed, so we should - * initialise the content panel (including the demo content and a close + * initialise the content panel (including the demo content and a close * button). But when the demo is run as part of the Swing activity board, * only the demo content panel is used, the frame itself is never displayed, * so we can avoid this step. */ - void initFrameContent() + void initFrameContent() { JPanel closePanel = new JPanel(); JButton closeButton = new JButton("Close"); @@ -119,15 +119,15 @@ public class ComboBoxDemo closePanel.add(closeButton); add(closePanel, BorderLayout.SOUTH); } - + /** * 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 + * 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). - */ - private void createContent() + */ + private void createContent() { setLayout(new BorderLayout()); JPanel panel = new JPanel(new GridLayout(6, 1)); @@ -139,127 +139,127 @@ public class ComboBoxDemo panel.add(createPanel6()); add(panel); } - - private JPanel createPanel1() + + 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", + this.combo1 = new JComboBox(new Object[] {"Australia", "New Zealand", "England"}); - - this.combo2 = new JComboBox(new Object[] {"Australia", "New Zealand", + + 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() + + 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", + 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", + + 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() + 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", + this.combo5 = new JComboBox(new Object[] {"Australia", "New Zealand", "England"}); this.combo5.setBackground(Color.yellow); - - this.combo6 = new JComboBox(new Object[] {"Australia", "New Zealand", + + 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() + 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 + * This panel contains combo boxes that are narrow but contain long text * items. - * + * * @return A panel. */ - private JPanel createPanel5() + 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[] { @@ -269,28 +269,28 @@ public class ComboBoxDemo "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() + 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[] { @@ -304,43 +304,43 @@ public class ComboBoxDemo 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) + public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("COMBO_STATE1")) + if (e.getActionCommand().equals("COMBO_STATE1")) { combo1.setEnabled(comboState1.isSelected()); combo2.setEnabled(comboState1.isSelected()); } - else if (e.getActionCommand().equals("COMBO_STATE2")) + else if (e.getActionCommand().equals("COMBO_STATE2")) { combo3.setEnabled(comboState2.isSelected()); combo4.setEnabled(comboState2.isSelected()); } - else if (e.getActionCommand().equals("COMBO_STATE3")) + else if (e.getActionCommand().equals("COMBO_STATE3")) { combo5.setEnabled(comboState3.isSelected()); combo6.setEnabled(comboState3.isSelected()); } - else if (e.getActionCommand().equals("COMBO_STATE4")) + else if (e.getActionCommand().equals("COMBO_STATE4")) { combo7.setEnabled(comboState4.isSelected()); combo8.setEnabled(comboState4.isSelected()); } - else if (e.getActionCommand().equals("COMBO_STATE5")) + else if (e.getActionCommand().equals("COMBO_STATE5")) { combo9.setEnabled(comboState5.isSelected()); combo10.setEnabled(comboState5.isSelected()); } - else if (e.getActionCommand().equals("COMBO_STATE6")) + else if (e.getActionCommand().equals("COMBO_STATE6")) { combo11.setEnabled(comboState6.isSelected()); combo12.setEnabled(comboState6.isSelected()); @@ -351,7 +351,7 @@ public class ComboBoxDemo } } - public static void main(String[] args) + public static void main(String[] args) { SwingUtilities.invokeLater (new Runnable() diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/Demo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/Demo.java index 3c7f0b8..772df6a 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/Demo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/Demo.java @@ -76,7 +76,7 @@ public class Demo private JMenuBar mkMenuBar() { JMenuBar bar = new JMenuBar(); - + JMenu file = new JMenu("File"); JMenu edit = new JMenu("Edit"); JMenu help = new JMenu("Help"); @@ -113,9 +113,9 @@ public class Demo JMenu preferences = new JMenu("Preferences..."); preferences.add(new JCheckBoxMenuItem("Microphone Active", - stockIcon("mic"))); + stockIcon("mic"))); preferences.add(new JCheckBoxMenuItem("Check Spelling", - stockIcon("spell-check"))); + stockIcon("spell-check"))); preferences.add(new JCheckBoxMenuItem("World Peace")); preferences.add(new JSeparator()); preferences.add(new JRadioButtonMenuItem("Radio Button")); @@ -165,7 +165,7 @@ public class Demo final JMenuItem vmMenu; - + help.add(new JMenuItem("just play with the widgets")); help.add(new JMenuItem("and enjoy the sensation of")); help.add(new JMenuItem("your neural connections growing")); @@ -182,14 +182,14 @@ public class Demo + " distributed by " + System.getProperty("java.vm.vendor") + "."; - + String gnuClasspath = System.getProperty("gnu.classpath.version"); if(gnuClasspath != null) message += "\nThe runtime's libraries are " + "kindly provided by the " + "members of GNU Classpath and are in version " + gnuClasspath + "."; - + JOptionPane.showMessageDialog(vmMenu, message); } }); @@ -197,7 +197,7 @@ public class Demo // Installs the BasicLookAndFeel. UIManager.installLookAndFeel("(Basic Look And Feel)", InstantiableBasicLookAndFeel.class.getName()); - + // Create L&F menu. JMenu lafMenu = new JMenu("Look and Feel"); ButtonGroup lafGroup = new ButtonGroup(); @@ -211,7 +211,7 @@ public class Demo boolean selected = laf.getClassName().equals(currentLaf); lafItem.setSelected(selected); lafMenu.add(lafItem); - + lafGroup.add(lafItem); } @@ -231,7 +231,7 @@ public class Demo { // Ignore it. } - + if (m != null) { JRadioButtonMenuItem ocean = @@ -239,7 +239,7 @@ public class Demo ocean.setSelected(MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme); themesMenu.add(ocean); themesGroup.add(ocean); - + JRadioButtonMenuItem steel = new JRadioButtonMenuItem(new ChangeThemeAction(new DefaultMetalTheme())); ocean.setSelected(MetalLookAndFeel.getCurrentTheme() @@ -251,7 +251,7 @@ public class Demo { themesMenu.setEnabled(false); } - + bar.add(file); bar.add(edit); bar.add(examples); @@ -267,10 +267,10 @@ public class Demo { public void actionPerformed(ActionEvent e) { - JOptionPane.showConfirmDialog(but, + JOptionPane.showConfirmDialog(but, "Sure you want to go " + dir + "?", "Confirm", - JOptionPane.OK_CANCEL_OPTION, + JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, bigStockIcon("warning")); } @@ -310,10 +310,10 @@ public class Demo } } - private static JButton mkButton(String title, Icon icon, + private static JButton mkButton(String title, Icon icon, int hAlign, int vAlign, int hPos, int vPos) - { + { JButton b; if (icon == null) b = new JButton(title); @@ -321,12 +321,12 @@ public class Demo b = new JButton(icon); 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); - if (vPos != -1) b.setVerticalTextPosition(vPos); + if (vPos != -1) b.setVerticalTextPosition(vPos); return b; } @@ -363,7 +363,7 @@ public class Demo { public void run() { - new Demo(); + new Demo(); } } @@ -442,7 +442,7 @@ public class Demo } private JPanel mkButtonBar() - { + { JPanel panel = new JPanel(new GridLayout(3, 1, 5, 5)); panel.add(new JButton(new PopupAction("Buttons", ButtonDemo.createDemoFactory()))); @@ -479,15 +479,15 @@ public class Demo JButton exitDisposer = mkDisposerButton(frame); panel.add(exitDisposer); - - panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, + + panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, panel.getPreferredSize().height)); exitDisposer.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) - { - System.exit(1); - } + public void actionPerformed(ActionEvent e) + { + System.exit(1); + } }); return panel; } @@ -546,7 +546,7 @@ public class Demo } SwingUtilities.updateComponentTreeUI(frame); } - + } /** @@ -585,16 +585,16 @@ public class Demo { ex.printStackTrace(); } - + SwingUtilities.updateComponentTreeUI(frame); themesMenu.setEnabled(laf.getClassName() .equals("javax.swing.plaf.metal.MetalLookAndFeel")); } } - + /** * An implementation of BasicLookAndFeel which can be instantiated. - * + * * @author Robert Schuster (robertschuster@fsfe.org) * */ @@ -604,9 +604,9 @@ public class Demo { return "An instantiable implementation of BasicLookAndFeel"; } - + public String getID() - { + { return "instantiableBasicLookAndFeel"; } @@ -614,12 +614,12 @@ public class Demo { return "Instantiable Basic Look And Feel"; } - + public boolean isNativeLookAndFeel() { return false; } - + public boolean isSupportedLookAndFeel() { return true; diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/DemoFactory.java b/libjava/classpath/examples/gnu/classpath/examples/swing/DemoFactory.java index 0320f31..0bbd022 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/DemoFactory.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/DemoFactory.java @@ -50,7 +50,7 @@ public interface DemoFactory /** * Creates the component that should be as demo application. - * + * * @return the component that should be as demo application */ JComponent createDemo(); diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/DocumentFilterDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/DocumentFilterDemo.java index b338e43..58db991 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/DocumentFilterDemo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/DocumentFilterDemo.java @@ -47,20 +47,20 @@ import javax.swing.text.DocumentFilter; /** * A demonstration of the <code>javax.swing.text.DocumentFilter</code> class. - * + * * <p>Similar to a dialog in a popular programming IDE the user can insert * a CVS URL into a textfield and the filter will split the components apart * and will put them into the right textfields saving the user a lot of * typing time.</p> - * + * * @author Robert Schuster */ -public class DocumentFilterDemo - extends JPanel - implements ActionListener +public class DocumentFilterDemo + extends JPanel + implements ActionListener { JTextField target; - + JTextField host; JTextField repositoryPath; JTextField user; @@ -70,16 +70,16 @@ public class DocumentFilterDemo /** * Creates a new demo instance. */ - public DocumentFilterDemo() + public DocumentFilterDemo() { createContent(); - // initFrameContent() is only called (from main) when running this app + // initFrameContent() is only called (from main) when running this app // standalone } - + /** * When the demo is run independently, the frame is displayed, so we should - * initialise the content panel (including the demo content and a close + * initialise the content panel (including the demo content and a close * button). But when the demo is run as part of the Swing activity board, * only the demo content panel is used, the frame itself is never displayed, * so we can avoid this step. @@ -97,30 +97,30 @@ public class DocumentFilterDemo private void createContent() { setLayout(new BorderLayout()); - + JPanel panel = new JPanel(new GridLayout(7, 2)); panel.add(new JLabel("CVS URL:")); panel.add(target = new JTextField(20)); target.setBackground(Color.RED); - + panel.add(new JLabel("Host:")); panel.add(host = new JTextField(20)); - + panel.add(new JLabel("Repository Path:")); panel.add(repositoryPath = new JTextField(20)); - + panel.add(new JLabel("Username:")); panel.add(user = new JTextField(20)); - + panel.add(new JLabel("Password:")); panel.add(password = new JTextField(20)); - + panel.add(new JLabel("Connection Type:")); panel.add(connectionType = new JComboBox()); - + JButton helpButton = new JButton("Help"); panel.add(helpButton); - + helpButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) @@ -134,7 +134,7 @@ public class DocumentFilterDemo "string into your clipboard."); } }); - + JButton exampleButton = new JButton("Provide me an example!"); panel.add(exampleButton); exampleButton.addActionListener(new ActionListener() @@ -148,9 +148,9 @@ public class DocumentFilterDemo StringSelection selection = new StringSelection(":extssh:gnu@cvs.savannah.gnu.org:" + "/cvs/example/project"); - + cb.setContents(selection, selection); - + // Confirm success with a beep. tk.beep(); } @@ -164,25 +164,25 @@ public class DocumentFilterDemo } } }); - + connectionType.addItem("pserver"); connectionType.addItem("ext"); connectionType.addItem("extssh"); - + add(panel); - + AbstractDocument doc = (AbstractDocument) target.getDocument(); doc.setDocumentFilter(new CVSFilter()); } - - public void actionPerformed(ActionEvent e) + + public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("CLOSE")) System.exit(0); - - } - public static void main(String[] args) + } + + public static void main(String[] args) { SwingUtilities.invokeLater (new Runnable() @@ -215,7 +215,7 @@ public class DocumentFilterDemo } }; } - + class CVSFilter extends DocumentFilter { // example: pserver:anonymous@cvs.sourceforge.net:/cvsroot/fmj @@ -228,7 +228,7 @@ public class DocumentFilterDemo { filterString(fb, offset, 0, string, attr, true); } - + public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String string, @@ -237,7 +237,7 @@ public class DocumentFilterDemo { filterString(fb, offset, length, string, attr, false); } - + public void filterString(DocumentFilter.FilterBypass fb, int offset, int length, String string, AttributeSet attr, boolean insertion) @@ -253,12 +253,12 @@ public class DocumentFilterDemo // operation on the remaining string and continue. if(result[0].equals("")) result = result[1].split(":", 2); - + connectionType.setSelectedItem(result[0]); - + // Split off the username and password part result = result[1].split("@", 2); - + // Break username and password in half String[] userCredentials = result[0].split(":"); user.setText(userCredentials[0]); @@ -267,22 +267,22 @@ public class DocumentFilterDemo // be the password. if (userCredentials.length == 2) password.setText(userCredentials[1]); - + // Now break the host part apart. result = result[1].split(":"); - + host.setText(result[0]); - + repositoryPath.setText(result[1]); } - + // The unmodified string is put into the document. if (insertion) fb.insertString(offset, string, attr); else fb.replace(offset, length, string, attr); } - + } - + } diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/FileChooserDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/FileChooserDemo.java index 86cc015..444453b 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/FileChooserDemo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/FileChooserDemo.java @@ -46,57 +46,57 @@ import javax.swing.filechooser.FileFilter; */ public class FileChooserDemo extends JPanel - implements ActionListener + implements ActionListener { /** * A file filter for Java source files. */ static class JavaFileFilter extends FileFilter { - public String getDescription() + public String getDescription() { return "Java Source Files (.java)"; } public boolean accept(File f) { - if (f != null) + if (f != null) { return f.getName().endsWith(".java") || f.isDirectory(); } - else + else return false; } } /** A label to display the selected file. */ JLabel selectedFileLabel; - - /** - * A list showing the selected files (where multi selections are - * allowed). + + /** + * 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. + * Creates a new demo instance. */ - public FileChooserDemo() + public FileChooserDemo() { super(); createContent(); } - + /** * When the demo is run independently, the frame is displayed, so we should - * initialise the content panel (including the demo content and a close + * initialise the content panel (including the demo content and a close * button). But when the demo is run as part of the Swing activity board, * only the demo content panel is used, the frame itself is never displayed, * so we can avoid this step. */ - void initFrameContent() + void initFrameContent() { JPanel closePanel = new JPanel(); JButton closeButton = new JButton("Close"); @@ -105,7 +105,7 @@ public class FileChooserDemo closePanel.add(closeButton); add(closePanel, BorderLayout.SOUTH); } - + /** * Returns a panel with the demo content. The panel * uses a BorderLayout(), and the BorderLayout.SOUTH area @@ -116,8 +116,8 @@ public class FileChooserDemo private void createContent() { setLayout(new BorderLayout()); - - // create a panel of buttons to select the different styles of file + + // 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..."); @@ -141,30 +141,30 @@ public class FileChooserDemo openMultiButton.addActionListener(this); buttonPanel.add(openMultiButton); 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); - + add(displayPanel); } - + /** * 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) @@ -172,7 +172,7 @@ public class FileChooserDemo int option = 0; File selectedFile = null; File[] selectedFiles = new File[0]; - + if (e.getActionCommand().equals("CLOSE")) { System.exit(0); @@ -216,7 +216,7 @@ public class FileChooserDemo selectedFile = chooser.getSelectedFile(); selectedFiles = chooser.getSelectedFiles(); } - + // display the selection and return code if (selectedFile != null) selectedFileLabel.setText(selectedFile.toString()); @@ -228,8 +228,8 @@ public class FileChooserDemo selectedFilesList.setModel(listModel); returnCodeLabel.setText(Integer.toString(option)); } - - public static void main(String[] args) + + public static void main(String[] args) { SwingUtilities.invokeLater (new Runnable() diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/HtmlDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/HtmlDemo.java index 1a24ae2..20977b2 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/HtmlDemo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/HtmlDemo.java @@ -68,11 +68,11 @@ import javax.swing.text.html.FormSubmitEvent; /** * Parses and displays HTML content. - * + * * @author Audrius Meskauskas (audriusa@bioinformatics.org) */ public class HtmlDemo extends JPanel -{ +{ private class LoadActionListener implements ActionListener @@ -101,10 +101,10 @@ public class HtmlDemo extends JPanel /** * The URL entry field. */ - JTextField url = new JTextField(); + JTextField url = new JTextField(); JTextPane html = new JTextPane(); - + int n; /** @@ -152,7 +152,7 @@ public class HtmlDemo extends JPanel } } } - + }); JScrollPane scroller = new JScrollPane(html); @@ -190,7 +190,7 @@ public class HtmlDemo extends JPanel } setPreferredSize(new Dimension(800, 600)); } - + /** * Creates the toolbar with the control buttons. @@ -254,7 +254,7 @@ public class HtmlDemo extends JPanel /** * The executable method to display the editable table. - * + * * @param args * unused. */ @@ -377,4 +377,3 @@ public class HtmlDemo extends JPanel }; } } - diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/ListDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/ListDemo.java index 7ed15be..8caa1dc 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/ListDemo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/ListDemo.java @@ -62,7 +62,7 @@ public class ListDemo implements ActionListener { - private static class LabelCellRenderer + private static class LabelCellRenderer extends DefaultListCellRenderer { public Component getListCellRendererComponent(JList list, @@ -71,14 +71,14 @@ public class ListDemo boolean isSelected, boolean cellHasFocus) { - Component c = super.getListCellRendererComponent(list, value, index, + Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); return c; } } - private static class CheckCellRenderer + private static class CheckCellRenderer extends JCheckBox implements ListCellRenderer { @@ -90,7 +90,7 @@ public class ListDemo { setSelected(isSelected); setText(value.toString()); - + return this; } } @@ -104,7 +104,7 @@ public class ListDemo private void createContent() { - String foo[] = new String[] { + String foo[] = new String[] { "non alcoholic ", "carbonated ", "malted ", @@ -113,8 +113,8 @@ public class ListDemo "high fructose ", "enriched " }; - - String bar[] = new String[] { + + String bar[] = new String[] { "orange juice", "ginger beer", "yak milk", @@ -162,7 +162,7 @@ public class ListDemo splitter.add(new JScrollPane(list2), JSplitPane.RIGHT); setLayout(new BorderLayout()); - JPanel p2 = new JPanel(); + JPanel p2 = new JPanel(); p2.setLayout(new GridLayout(1, 2)); p2.add(add); p2.add(del); @@ -171,7 +171,7 @@ public class ListDemo add(splitter, BorderLayout.CENTER); } - public void actionPerformed(ActionEvent e) + public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("CLOSE")) { @@ -181,7 +181,7 @@ public class ListDemo /** * When the demo is run independently, the frame is displayed, so we should - * initialise the content panel (including the demo content and a close + * initialise the content panel (including the demo content and a close * button). But when the demo is run as part of the Swing activity board, * only the demo content panel is used, the frame itself is never displayed, * so we can avoid this step. diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/MetalThemeEditor.java b/libjava/classpath/examples/gnu/classpath/examples/swing/MetalThemeEditor.java index d3be0b8..1360f9b 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/MetalThemeEditor.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/MetalThemeEditor.java @@ -134,7 +134,7 @@ public class MetalThemeEditor g.setColor(color); g.fillRect(x, y, 30, 10); } - + } /** @@ -477,7 +477,7 @@ public class MetalThemeEditor { ex.printStackTrace(); } - + } /** diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/NavigationFilterDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/NavigationFilterDemo.java index a7472df..761c575 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/NavigationFilterDemo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/NavigationFilterDemo.java @@ -42,32 +42,32 @@ import javax.swing.text.Utilities; /** * A demonstration of the <code>javax.swing.text.NavigationFilter</code> class. - * + * * <p>It shows a NavigationFilter which lets you walk word-wise * through a text.</p> - * + * * @author Robert Schuster */ -public class NavigationFilterDemo - extends JPanel - implements ActionListener +public class NavigationFilterDemo + extends JPanel + implements ActionListener { - + JTextArea textArea; /** * Creates a new demo instance. */ - public NavigationFilterDemo() + public NavigationFilterDemo() { createContent(); - // initFrameContent() is only called (from main) when running this app + // initFrameContent() is only called (from main) when running this app // standalone } - + /** * When the demo is run independently, the frame is displayed, so we should - * initialise the content panel (including the demo content and a close + * initialise the content panel (including the demo content and a close * button). But when the demo is run as part of the Swing activity board, * only the demo content panel is used, the frame itself is never displayed, * so we can avoid this step. @@ -85,29 +85,29 @@ public class NavigationFilterDemo private void createContent() { setLayout(new BorderLayout()); - + add(textArea = new JTextArea(10, 20)); - + textArea.setWrapStyleWord(true); - + textArea.setLineWrap(true); - + textArea.setNavigationFilter(new WordFilter()); - + textArea.setText("GNU Classpath, Essential Libraries for Java, " + "is a GNU project to create free core class " + "libraries for use with virtual machines and " + "compilers for the java programming language."); } - - public void actionPerformed(ActionEvent e) + + public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("CLOSE")) System.exit(0); - - } - public static void main(String[] args) + } + + public static void main(String[] args) { SwingUtilities.invokeLater (new Runnable() @@ -140,7 +140,7 @@ public class NavigationFilterDemo } }; } - + class WordFilter extends NavigationFilter { public int getNextVisualPositionFrom(JTextComponent text, @@ -151,14 +151,14 @@ public class NavigationFilterDemo throws BadLocationException { Point pt; - + int newpos = pos; switch (direction) { case SwingConstants.NORTH: // Find out where the caret want to be positioned ideally. pt = text.getCaret().getMagicCaretPosition(); - + // Calculate its position above. newpos = Utilities.getPositionAbove(text, pos, (pt != null) ? pt.x : 0); @@ -184,7 +184,7 @@ public class NavigationFilterDemo case SwingConstants.WEST: // Calculate the next word start. newpos = Utilities.getWordStart(text, newpos); - + // If that means that the caret will not move, return // the start of the previous word. if (newpos != pos) @@ -199,7 +199,7 @@ public class NavigationFilterDemo direction, biasRet); } } - + } - + } diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/ScrollBarDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/ScrollBarDemo.java index 505991e..ac500d6 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/ScrollBarDemo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/ScrollBarDemo.java @@ -37,23 +37,23 @@ import javax.swing.SwingUtilities; /** * A simple scroll bar demo showing various scroll bars in different states. */ -public class ScrollBarDemo +public class ScrollBarDemo extends JPanel - implements ActionListener + implements ActionListener { /** * Creates a new demo instance. */ - public ScrollBarDemo() + public ScrollBarDemo() { super(); createContent(); } - + /** * When the demo is run independently, the frame is displayed, so we should - * initialise the content panel (including the demo content and a close + * initialise the content panel (including the demo content and a close * button). But when the demo is run as part of the Swing activity board, * only the demo content panel is used, the frame itself is never displayed, * so we can avoid this step. @@ -67,27 +67,27 @@ public class ScrollBarDemo closePanel.add(closeButton); add(closePanel, BorderLayout.SOUTH); } - + /** * 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 + * 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). - */ - private void createContent() + */ + private void createContent() { setLayout(new BorderLayout()); JPanel panel = createScrollBarPanel(); add(panel); } - - private JPanel createScrollBarPanel() + + 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); @@ -100,12 +100,12 @@ public class ScrollBarDemo 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); @@ -114,7 +114,7 @@ public class ScrollBarDemo 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); @@ -122,17 +122,17 @@ public class ScrollBarDemo 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; + return panel; } - - public void actionPerformed(ActionEvent e) + + public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("CLOSE")) { @@ -140,7 +140,7 @@ public class ScrollBarDemo } } - public static void main(String[] args) + public static void main(String[] args) { SwingUtilities.invokeLater (new Runnable() diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/SliderDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/SliderDemo.java index df84cc6..76d68c9 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/SliderDemo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/SliderDemo.java @@ -37,7 +37,7 @@ import javax.swing.SwingUtilities; public class SliderDemo extends JPanel - implements ActionListener + implements ActionListener { JSlider hslider1; @@ -48,7 +48,7 @@ public class SliderDemo JSlider hslider6; JSlider hslider7; JSlider hslider8; - + JSlider vslider1; JSlider vslider2; JSlider vslider3; @@ -59,15 +59,15 @@ public class SliderDemo JSlider vslider8; JCheckBox enabledCheckBox; - - public SliderDemo() + + public SliderDemo() { createContent(); } - + /** * When the demo is run independently, the frame is displayed, so we should - * initialise the content panel (including the demo content and a close + * initialise the content panel (including the demo content and a close * button). But when the demo is run as part of the Swing activity board, * only the demo content panel is used, the frame itself is never displayed, * so we can avoid this step. @@ -81,15 +81,15 @@ public class SliderDemo closePanel.add(closeButton); add(closePanel, BorderLayout.SOUTH); } - + /** * 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 + * 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). - */ - private void createContent() + */ + private void createContent() { setLayout(new BorderLayout()); JPanel panel = new JPanel(new GridLayout(1, 2)); @@ -106,14 +106,14 @@ public class SliderDemo panel2.add(checkBoxPanel, BorderLayout.SOUTH); add(panel2); } - - private JPanel createHorizontalPanel() + + 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); @@ -138,7 +138,7 @@ public class SliderDemo 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); @@ -165,14 +165,14 @@ public class SliderDemo return panel; } - - private JPanel createVerticalPanel() + + 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); @@ -197,7 +197,7 @@ public class SliderDemo 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); @@ -223,8 +223,8 @@ public class SliderDemo panel.add(vslider8); return panel; } - - public void actionPerformed(ActionEvent e) + + public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("CLOSE")) { @@ -251,7 +251,7 @@ public class SliderDemo vslider8.setEnabled(enabled); } } - public static void main(String[] args) + public static void main(String[] args) { SwingUtilities.invokeLater (new Runnable() diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/SpinnerDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/SpinnerDemo.java index d0edd96..abf72bc 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/SpinnerDemo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/SpinnerDemo.java @@ -45,39 +45,39 @@ import javax.swing.SwingUtilities; /** * A simple demo showing various spinners in different states. */ -public class SpinnerDemo - extends JPanel - implements ActionListener +public class SpinnerDemo + extends JPanel + implements ActionListener { - private JCheckBox spinnerState1; + private JCheckBox spinnerState1; private JSpinner spinner1; private JSpinner spinner2; - private JCheckBox spinnerState2; + private JCheckBox spinnerState2; private JSpinner spinner3; private JSpinner spinner4; - - private JCheckBox spinnerState3; + + private JCheckBox spinnerState3; private JSpinner spinner5; private JSpinner spinner6; - + /** * Creates a new demo instance. */ - public SpinnerDemo() + public SpinnerDemo() { super(); createContent(); } - + /** * When the demo is run independently, the frame is displayed, so we should - * initialise the content panel (including the demo content and a close + * initialise the content panel (including the demo content and a close * button). But when the demo is run as part of the Swing activity board, * only the demo content panel is used, the frame itself is never displayed, * so we can avoid this step. */ - void initFrameContent() + void initFrameContent() { JPanel closePanel = new JPanel(); JButton closeButton = new JButton("Close"); @@ -86,15 +86,15 @@ public class SpinnerDemo closePanel.add(closeButton); add(closePanel, BorderLayout.SOUTH); } - + /** * 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 + * 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). - */ - private void createContent() + */ + private void createContent() { setLayout(new BorderLayout()); JPanel panel = new JPanel(new GridLayout(3, 1)); @@ -103,15 +103,15 @@ public class SpinnerDemo panel.add(createPanel3()); add(panel); } - - private JPanel createPanel1() + + private JPanel createPanel1() { JPanel panel = new JPanel(new BorderLayout()); this.spinnerState1 = new JCheckBox("Enabled", true); this.spinnerState1.setActionCommand("COMBO_STATE1"); this.spinnerState1.addActionListener(this); panel.add(this.spinnerState1, BorderLayout.EAST); - + JPanel controlPanel = new JPanel(); controlPanel.setBorder(BorderFactory.createTitledBorder( "Number Spinner: ")); @@ -120,76 +120,76 @@ public class SpinnerDemo this.spinner2.setFont(new Font("Dialog", Font.PLAIN, 20)); controlPanel.add(this.spinner1); controlPanel.add(this.spinner2); - + panel.add(controlPanel); - + return panel; } - - private JPanel createPanel2() + + private JPanel createPanel2() { JPanel panel = new JPanel(new BorderLayout()); this.spinnerState2 = new JCheckBox("Enabled", true); this.spinnerState2.setActionCommand("COMBO_STATE2"); this.spinnerState2.addActionListener(this); panel.add(this.spinnerState2, BorderLayout.EAST); - + JPanel controlPanel = new JPanel(); controlPanel.setBorder(BorderFactory.createTitledBorder("Date Spinner: ")); - this.spinner3 = new JSpinner(new SpinnerDateModel(new Date(), null, null, + this.spinner3 = new JSpinner(new SpinnerDateModel(new Date(), null, null, Calendar.DATE)); - - this.spinner4 = new JSpinner(new SpinnerDateModel(new Date(), null, null, + + this.spinner4 = new JSpinner(new SpinnerDateModel(new Date(), null, null, Calendar.YEAR)); this.spinner4.setFont(new Font("Dialog", Font.PLAIN, 20)); - + controlPanel.add(this.spinner3); controlPanel.add(this.spinner4); - + panel.add(controlPanel); - + return panel; } - private JPanel createPanel3() + private JPanel createPanel3() { JPanel panel = new JPanel(new BorderLayout()); this.spinnerState3 = new JCheckBox("Enabled", true); this.spinnerState3.setActionCommand("COMBO_STATE3"); this.spinnerState3.addActionListener(this); panel.add(this.spinnerState3, BorderLayout.EAST); - + JPanel controlPanel = new JPanel(); controlPanel.setBorder(BorderFactory.createTitledBorder("List Spinner: ")); - this.spinner5 = new JSpinner(new SpinnerListModel(new Object[] {"Red", + this.spinner5 = new JSpinner(new SpinnerListModel(new Object[] {"Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"})); - - this.spinner6 = new JSpinner(new SpinnerListModel(new Object[] {"Red", + + this.spinner6 = new JSpinner(new SpinnerListModel(new Object[] {"Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"})); this.spinner6.setValue("Yellow"); this.spinner6.setFont(new Font("Dialog", Font.PLAIN, 20)); - + controlPanel.add(this.spinner5); controlPanel.add(this.spinner6); - + panel.add(controlPanel); - + return panel; } - - public void actionPerformed(ActionEvent e) + + public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("COMBO_STATE1")) + if (e.getActionCommand().equals("COMBO_STATE1")) { spinner1.setEnabled(spinnerState1.isSelected()); spinner2.setEnabled(spinnerState1.isSelected()); } - else if (e.getActionCommand().equals("COMBO_STATE2")) + else if (e.getActionCommand().equals("COMBO_STATE2")) { spinner3.setEnabled(spinnerState2.isSelected()); spinner4.setEnabled(spinnerState2.isSelected()); } - else if (e.getActionCommand().equals("COMBO_STATE3")) + else if (e.getActionCommand().equals("COMBO_STATE3")) { spinner5.setEnabled(spinnerState3.isSelected()); spinner6.setEnabled(spinnerState3.isSelected()); @@ -200,7 +200,7 @@ public class SpinnerDemo } } - public static void main(String[] args) + public static void main(String[] args) { SwingUtilities.invokeLater (new Runnable() diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/TabbedPaneDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/TabbedPaneDemo.java index bd0e6bf..7cf02ce 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/TabbedPaneDemo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/TabbedPaneDemo.java @@ -78,26 +78,26 @@ public class TabbedPaneDemo { JPanel p = new JPanel(); p.setLayout(new GridLayout(1, 1)); - + int COUNT = 25; JTabbedPane tp = createTabbedPane(SwingConstants.TOP, "tab", COUNT); p.add(tp); - + final JPopupMenu popup = new JPopupMenu(); JMenu menu = new JMenu("tab placement"); menu.add(createPlacementChangingMenuItem("top", SwingConstants.TOP, tp)); - + menu.add(createPlacementChangingMenuItem("bottom", SwingConstants.BOTTOM, tp)); - + menu.add(createPlacementChangingMenuItem("left", SwingConstants.LEFT, tp)); - + menu.add(createPlacementChangingMenuItem("right", SwingConstants.RIGHT, tp)); @@ -107,40 +107,40 @@ public class TabbedPaneDemo menu.add(createLayoutPolicyChangingMenuItem("wrapping tabs", JTabbedPane.WRAP_TAB_LAYOUT, tp)); - + menu.add(createLayoutPolicyChangingMenuItem("scrolling tabs", JTabbedPane.SCROLL_TAB_LAYOUT, tp)); popup.add(menu); - + tp.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { showPopup(e); } - + public void mouseReleased(MouseEvent e) { showPopup(e); } - + void showPopup(MouseEvent e) { if (e.isPopupTrigger()) { popup.show(e.getComponent(), e.getX(), e.getY()); } } }); - + setLayout(new BorderLayout()); add(p, BorderLayout.CENTER); - + } - + private JMenuItem createPlacementChangingMenuItem(String t, final int v, final JTabbedPane dst) { JMenuItem item = new JMenuItem(t); - + item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) @@ -148,16 +148,16 @@ public class TabbedPaneDemo dst.setTabPlacement(v); } }); - + return item; } - + private JMenuItem createLayoutPolicyChangingMenuItem(String t, final int v, final JTabbedPane dst) { JMenuItem item = new JMenuItem(t); - + item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) @@ -165,24 +165,24 @@ public class TabbedPaneDemo dst.setTabLayoutPolicy(v); } }); - + return item; } - + private JTabbedPane createTabbedPane(int direction, String name, int count) { JTabbedPane pane = new JTabbedPane(direction); - + for(int i = 0; i< count; i++) { pane.addTab(name + " " + i, createTabContent(name + " " + i)); if (Math.random() >= 0.75) pane.setEnabledAt(i, false); } - + return pane; } - + private JPanel createTabContent(String name) { JTextArea ta; @@ -190,13 +190,13 @@ public class TabbedPaneDemo panel.add(new JLabel(name)); panel.add(new JButton(name)); panel.add(new JScrollPane(ta = new JTextArea(5, 5))); - + ta.setBackground(colors[(int) (Math.random() * colors.length)]); - + return panel; } - public void actionPerformed(ActionEvent e) + public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("CLOSE")) { @@ -206,7 +206,7 @@ public class TabbedPaneDemo /** * When the demo is run independently, the frame is displayed, so we should - * initialise the content panel (including the demo content and a close + * initialise the content panel (including the demo content and a close * button). But when the demo is run as part of the Swing activity board, * only the demo content panel is used, the frame itself is never displayed, * so we can avoid this step. diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/TableDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/TableDemo.java index 9f8e3e7..6aa9ba5 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/TableDemo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/TableDemo.java @@ -65,28 +65,28 @@ import javax.swing.table.TableColumnModel; /** * Displays the editable table. The first column consists of check boxes. - * + * * @author Audrius Meskauskas (audriusa@bioinformatics.org) */ public class TableDemo extends JPanel -{ +{ /** * The initial row count for this table. - */ + */ static int rows = 32; - + /** * The initial column count for this table. - */ + */ static int cols = 7; - - + + /** * The table model. */ class TModel extends DefaultTableModel { - + /** * All cells are editable in our table. */ @@ -94,7 +94,7 @@ public class TableDemo extends JPanel { return true; } - + /** * Get the number of the table rows. */ @@ -110,7 +110,7 @@ public class TableDemo extends JPanel { return cols; } - + /** * Set the value at the given position */ @@ -118,7 +118,7 @@ public class TableDemo extends JPanel { values[aRow][aColumn] = aValue; } - + /** * Get the value at the given position. */ @@ -126,7 +126,7 @@ public class TableDemo extends JPanel { return values[aRow][aColumn]; } - + /** * The column name, as suggested by model. This header should not be * visible, as it is overridden by setting the header name with @@ -136,9 +136,9 @@ public class TableDemo extends JPanel { return "Error "+column; } - + /** - * The first column contains booleans, the second - icons, + * The first column contains booleans, the second - icons, * others - default class. */ public Class getColumnClass(int column) @@ -149,7 +149,7 @@ public class TableDemo extends JPanel return Icon.class; else return super.getColumnClass(column); - } + } } /** @@ -163,12 +163,12 @@ public class TableDemo extends JPanel * The editor bar. */ JSlider bar; - + /** * The renderer bar. */ JSlider rendererBar; - + /** * The border around the bar, if required. */ @@ -179,9 +179,9 @@ public class TableDemo extends JPanel bar = new JSlider(); bar.setOrientation(JScrollBar.HORIZONTAL); bar.setMinimum(0); - bar.setMaximum(rows); + bar.setMaximum(rows); bar.setBorder(border); - + rendererBar = new JSlider(); rendererBar.setMinimum(0); rendererBar.setMaximum(rows); @@ -199,7 +199,7 @@ public class TableDemo extends JPanel bar.setValue(((Integer) value).intValue()); return bar; } - + /** * Get the renderer. */ @@ -221,13 +221,13 @@ public class TableDemo extends JPanel return new Integer(bar.getValue()); } - } - + } + /** * The table being displayed. */ JTable table = new JTable(); - + /** * The table model. */ @@ -237,26 +237,26 @@ public class TableDemo extends JPanel * The table value array. */ Object[][] values; - + /** * The icons that appear in the icon column. - */ + */ Icon[] icons = new Icon[] - { + { MetalIconFactory.getTreeComputerIcon(), MetalIconFactory.getTreeHardDriveIcon(), MetalIconFactory.getTreeFolderIcon(), }; - + /** * The choices in the combo boxes */ String [] sides = new String[] { - "north", "south", "east", "west" + "north", "south", "east", "west" }; - - + + /** * Create the table demo with the given titel. */ @@ -265,7 +265,7 @@ public class TableDemo extends JPanel super(); createContent(); } - + /** * 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 @@ -276,7 +276,7 @@ public class TableDemo extends JPanel { setLayout(new BorderLayout()); values = new Object[rows][]; - + for (int i = 0; i < values.length; i++) { values[i] = new Object[cols]; @@ -289,44 +289,44 @@ public class TableDemo extends JPanel values [i][2] = sides [ i % sides.length ]; values [i][4] = new Integer(i); } - - table.setModel(model); - + + table.setModel(model); + // Make the columns with gradually increasing width: DefaultTableColumnModel cm = new DefaultTableColumnModel(); table.setColumnModel(cm); - + for (int i = 0; i < cols; i++) { TableColumn column = new TableColumn(i); - + // Showing the variable width columns. int width = 100+10*i; column.setPreferredWidth(width); - + // If we do not set the header value here, the value, returned // by model, is used. column.setHeaderValue("Width +"+(20*i)); - - cm.addColumn(column); + + cm.addColumn(column); } - + setCustomEditors(); setInformativeHeaders(); // Create the table, place it into scroll pane and place // the pane into this frame. JScrollPane scroll = new JScrollPane(); - + // The horizontal scroll bar is never needed. scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scroll.getViewport().add(table); add(scroll, BorderLayout.CENTER); - + // Increase the row height to make the icons and sliders look better. table.setRowHeight(table.getRowHeight()+2); } - + /** * Set the more informative column headers for specific columns. */ @@ -340,7 +340,7 @@ public class TableDemo extends JPanel cm.getColumn(3).setHeaderValue("edit combo"); cm.getColumn(4).setHeaderValue("slider"); } - + /** * Set the custom editors for combo boxes. This method also sets one * custom renderer. @@ -348,31 +348,31 @@ public class TableDemo extends JPanel void setCustomEditors() { TableColumnModel cm = table.getColumnModel(); - + // Set combo-box based editor for icons (note that no custom // renderer is needed for JComboBox to work with icons. JComboBox combo0 = new JComboBox(icons); cm.getColumn(1).setCellEditor(new DefaultCellEditor(combo0)); - + // Set the simple combo box editor for the third column: JComboBox combo1 = new JComboBox(sides); cm.getColumn(2).setCellEditor(new DefaultCellEditor(combo1)); - + // Set the editable combo box for the forth column: JComboBox combo2 = new JComboBox(sides); combo2.setEditable(true); cm.getColumn(3).setCellEditor(new DefaultCellEditor(combo2)); - + SliderCell scrollView = new SliderCell(); cm.getColumn(4).setCellEditor(scrollView); - cm.getColumn(4).setCellRenderer(scrollView); + cm.getColumn(4).setCellRenderer(scrollView); table.setColumnModel(cm); } - + /** * The executable method to display the editable table. - * + * * @param args * unused. */ @@ -408,4 +408,3 @@ public class TableDemo extends JPanel }; } } - diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/TextAreaDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/TextAreaDemo.java index b72997c..5381f7e 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/TextAreaDemo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/TextAreaDemo.java @@ -63,7 +63,7 @@ public class TextAreaDemo /** * 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 @@ -491,7 +491,7 @@ public class TextAreaDemo return DemoHighlightPainter.INSTANCE; } }); - + innerPanel.add(new JScrollPane(textarea16)); panel.add(innerPanel); diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/TextFieldDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/TextFieldDemo.java index ba0fefa..e630228 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/TextFieldDemo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/TextFieldDemo.java @@ -58,7 +58,7 @@ import javax.swing.text.LayeredHighlighter.LayerPainter; /** * A simple textfield demo showing various textfields in different states. */ -public class TextFieldDemo +public class TextFieldDemo extends JPanel implements ActionListener { @@ -118,7 +118,7 @@ public class TextFieldDemo } } } - + static class DemoHighlightPainter extends LayerPainter { @@ -167,14 +167,14 @@ public class TextFieldDemo return bounds; } - + } /** * The left aligned textfields and state buttons. */ Compound compound1; - + /** * The right aligned textfields and state buttons. */ @@ -195,7 +195,7 @@ public class TextFieldDemo * Some miscellaneous textfield demos. */ Compound compound6; - + /** * Some textfields with custom borders. */ @@ -204,20 +204,20 @@ public class TextFieldDemo /** * Creates a new demo instance. */ - public TextFieldDemo() + public TextFieldDemo() { super(); createContent(); } - + /** * When the demo is run independently, the frame is displayed, so we should - * initialise the content panel (including the demo content and a close + * initialise the content panel (including the demo content and a close * button). But when the demo is run as part of the Swing activity board, * only the demo content panel is used, the frame itself is never displayed, * so we can avoid this step. */ - void initFrameContent() + void initFrameContent() { JPanel closePanel = new JPanel(); JButton closeButton = new JButton("Close"); @@ -230,11 +230,11 @@ public class TextFieldDemo /** * 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 + * 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). - */ - private void createContent() + */ + private void createContent() { setLayout(new BorderLayout()); JPanel panel = new JPanel(new GridLayout(7, 1)); @@ -245,13 +245,13 @@ public class TextFieldDemo panel.add(createCustomColorPanel2()); panel.add(createCustomBordersPanel()); panel.add(createMiscPanel()); - + // Put everything in a scroll pane to make it neccessary // to reach the bottom inner panels if the screen is to small. add(new JScrollPane(panel)); } - - private JPanel createLeftAlignedPanel() + + private JPanel createLeftAlignedPanel() { compound1 = createTextFieldCompound("Left aligned", 1); @@ -261,16 +261,16 @@ public class TextFieldDemo new Font("Dialog", Font.ITALIC, 12), new Font("Dialog", Font.BOLD, 14) }); - + return compound1.panel; } - + private Compound createTextFieldCompound(String title, int actionCommandNo) { Compound compound = new Compound(); compound.panel = new JPanel(new BorderLayout()); compound.panel.setBorder(BorderFactory.createTitledBorder(title)); - + compound.textFieldPanel = new JPanel(); compound.textFieldPanel.setLayout(new BoxLayout(compound.textFieldPanel, BoxLayout.X_AXIS)); @@ -295,7 +295,7 @@ public class TextFieldDemo return compound; } - private JPanel createRightAlignedPanel() + private JPanel createRightAlignedPanel() { compound2 = createTextFieldCompound("Right aligned", 2); @@ -305,11 +305,11 @@ public class TextFieldDemo new Font("Dialog", Font.ITALIC, 12), new Font("Dialog", Font.BOLD, 14) }); - + return compound2.panel; } - private JPanel createCenteredPanel() + private JPanel createCenteredPanel() { compound3 = createTextFieldCompound("Centered", 3); @@ -319,7 +319,7 @@ public class TextFieldDemo new Font("Dialog", Font.ITALIC, 12), new Font("Dialog", Font.BOLD, 14) }); - + return compound3.panel; } @@ -339,11 +339,11 @@ public class TextFieldDemo compound4.textfield3.setForeground(Color.RED); compound4.textfield3.setBackground(Color.YELLOW); compound4.textFieldPanel.add(compound4.textfield3); - + return compound4.panel; - + } - + private JPanel createCustomColorPanel2() { compound5 = createTextFieldCompound("Custom colors II", 5); @@ -359,12 +359,12 @@ public class TextFieldDemo compound5.textfield3 = new JTextField("custom selection color"); compound5.textfield3.setSelectionColor(Color.BLACK); compound5.textFieldPanel.add(compound5.textfield3); - + return compound5.panel; - + } - private JPanel createMiscPanel() + private JPanel createMiscPanel() { compound6 = createTextFieldCompound("Miscellaneous", 6); @@ -392,8 +392,8 @@ public class TextFieldDemo return compound6.panel; } - - private JPanel createCustomBordersPanel() + + private JPanel createCustomBordersPanel() { compound7 = createTextFieldCompound("Custom borders", 7); @@ -415,7 +415,7 @@ public class TextFieldDemo return compound7.panel; } - public void actionPerformed(ActionEvent e) + public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("CLOSE")) { @@ -476,7 +476,7 @@ public class TextFieldDemo compound4.textfield1.setEditable(editable); compound4.textfield2.setEditable(editable); compound4.textfield3.setEditable(editable); - } + } else if (e.getActionCommand().equals("ENABLED5")) { boolean enabled = compound5.enabled.isSelected(); @@ -521,7 +521,7 @@ public class TextFieldDemo } } - public static void main(String[] args) + public static void main(String[] args) { SwingUtilities.invokeLater (new Runnable() @@ -557,16 +557,16 @@ public class TextFieldDemo static class Compound { JTextField textfield1; - JTextField textfield2; + JTextField textfield2; JTextField textfield3; JCheckBox enabled; JCheckBox editable; JPanel textFieldPanel; JPanel panel; - + /** Creates and initializes the textfields with the same text and * alignment but with a different font. - * + * * @param title The text for the textfields. * @param align The alignment for the textfields. * @param fonts The fonts to be used for the textfields. @@ -582,13 +582,13 @@ public class TextFieldDemo textfield2.setHorizontalAlignment(align); textfield2.setFont(fonts[1]); textFieldPanel.add(textfield2); - + textfield3 = new JTextField(title); textfield3.setHorizontalAlignment(align); textfield3.setFont(fonts[2]); textFieldPanel.add(textfield3); } - + } - + } diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/TreeDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/TreeDemo.java index 8da3750..f8f7ae6 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/TreeDemo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/TreeDemo.java @@ -72,13 +72,13 @@ public class TreeDemo } private void createContent() - { + { // non-leafs DefaultMutableTreeNode root = new DefaultMutableTreeNode("Exotic Subsistence"); DefaultMutableTreeNode fruit = new DefaultMutableTreeNode("Interesting Fruit"); DefaultMutableTreeNode veg = new DefaultMutableTreeNode("Extraordinary Vegetables"); DefaultMutableTreeNode liq = new DefaultMutableTreeNode("Peculiar Liquids"); - + // leafs DefaultMutableTreeNode f1 = new DefaultMutableTreeNode("Abiu"); DefaultMutableTreeNode f2 = new DefaultMutableTreeNode("Bamboo Shoots"); @@ -88,7 +88,7 @@ public class TreeDemo DefaultMutableTreeNode f6 = new DefaultMutableTreeNode("Guava"); DefaultMutableTreeNode f7 = new DefaultMutableTreeNode("Jakfruit"); DefaultMutableTreeNode f8 = new DefaultMutableTreeNode("Quaribea"); - + DefaultMutableTreeNode v1 = new DefaultMutableTreeNode("Amaranth"); DefaultMutableTreeNode v2 = new DefaultMutableTreeNode("Kiwano"); DefaultMutableTreeNode v3 = new DefaultMutableTreeNode("Leeks"); @@ -96,7 +96,7 @@ public class TreeDemo DefaultMutableTreeNode v5 = new DefaultMutableTreeNode("Chayote"); DefaultMutableTreeNode v6 = new DefaultMutableTreeNode("Jicama"); DefaultMutableTreeNode v7 = new DefaultMutableTreeNode("Okra"); - + DefaultMutableTreeNode l1 = new DefaultMutableTreeNode("Alcoholic"); DefaultMutableTreeNode l11 = new DefaultMutableTreeNode("Caipirinha"); DefaultMutableTreeNode l21 = new DefaultMutableTreeNode("Mojito"); @@ -105,7 +105,7 @@ public class TreeDemo DefaultMutableTreeNode l5 = new DefaultMutableTreeNode("Non Alcoholic"); DefaultMutableTreeNode l55 = new DefaultMutableTreeNode("Babaji"); DefaultMutableTreeNode l65 = new DefaultMutableTreeNode("Chikita"); - + root.add(fruit); root.add(veg); root.add(liq); @@ -140,7 +140,7 @@ public class TreeDemo selModel.setSelectionMode( DefaultTreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); tree.setSelectionModel(selModel); - + // buttons to add and delete JButton add = new JButton("add element"); add.addActionListener(new ActionListener() @@ -155,22 +155,22 @@ public class TreeDemo DefaultMutableTreeNode n = (DefaultMutableTreeNode) p. getLastPathComponent(); n.add(new DefaultMutableTreeNode("New Element")); - + // The expansion state of the parent node does not change // by default. We will expand it manually, to ensure that the // added node is immediately visible. tree.expandPath(p); - + // Refresh the tree (.repaint would be not enough both in // Classpath and Sun implementations). - DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); + DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); model.reload(n); break; } } } }); - + // Demonstration of the various selection modes final JCheckBox cbSingle = new JCheckBox("single selection"); cbSingle.addActionListener(new ActionListener() @@ -185,7 +185,7 @@ public class TreeDemo DefaultTreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); } }); - + // Demonstration of the root visibility changes final JCheckBox cbRoot = new JCheckBox("root"); cbRoot.addActionListener(new ActionListener() @@ -196,7 +196,7 @@ public class TreeDemo } }); cbRoot.setSelected(true); - + // Demonstration of the tree selection listener. final JLabel choice = new JLabel("Make a choice"); tree.getSelectionModel().addTreeSelectionListener( @@ -206,18 +206,18 @@ public class TreeDemo { TreePath was = event.getOldLeadSelectionPath(); TreePath now = event.getNewLeadSelectionPath(); - String swas = + String swas = was == null ? "none":was.getLastPathComponent().toString(); - String snow = + String snow = now == null ? "none":now.getLastPathComponent().toString(); choice.setText("From "+swas+" to "+snow); } } ); - + setLayout(new BorderLayout()); - - JPanel p2 = new JPanel(); + + JPanel p2 = new JPanel(); p2.add(add); p2.add(cbSingle); p2.add(cbRoot); @@ -258,7 +258,7 @@ public class TreeDemo add(choice, BorderLayout.SOUTH); } - public void actionPerformed(ActionEvent e) + public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("CLOSE")) { @@ -268,7 +268,7 @@ public class TreeDemo /** * When the demo is run independently, the frame is displayed, so we should - * initialise the content panel (including the demo content and a close + * initialise the content panel (including the demo content and a close * button). But when the demo is run as part of the Swing activity board, * only the demo content panel is used, the frame itself is never displayed, * so we can avoid this step. |