diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/awt/Button.java | 4 | ||||
-rw-r--r-- | java/awt/Checkbox.java | 4 | ||||
-rw-r--r-- | java/awt/CheckboxMenuItem.java | 26 | ||||
-rw-r--r-- | java/awt/Choice.java | 110 | ||||
-rw-r--r-- | java/awt/Color.java | 121 | ||||
-rw-r--r-- | java/awt/Cursor.java | 250 | ||||
-rw-r--r-- | java/awt/Dialog.java | 51 | ||||
-rw-r--r-- | java/awt/FileDialog.java | 41 | ||||
-rw-r--r-- | java/awt/Font.java | 24 | ||||
-rw-r--r-- | java/awt/FontMetrics.java | 7 | ||||
-rw-r--r-- | java/awt/GridBagConstraints.java | 109 | ||||
-rw-r--r-- | java/awt/Insets.java | 12 | ||||
-rw-r--r-- | java/awt/Label.java | 4 | ||||
-rw-r--r-- | java/awt/List.java | 124 | ||||
-rw-r--r-- | java/awt/Menu.java | 64 | ||||
-rw-r--r-- | java/awt/MenuBar.java | 77 | ||||
-rw-r--r-- | java/awt/MenuComponent.java | 6 | ||||
-rw-r--r-- | java/awt/MenuContainer.java | 6 | ||||
-rw-r--r-- | java/awt/MenuItem.java | 4 | ||||
-rw-r--r-- | java/awt/MenuShortcut.java | 26 | ||||
-rw-r--r-- | java/awt/PaintContext.java | 46 | ||||
-rw-r--r-- | java/awt/Panel.java | 9 | ||||
-rw-r--r-- | java/awt/PopupMenu.java | 9 |
23 files changed, 720 insertions, 414 deletions
diff --git a/java/awt/Button.java b/java/awt/Button.java index 1626047bb..64c55cb5c 100644 --- a/java/awt/Button.java +++ b/java/awt/Button.java @@ -269,8 +269,8 @@ dispatchEventImpl(AWTEvent e) protected String paramString() { - return(getClass().getName() + "(label=" + getLabel() + ",actionCommand=" + - getActionCommand() + ")"); + return ("label=" + getLabel() + ",actionCommand=" + getActionCommand() + + "," + super.paramString()); } } // class Button diff --git a/java/awt/Checkbox.java b/java/awt/Checkbox.java index 60795ae74..a7d12ad5f 100644 --- a/java/awt/Checkbox.java +++ b/java/awt/Checkbox.java @@ -362,8 +362,8 @@ processItemEvent(ItemEvent event) protected String paramString() { - return(getClass().getName() + "[label=" + label + ",state=" + state - + ",group=" + group + "]"); + return ("label=" + label + ",state=" + state + ",group=" + group + + "," + super.paramString()); } } // class Checkbox diff --git a/java/awt/CheckboxMenuItem.java b/java/awt/CheckboxMenuItem.java index 1966058d1..bdede7b85 100644 --- a/java/awt/CheckboxMenuItem.java +++ b/java/awt/CheckboxMenuItem.java @@ -1,5 +1,5 @@ /* CheckboxMenuItem.java -- A menu option with a checkbox on it. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,6 +38,7 @@ import java.awt.event.ItemListener; * the selected state of some option. * * @author Aaron M. Renn (arenn@urbanophile.com) + * @author Tom Tromey <tromey@redhat.com> */ public class CheckboxMenuItem extends MenuItem implements ItemSelectable, java.io.Serializable @@ -139,10 +140,11 @@ public synchronized void setState(boolean state) { this.state = state; - - CheckboxMenuItemPeer cmip = (CheckboxMenuItemPeer)getPeer(); - if (cmip != null) - cmip.setState(state); + if (peer != null) + { + CheckboxMenuItemPeer cp = (CheckboxMenuItemPeer) peer; + cp.setState (state); + } } /*************************************************************************/ @@ -174,8 +176,13 @@ getSelectedObjects() public synchronized void addNotify() { - if (getPeer() == null) - setPeer((MenuComponentPeer)getToolkit().createCheckboxMenuItem(this)); + if (peer != null) + { + // This choice of toolkit seems unsatisfying, but I'm not sure + // what else to do. + peer = getToolkit().createCheckboxMenuItem(this); + } + super.addNotify (); } /*************************************************************************/ @@ -222,6 +229,8 @@ processEvent(AWTEvent event) { if (event instanceof ItemEvent) processItemEvent((ItemEvent)event); + else + super.processEvent(event); } /*************************************************************************/ @@ -248,7 +257,8 @@ processItemEvent(ItemEvent event) public String paramString() { - return(getClass().getName() + "(label=" + getLabel() + ",state=" + state + ")"); + return ("label=" + getLabel() + ",state=" + state + + "," + super.paramString()); } } // class CheckboxMenuItem diff --git a/java/awt/Choice.java b/java/awt/Choice.java index f26a74bc6..68064356d 100644 --- a/java/awt/Choice.java +++ b/java/awt/Choice.java @@ -1,5 +1,5 @@ /* Choice.java -- Java choice button widget. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -63,7 +63,7 @@ private Vector pItems = new Vector(); /** * @serial The index of the selected item in the choice box. */ -private int selectedIndex; +private int selectedIndex = -1; // Listener chain private ItemListener item_listeners; @@ -139,11 +139,20 @@ getItem(int index) public synchronized void add(String item) { + if (item == null) + throw new IllegalArgumentException ("item must be non-null"); + pItems.addElement(item); - ChoicePeer cp = (ChoicePeer)getPeer(); - if (cp != null) - cp.add(item, getItemCount()); + int i = pItems.size () - 1; + if (peer != null) + { + ChoicePeer cp = (ChoicePeer) peer; + cp.add (item, i); + } + + if (i == 0) + select (0); } /*************************************************************************/ @@ -156,29 +165,36 @@ add(String item) public synchronized void addItem(String item) { - pItems.addElement(item); - - ChoicePeer cp = (ChoicePeer)getPeer(); - if (cp != null) - cp.addItem(item, getItemCount()); + add(item); } /*************************************************************************/ -/** - * Inserts the specified item to this choice box at the specified index. - * - * @param item The item to add. - * @param index The index at which the item should be inserted. - */ +/** Inserts an item into this Choice. Existing items are shifted + * upwards. If the new item is the only item, then it is selected. + * If the currently selected item is shifted, then the first item is + * selected. If the currently selected item is not shifted, then it + * remains selected. + * + * @param item The item to add. + * @param index The index at which the item should be inserted. + */ public synchronized void insert(String item, int index) { + if (index > getItemCount ()) + index = getItemCount (); + pItems.insertElementAt(item, index); - ChoicePeer cp = (ChoicePeer)getPeer(); - if (cp != null) - cp.addItem(item, getItemCount()); + if (peer != null) + { + ChoicePeer cp = (ChoicePeer) peer; + cp.add (item, index); + } + + if (getItemCount () == 1 || selectedIndex >= index) + select (0); } /*************************************************************************/ @@ -194,6 +210,9 @@ public synchronized void remove(String item) { int index = pItems.indexOf(item); + if (index == -1) + throw new IllegalArgumentException ("item \"" + + item + "\" not found in Choice"); remove(index); } @@ -211,9 +230,16 @@ remove(int index) { pItems.removeElementAt(index); - ChoicePeer cp = (ChoicePeer)getPeer(); - if (cp != null) - cp.remove(index); + if (peer != null) + { + ChoicePeer cp = (ChoicePeer) peer; + cp.remove (index); + } + + if (index == selectedIndex) + select (0); + else if (selectedIndex > index) + --selectedIndex; } /*************************************************************************/ @@ -226,24 +252,27 @@ removeAll() { int count = getItemCount(); - if (count > 0) - for (int i = 0; i < count; i++) - remove(i); - - pItems = new Vector(); + for (int i = 0; i < count; i++) + { + // Always remove 0. + remove(0); + } } /*************************************************************************/ /** - * Returns the currently selected item. + * Returns the currently selected item, or null if no item is + * selected. * * @return The currently selected item. */ public synchronized String getSelectedItem() { - return((String)pItems.elementAt(selectedIndex)); + return (selectedIndex == -1 + ? null + : ((String)pItems.elementAt(selectedIndex))); } /*************************************************************************/ @@ -256,6 +285,9 @@ getSelectedItem() public synchronized Object[] getSelectedObjects() { + if (selectedIndex == -1) + return null; + Object[] objs = new Object[1]; objs[0] = pItems.elementAt(selectedIndex); @@ -291,10 +323,11 @@ select(int index) throw new IllegalArgumentException("Bad index: " + index); this.selectedIndex = index; - - ChoicePeer cp = (ChoicePeer)getPeer(); - if (cp != null) - cp.select(index); + if (peer != null) + { + ChoicePeer cp = (ChoicePeer) peer; + cp.select (index); + } } /*************************************************************************/ @@ -310,7 +343,8 @@ public synchronized void select(String item) { int index = pItems.indexOf(item); - select(index); + if (index >= 0) + select(index); } /*************************************************************************/ @@ -321,8 +355,9 @@ select(String item) public void addNotify() { - if (getPeer() == null) - setPeer((ComponentPeer)getToolkit().createChoice(this)); + if (peer == null) + peer = getToolkit ().createChoice (this); + super.addNotify (); } /*************************************************************************/ @@ -395,8 +430,7 @@ processItemEvent(ItemEvent event) protected String paramString() { - return(getClass().getName() + "(selectedIndex=" + selectedIndex + ")"); + return ("selectedIndex=" + selectedIndex + "," + super.paramString()); } } // class Choice - diff --git a/java/awt/Color.java b/java/awt/Color.java index ac1cc51e8..52db41c8f 100644 --- a/java/awt/Color.java +++ b/java/awt/Color.java @@ -1,5 +1,5 @@ /* Color.java -- Class representing a color in Java - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -42,67 +42,67 @@ public class Color implements java.io.Serializable /** * Constant for the color white */ -public static final Color white = new Color(255,255,255); +public static final Color white = new Color(255,255,255,255); /** * Constant for the color light gray */ -public static final Color lightGray = new Color(192,192,192); +public static final Color lightGray = new Color(192,192,192,255); /** * Constant for the color gray */ -public static final Color gray = new Color(128,128,128); +public static final Color gray = new Color(128,128,128,255); /** * Constant for the color dark gray */ -public static final Color darkGray = new Color(64,64,64); +public static final Color darkGray = new Color(64,64,64,255); /** * Constant for the color black */ -public static final Color black = new Color(0,0,0); +public static final Color black = new Color(0,0,0,255); /** * Constant for the color red */ -public static final Color red = new Color(255,0,0); +public static final Color red = new Color(255,0,0,255); /** * Constant for the color pink */ -public static final Color pink = new Color(255, 175, 175); +public static final Color pink = new Color(255, 175, 175,255); /** * Constant for the color orange */ -public static final Color orange = new Color(255, 200, 0); +public static final Color orange = new Color(255, 200, 0,255); /** * Constant for the color yellow */ -public static final Color yellow = new Color(255,255,0); +public static final Color yellow = new Color(255,255,0,255); /** * Constant for the color green */ -public static final Color green = new Color(0,255,0); +public static final Color green = new Color(0,255,0,255); /** * Constant for the color magenta */ -public static final Color magenta = new Color(255,0,255); +public static final Color magenta = new Color(255,0,255,255); /** * Constant for the color cyan */ -public static final Color cyan = new Color(0,255,255); +public static final Color cyan = new Color(0,255,255,255); /** * Constant for the color blue */ -public static final Color blue = new Color(0,0,255); +public static final Color blue = new Color(0,0,255,255); // Serialization Constant private static final long serialVersionUID = 118526816881161077L; @@ -111,6 +111,9 @@ private static final long serialVersionUID = 118526816881161077L; private static final int redmask = 255 << 16; private static final int greenmask = 255 << 8; private static final int bluemask = 255; +private static final int alphamask = 255 << 24; + +private static final int BRIGHT_STEP = 0x30; /*************************************************************************/ @@ -121,7 +124,7 @@ private static final int bluemask = 255; /** * @serial The RGB value of the color. */ -private int value; +private int value = 0xFFFFFFFF; /*************************************************************************/ @@ -292,6 +295,16 @@ Color(int red, int green, int blue) value = blue + (green << 8) + (red << 16); } +public +Color(int red, int green, int blue, int alpha) +{ + if ((red < 0) || (red > 255) || (green < 0) || (green > 255) || + (blue < 0) || (blue > 255)) + throw new IllegalArgumentException("Bad RGB values"); + + value = blue + (green << 8) + (red << 16) + (alpha << 24); +} + /*************************************************************************/ /** @@ -307,6 +320,14 @@ Color(int value) this.value = value; } +public +Color(int value, boolean hasalpha) +{ + this.value = value; + if (! hasalpha) + this.value |= 0xFF000000; +} + /*************************************************************************/ /** @@ -382,6 +403,23 @@ getBlue() return(blueval); } +public int +getAlpha() +{ + int alphaval = (value & alphamask); + + return(alphaval); +} + +public int +getTransparency() +{ + if (getAlpha() == 0xFF) + return Transparency.OPAQUE; + else + return Transparency.TRANSLUCENT; +} + /*************************************************************************/ /** @@ -408,22 +446,10 @@ getRGB() public Color brighter() { - int red = getRed(); - int green = getGreen(); - int blue = getBlue(); - - red += 10; - green += 10; - blue += 10; - - if (red > 255) - red = 255; - if (green > 255) - green = 255; - if (blue > 255) - blue = 255; - - return(new Color(red, green, blue)); + return new Color(Math.min(255, getRed() + BRIGHT_STEP), + Math.min(255, getGreen() + BRIGHT_STEP), + Math.min(255, getBlue() + BRIGHT_STEP), + getAlpha()); } /*************************************************************************/ @@ -438,22 +464,10 @@ brighter() public Color darker() { - int red = getRed(); - int green = getGreen(); - int blue = getBlue(); - - red -= 10; - green -= 10; - blue -= 10; - - if (red < 0) - red = 0; - if (green < 0) - green = 0; - if (blue < 0) - blue = 0; - - return(new Color(red, green, blue)); + return new Color(Math.max(0, getRed() - BRIGHT_STEP), + Math.max(0, getGreen() - BRIGHT_STEP), + Math.max(0, getBlue() - BRIGHT_STEP), + getAlpha()); } /*************************************************************************/ @@ -483,22 +497,11 @@ hashCode() public boolean equals(Object obj) { - if (obj == null) - return(false); - if (!(obj instanceof Color)) return(false); Color c = (Color)obj; - - if (c.getRed() != getRed()) - return(false); - if (c.getGreen() != getGreen()) - return(false); - if (c.getBlue() != getBlue()) - return(false); - - return(true); + return value == c.value; } /*************************************************************************/ diff --git a/java/awt/Cursor.java b/java/awt/Cursor.java index 948c412e9..79b1d6c52 100644 --- a/java/awt/Cursor.java +++ b/java/awt/Cursor.java @@ -1,5 +1,4 @@ -/* Cursor.java -- Mouse pointer class - Copyright (C) 1999 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2000, 2002 Free Software Foundation This file is part of GNU Classpath. @@ -34,168 +33,165 @@ package java.awt; */ public class Cursor implements java.io.Serializable { - -/* - * Static Variables - */ - -/** + /** * Constant for the system default cursor type */ -public static final int DEFAULT_CURSOR = 0; + public static final int DEFAULT_CURSOR = 0; -/** + /** * Constant for a cross-hair cursor. */ -public static final int CROSSHAIR_CURSOR = 1; + public static final int CROSSHAIR_CURSOR = 1; -/** + /** * Constant for a cursor over a text field. */ -public static final int TEXT_CURSOR = 2; + public static final int TEXT_CURSOR = 2; -/** + /** * Constant for a cursor to display while waiting for an action to complete. */ -public static final int WAIT_CURSOR = 3; + public static final int WAIT_CURSOR = 3; -/** + /** * Cursor used over SW corner of window decorations. */ -public static final int SW_RESIZE_CURSOR = 4; + public static final int SW_RESIZE_CURSOR = 4; -/** + /** * Cursor used over SE corner of window decorations. */ -public static final int SE_RESIZE_CURSOR = 5; + public static final int SE_RESIZE_CURSOR = 5; -/** + /** * Cursor used over NW corner of window decorations. */ -public static final int NW_RESIZE_CURSOR = 6; + public static final int NW_RESIZE_CURSOR = 6; -/** + /** * Cursor used over NE corner of window decorations. */ -public static final int NE_RESIZE_CURSOR = 7; + public static final int NE_RESIZE_CURSOR = 7; -/** + /** * Cursor used over N edge of window decorations. */ -public static final int N_RESIZE_CURSOR = 8; + public static final int N_RESIZE_CURSOR = 8; -/** + /** * Cursor used over S edge of window decorations. */ -public static final int S_RESIZE_CURSOR = 9; + public static final int S_RESIZE_CURSOR = 9; -/** - * Cursor used over E edge of window decorations. + /** + * Cursor used over W edge of window decorations. */ -public static final int E_RESIZE_CURSOR = 10; + public static final int W_RESIZE_CURSOR = 10; -/** - * Cursor used over W edge of window decorations. + /** + * Cursor used over E edge of window decorations. */ -public static final int W_RESIZE_CURSOR = 11; + public static final int E_RESIZE_CURSOR = 11; -/** + /** * Constant for a hand cursor. */ -public static final int HAND_CURSOR = 12; + public static final int HAND_CURSOR = 12; -/** + /** * Constant for a cursor used during window move operations. */ -public static final int MOVE_CURSOR = 13; - -// Serialization constant -private static final long serialVersionUID = 8028237497568985504L; - -/*************************************************************************/ - -/* - * Instance Variables - */ - -/** - * @serial The numeric id of this cursor. - */ -private int type; - -/*************************************************************************/ - -/* - * Static Methods - */ - -/** - * Returns an instance of the system default cursor type. - * - * @return The system default cursor. - */ -public static Cursor -getDefaultCursor() -{ - return(new Cursor(DEFAULT_CURSOR)); -} - -/*************************************************************************/ - -/** - * Returns an instance of <code>Cursor</code> for one of the specified - * predetermined types. - * - * @param type The type contant from this class. - * - * @return The requested predefined cursor. - * - * @exception IllegalArgumentException If the constant is not one of the - * predefined cursor type constants from this class. - */ -public static Cursor -getPredefinedCursor(int type) throws IllegalArgumentException -{ - if ((type < DEFAULT_CURSOR) || (type > MOVE_CURSOR)) - throw new IllegalArgumentException("Bad predefined cursor type: " + type); - - return(new Cursor(type)); + public static final int MOVE_CURSOR = 13; + + public static final int CUSTOM_CURSOR = 0xFFFFFFFF; + + private static final int PREDEFINED_COUNT = 14; + + protected static Cursor[] predefined = new Cursor[PREDEFINED_COUNT]; + protected String name; + + /** + * @serial The numeric id of this cursor. + */ + int type; + + /** + * Initializes a new instance of <code>Cursor</code> with the specified + * type. + * + * @param type The cursor type. + */ + public Cursor(int type) + { + if (type < 0 || type >= PREDEFINED_COUNT) + throw new IllegalArgumentException ("invalid cursor " + type); + this.type = type; + // FIXME: lookup and set name? + } + + /** This constructor is used internally only. + * Application code should call Toolkit.createCustomCursor(). + */ + protected Cursor(String name) + { + this.name = name; + this.type = CUSTOM_CURSOR; + } + + /** + * Returns an instance of <code>Cursor</code> for one of the specified + * predetermined types. + * + * @param type The type contant from this class. + * + * @return The requested predefined cursor. + * + * @exception IllegalArgumentException If the constant is not one of the + * predefined cursor type constants from this class. + */ + public static Cursor getPredefinedCursor(int type) + { + if (type < 0 || type >= PREDEFINED_COUNT) + throw new IllegalArgumentException ("invalid cursor " + type); + if (predefined[type] == null) + predefined[type] = new Cursor(type); + return predefined[type]; + } + + public static Cursor getSystemCustomCursor(String name) + throws AWTException + { + // FIXME + return null; + } + + /** + * Returns an instance of the system default cursor type. + * + * @return The system default cursor. + */ + public static Cursor getDefaultCursor() + { + return getPredefinedCursor(DEFAULT_CURSOR); + } + + /** + * Returns the numeric type identifier for this cursor. + * + * @return The cursor id. + */ + public int getType() + { + return type; + } + + public String getName() + { + return name; + } + + public String toString() + { + return (this.getClass() + "[" + getName() + "]"); + } } - -/*************************************************************************/ - -/* - * Constructors - */ - -/** - * Initializes a new instance of <code>Cursor</code> with the specified - * type. - * - * @param type The cursor type. - */ -public -Cursor(int type) -{ - this.type = type; -} - -/*************************************************************************/ - -/** - * Instance Variables - */ - -/** - * Returns the numeric type identifier for this cursor. - * - * @return The cursor id. - */ -public int -getType() -{ - return(type); -} - -} // class Cursor - diff --git a/java/awt/Dialog.java b/java/awt/Dialog.java index f38105a7f..5469d8de9 100644 --- a/java/awt/Dialog.java +++ b/java/awt/Dialog.java @@ -1,5 +1,5 @@ /* Dialog.java -- An AWT dialog box - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -36,6 +36,7 @@ import java.awt.peer.ComponentPeer; * A dialog box widget class. * * @author Aaron M. Renn (arenn@urbanophile.com) + * @author Tom Tromey <tromey@redhat.com> */ public class Dialog extends Window implements java.io.Serializable { @@ -142,6 +143,27 @@ Dialog(Frame parent, String title, boolean modal) setLayout(new BorderLayout()); } +public +Dialog (Dialog owner) +{ + this (owner, "", false); +} + +public +Dialog (Dialog owner, String title) +{ + this (owner, title, false); +} + +public +Dialog (Dialog owner, String title, boolean modal) +{ + super (owner); + this.modal = modal; + this.title = title; + setLayout (new BorderLayout ()); +} + /*************************************************************************/ /* @@ -170,10 +192,11 @@ public synchronized void setTitle(String title) { this.title = title; - - DialogPeer dp = (DialogPeer)getPeer(); - if (dp != null) - dp.setTitle(title); + if (peer != null) + { + DialogPeer d = (DialogPeer) peer; + d.setTitle (title); + } } /*************************************************************************/ @@ -231,10 +254,11 @@ public synchronized void setResizable(boolean resizable) { this.resizable = resizable; - - DialogPeer dp = (DialogPeer)getPeer(); - if (dp != null) - dp.setResizable(resizable); + if (peer != null) + { + DialogPeer d = (DialogPeer) peer; + d.setResizable (resizable); + } } /*************************************************************************/ @@ -245,8 +269,9 @@ setResizable(boolean resizable) public synchronized void addNotify() { - if (getPeer() == null) - setPeer((ComponentPeer)getToolkit().createDialog(this)); + if (peer == null) + peer = getToolkit ().createDialog (this); + super.addNotify (); } /*************************************************************************/ @@ -270,8 +295,8 @@ show() protected String paramString() { - return(getClass().getName() + "(title+" + title + ",modal=" + modal + - ",resizable=" + resizable + ")"); + return ("title+" + title + ",modal=" + modal + + ",resizable=" + resizable + "," + super.paramString()); } } // class Dialog diff --git a/java/awt/FileDialog.java b/java/awt/FileDialog.java index a32e7a6b4..247ee596d 100644 --- a/java/awt/FileDialog.java +++ b/java/awt/FileDialog.java @@ -1,5 +1,5 @@ /* FileDialog.java -- A filename selection dialog box - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,6 +38,7 @@ import java.io.FilenameFilter; * This class implements a file selection dialog box widget. * * @author Aaron M. Renn (arenn@urbanophile.com) + * @author Tom Tromey <tromey@redhat.com> */ public class FileDialog extends Dialog implements java.io.Serializable { @@ -202,10 +203,11 @@ public synchronized void setDirectory(String dir) { this.dir = dir; - - FileDialogPeer fdp = (FileDialogPeer)getPeer(); - if (fdp != null) - fdp.setDirectory(dir); + if (peer != null) + { + FileDialogPeer f = (FileDialogPeer) peer; + f.setDirectory (dir); + } } /*************************************************************************/ @@ -232,10 +234,11 @@ public synchronized void setFile(String file) { this.file = file; - - FileDialogPeer fdp = (FileDialogPeer)getPeer(); - if (fdp != null) - fdp.setFile(file); + if (peer != null) + { + FileDialogPeer f = (FileDialogPeer) peer; + f.setFile (file); + } } /*************************************************************************/ @@ -262,10 +265,11 @@ public synchronized void setFilenameFilter(FilenameFilter filter) { this.filter = filter; - - FileDialogPeer fdp = (FileDialogPeer)getPeer(); - if (fdp != null) - fdp.setFilenameFilter(filter); + if (peer != null) + { + FileDialogPeer f = (FileDialogPeer) peer; + f.setFilenameFilter (filter); + } } /*************************************************************************/ @@ -276,10 +280,9 @@ setFilenameFilter(FilenameFilter filter) public void addNotify() { - if (getPeer() != null) - return; - - setPeer((ComponentPeer)getToolkit().createFileDialog(this)); + if (peer == null) + peer = getToolkit ().createFileDialog (this); + super.addNotify (); } /*************************************************************************/ @@ -292,8 +295,8 @@ addNotify() protected String paramString() { - return(getClass().getName() + "(dir=" + dir + ",file=" + file + - ",mode=" + mode + ")"); + return ("dir=" + dir + ",file=" + file + + ",mode=" + mode + "," + super.paramString()); } } // class FileDialog diff --git a/java/awt/Font.java b/java/awt/Font.java index c9b2c8e8c..266a358e3 100644 --- a/java/awt/Font.java +++ b/java/awt/Font.java @@ -1,5 +1,5 @@ /* Font.java -- Font object - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -34,6 +34,7 @@ import java.util.StringTokenizer; * This class represents a windowing system font. * * @author Aaron M. Renn (arenn@urbanophile.com) + * @author Warren Levy <warrenl@cygnus.com> */ public class Font implements java.io.Serializable { @@ -57,6 +58,10 @@ public static final int BOLD = 1; */ public static final int ITALIC = 2; +public static final int ROMAN_BASELINE = 0; +public static final int CENTER_BASELINE = 1; +public static final int HANGING_BASELINE = 2; + // Serialization constant private static final long serialVersionUID = -4206021311591459213L; @@ -82,6 +87,8 @@ protected int style; */ protected int size; +protected float pointSize; + // The native peer for this font private FontPeer peer; @@ -204,12 +211,13 @@ getFont(String propname) * @param style The font style. * @param size The font point size. */ -public +public Font(String name, int style, int size) { this.name = name; this.style = style; this.size = size; + this.pointSize = size; } /*************************************************************************/ @@ -242,6 +250,12 @@ getSize() return(size); } +public float +getSize2D() +{ + return pointSize; +} + /*************************************************************************/ /** @@ -308,6 +322,12 @@ getFamily() return(name); } +public int +getStyle() +{ + return style; +} + /*************************************************************************/ /** diff --git a/java/awt/FontMetrics.java b/java/awt/FontMetrics.java index 90d175ece..890ffd164 100644 --- a/java/awt/FontMetrics.java +++ b/java/awt/FontMetrics.java @@ -1,5 +1,5 @@ /* FontMetrics.java -- Information about about a fonts display characteristics - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -214,7 +214,7 @@ getMaxDecent() public int getMaxAdvance() { - return(1); + return(-1); } /*************************************************************************/ @@ -330,7 +330,8 @@ getWidths() public String toString() { - return(getClass().getName() + "(font=" + font.getName() + ")"); + return (this.getClass() + "[font=" + font + ",ascent=" + getAscent() + + ",descent=" + getDescent() + ",height=" + getHeight() + "]"); } } // class FontMetrics diff --git a/java/awt/GridBagConstraints.java b/java/awt/GridBagConstraints.java new file mode 100644 index 000000000..27e66587e --- /dev/null +++ b/java/awt/GridBagConstraints.java @@ -0,0 +1,109 @@ +// GridBagConstraints.java - Constraints for GridBag layout manager + +/* Copyright (C) 2000, 2001 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package java.awt; + +import java.io.Serializable; + +/** This specifies the constraints for a component managed by the + * GridBagLayout layout manager. */ +public class GridBagConstraints implements Cloneable, Serializable +{ + /** Fill in both directions. */ + public static final int BOTH = 1; + /** Don't fill. */ + public static final int NONE = 0; + /** Fill horizontally. */ + public static final int HORIZONTAL = 2; + /** Fill vertically. */ + public static final int VERTICAL = 3; + + /** Position in the center. */ + public static final int CENTER = 10; + /** Position to the east. */ + public static final int EAST = 13; + /** Position to the north. */ + public static final int NORTH = 11; + /** Position to the northeast. */ + public static final int NORTHEAST = 12; + /** Position to the northwest. */ + public static final int NORTHWEST = 18; + /** Position to the south. */ + public static final int SOUTH = 15; + /** Position to the southeast. */ + public static final int SOUTHEAST = 14; + /** Position to the southwest. */ + public static final int SOUTHWEST = 16; + /** Position to the west. */ + public static final int WEST = 17; + + /** Occupy all remaining cells except last cell. */ + public static final int RELATIVE = -1; + /** Occupy all remaining cells. */ + public static final int REMAINDER = 0; + + public int anchor; + public int fill; + public int gridheight; + public int gridwidth; + public int gridx; + public int gridy; + public Insets insets; + public int ipadx; + public int ipady; + public double weightx; + public double weighty; + + /** Create a copy of this object. */ + public Object clone () + { + GridBagConstraints g = (GridBagConstraints) super.clone (); + g.insets = (Insets) insets.clone (); + return g; + } + + /** Create a new GridBagConstraints object with the default + * parameters. */ + public GridBagConstraints () + { + this.anchor = CENTER; + this.fill = NONE; + this.gridx = RELATIVE; + this.gridy = RELATIVE; + this.gridwidth = 1; + this.gridheight = 1; + this.ipadx = 0; + this.ipady = 0; + this.insets = new Insets (0, 0, 0, 0); + this.weightx = 0; + this.weighty = 0; + } + + /** Create a new GridBagConstraints object with the indicated + * parameters. */ + public GridBagConstraints (int gridx, int gridy, + int gridwidth, int gridheight, + double weightx, double weighty, + int anchor, int fill, + Insets insets, int ipadx, int ipady) + { + this.anchor = anchor; + this.fill = fill; + this.gridx = gridx; + this.gridy = gridy; + this.gridwidth = gridwidth; + this.gridheight = gridheight; + this.ipadx = ipadx; + this.ipady = ipady; + this.insets = insets; + this.weightx = weightx; + this.weighty = weighty; + } +} diff --git a/java/awt/Insets.java b/java/awt/Insets.java index 4fdef89aa..20857d560 100644 --- a/java/awt/Insets.java +++ b/java/awt/Insets.java @@ -1,5 +1,5 @@ /* Insets.java -- Information about a container border. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -103,9 +103,6 @@ Insets(int top, int left, int bottom, int right) public boolean equals(Object obj) { - if (obj == null) - return(false); - if (!(obj instanceof Insets)) return(false); @@ -123,6 +120,12 @@ equals(Object obj) return(true); } +public int +hashCode() +{ + return top + bottom + left + right; +} + /*************************************************************************/ /** @@ -158,4 +161,3 @@ clone() } } // class Insets - diff --git a/java/awt/Label.java b/java/awt/Label.java index 637348a33..3f972aa29 100644 --- a/java/awt/Label.java +++ b/java/awt/Label.java @@ -225,8 +225,8 @@ addNotify() protected String paramString() { - return(getClass().getName() + "(text=" + getText() + ",alignment=" + - getAlignment() + ")"); + return ("text=" + getText() + ",alignment=" + + getAlignment() + "," + super.paramString()); } } // class Label diff --git a/java/awt/List.java b/java/awt/List.java index ac8d21552..c4fa0aa87 100644 --- a/java/awt/List.java +++ b/java/awt/List.java @@ -1,5 +1,5 @@ /* List.java -- A listbox widget - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -106,7 +106,7 @@ private ActionListener action_listeners; public List() { - this(0, false); + this(4, false); } /*************************************************************************/ @@ -261,10 +261,11 @@ public void setMultipleMode(boolean multipleMode) { this.multipleMode = multipleMode; - - ListPeer lp = (ListPeer)getPeer(); - if (lp != null) - lp.setMultipleMode(multipleMode); + if (peer != null) + { + ListPeer l = (ListPeer) peer; + l.setMultipleMode (multipleMode); + } } /*************************************************************************/ @@ -428,7 +429,7 @@ preferredSize(int rows) public void add(String item) { - addItem(item, -1); + add(item, -1); } /*************************************************************************/ @@ -437,6 +438,8 @@ add(String item) * This method adds the specified item to the end of the list. * * @param item The item to add to the list. + * + * @deprecated Use add() instead. */ public void addItem(String item) @@ -458,7 +461,16 @@ addItem(String item) public void add(String item, int index) { - addItem(item, index); + if ((index == -1) || (index >= items.size())) + items.addElement(item); + else + items.insertElementAt(item, index); + + if (peer != null) + { + ListPeer l = (ListPeer) peer; + l.add (item, index); + } } /*************************************************************************/ @@ -471,18 +483,13 @@ add(String item, int index) * @param item The item to add to the list. * @param index The location in the list to add the item, or -1 to add * to the end. + * + * @deprecated Use add() instead. */ public void addItem(String item, int index) { - if ((index == -1) || (index >= items.size())) - items.addElement(item); - else - items.insertElementAt(item, index); - - ListPeer lp = (ListPeer)getPeer(); - if (lp != null) - lp.add(item, index); + add(item, index); } /*************************************************************************/ @@ -497,7 +504,7 @@ addItem(String item, int index) public void delItem(int index) throws IllegalArgumentException { - delItems(index, index); + remove(index); } /*************************************************************************/ @@ -512,7 +519,12 @@ delItem(int index) throws IllegalArgumentException public void remove(int index) throws IllegalArgumentException { - delItems(index, index); + items.removeElementAt (index); + if (peer != null) + { + ListPeer l = (ListPeer) peer; + l.delItems (index, index); + } } /*************************************************************************/ @@ -539,12 +551,14 @@ delItems(int start, int end) throws IllegalArgumentException if (start > end) throw new IllegalArgumentException("Start is greater than end!"); - for (int i = start; i <= end; i++) - items.removeElementAt(i); - - ListPeer lp = (ListPeer)getPeer(); - if (lp != null) - lp.delItems(start, end); + // We must run the loop in reverse direction. + for (int i = end; i >= start; --i) + items.removeElementAt (i); + if (peer != null) + { + ListPeer l = (ListPeer) peer; + l.delItems (start, end); + } } /*************************************************************************/ @@ -563,7 +577,7 @@ remove(String item) throws IllegalArgumentException if (index == -1) throw new IllegalArgumentException("List element to delete not found"); - delItem(index); + remove(index); } /*************************************************************************/ @@ -574,11 +588,12 @@ remove(String item) throws IllegalArgumentException public synchronized void removeAll() { - items = new Vector(); - - ListPeer lp = (ListPeer)getPeer(); - if (lp != null) - lp.removeAll(); + items.clear(); + if (peer != null) + { + ListPeer l = (ListPeer) peer; + l.removeAll (); + } } /*************************************************************************/ @@ -607,7 +622,7 @@ clear() public synchronized void replaceItem(String item, int index) throws IllegalArgumentException { - delItem(index); + remove(index); addItem(item, index); } @@ -622,17 +637,15 @@ replaceItem(String item, int index) throws IllegalArgumentException public synchronized int getSelectedIndex() { - ListPeer lp = (ListPeer)getPeer(); - if (lp == null) - return(-1); - - int[] idxs = lp.getSelectedIndexes(); - if (idxs == null) - return(-1); - if (idxs.length > 1) - return(-1); + if (peer != null) + { + ListPeer l = (ListPeer) peer; + selected = l.getSelectedIndexes (); + } - return(idxs[0]); + if (selected == null || selected.length > 1) + return -1; + return selected[0]; } /*************************************************************************/ @@ -646,11 +659,12 @@ getSelectedIndex() public synchronized int[] getSelectedIndexes() { - ListPeer lp = (ListPeer)getPeer(); - if (lp == null) - return(new int[0]); - - return(lp.getSelectedIndexes()); + if (peer != null) + { + ListPeer l = (ListPeer) peer; + selected = l.getSelectedIndexes (); + } + return selected; } /*************************************************************************/ @@ -731,8 +745,6 @@ public boolean isIndexSelected(int index) { int[] indexes = getSelectedIndexes(); - if (indexes.length == 0) - return(false); for (int i = 0; i < indexes.length; i++) if (indexes[i] == index) @@ -775,10 +787,11 @@ makeVisible(int index) throws IllegalArgumentException throw new IllegalArgumentException("Bad list index: " + index); visibleIndex = index; - - ListPeer lp = (ListPeer)getPeer(); - if (lp != null) - lp.makeVisible(index); + if (peer != null) + { + ListPeer l = (ListPeer) peer; + l.makeVisible (index); + } } /*************************************************************************/ @@ -834,7 +847,9 @@ deselect(int index) public void addNotify() { - setPeer((ComponentPeer)getToolkit().createList(this)); + if (peer != null) + peer = getToolkit ().createList (this); + super.addNotify (); } /*************************************************************************/ @@ -973,8 +988,7 @@ processItemEvent(ItemEvent event) protected String paramString() { - return(getClass().getName()); + return "multiple=" + multipleMode + ",rows=" + rows + super.paramString(); } } // class List - diff --git a/java/awt/Menu.java b/java/awt/Menu.java index c0c276296..ab73a233a 100644 --- a/java/awt/Menu.java +++ b/java/awt/Menu.java @@ -1,5 +1,5 @@ /* Menu.java -- A Java AWT Menu - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -70,6 +70,11 @@ private boolean isTearOff; */ private boolean isHelpMenu; +// From the serialization spec. FIXME: what should it be? +private int menuSerializedDataVersion; + +static final MenuItem separator = new MenuItem("-"); + /*************************************************************************/ /* @@ -194,15 +199,20 @@ getItem(int index) public MenuItem add(MenuItem item) { - // FIXME: How do I remove from previous menu's? - items.addElement(item); - - MenuPeer mp = (MenuPeer)getPeer(); - if (mp != null) - mp.addItem(item); - - return(item); + if (item.parent != null) + { + item.parent.remove(item); + } + item.parent = this; + + if (peer != null) + { + MenuPeer mp = (MenuPeer) peer; + mp.addItem(item); + } + + return item; } /*************************************************************************/ @@ -240,6 +250,7 @@ insert(MenuItem item, int index) items.insertElementAt(item, index); MenuPeer mp = (MenuPeer)getPeer(); + // FIXME: Need to add a peer method here. // if (mp != null) // mp.insertItem(item, index); } @@ -269,10 +280,7 @@ insert(String label, int index) public void addSeparator() { - // FIXME: How do we note in the items array what this is? - MenuPeer mp = (MenuPeer)getPeer(); - if (mp != null) - mp.addSeparator(); + add(separator); } /*************************************************************************/ @@ -290,13 +298,7 @@ addSeparator() public void insertSeparator(int index) { - if (index < 0) - throw new IllegalArgumentException("Index is less than zero"); - - // FIXME: How do we note in the items array what this is? -// MenuPeer mp = (MenuPeer)getPeer(); -// if (mp != null) -// mp.insertSeparator(index); + insert(separator, index); } /*************************************************************************/ @@ -345,9 +347,11 @@ public synchronized void removeAll() { int count = getItemCount(); - if (count > 0) - for(int i = 0; i < count; i++) - remove(i); + for(int i = 0; i < count; i++) + { + // We must always remove item 0. + remove(0); + } } /*************************************************************************/ @@ -358,10 +362,9 @@ removeAll() public void addNotify() { - if (getPeer() != null) - return; - - setPeer((MenuComponentPeer)getToolkit().createMenu(this)); + if (peer != null) + peer = getToolkit().createMenu(this); + super.addNotify (); } /*************************************************************************/ @@ -385,8 +388,11 @@ removeNotify() public String paramString() { - return(getClass().getName() + "(label=" + getLabel() + ")"); + return (",isTearOff=" + isTearOff + ",isHelpMenu=" + isHelpMenu + + super.paramString()); } -} // class Menu +// Accessibility API not yet implemented. +// public AccessibleContext getAccessibleContext() +} // class Menu diff --git a/java/awt/MenuBar.java b/java/awt/MenuBar.java index fd245ef82..7ad688b65 100644 --- a/java/awt/MenuBar.java +++ b/java/awt/MenuBar.java @@ -1,5 +1,5 @@ /* MenuBar.java -- An AWT menu bar class - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,8 +38,10 @@ import java.util.Vector; * This class implements a menu bar in the AWT system. * * @author Aaron M. Renn (arenn@urbanophile.com) + * @author Tom Tromey <tromey@redhat.com> */ -public class MenuBar extends MenuComponent implements MenuContainer, Serializable +public class MenuBar extends MenuComponent + implements MenuContainer, Serializable { /* @@ -104,33 +106,51 @@ getHelpMenu() * @param helpMenu The new help menu for this menu bar. */ public synchronized void -setHelpMenu(Menu helpMenu) +setHelpMenu(Menu menu) { - // FIXME: Does this need to be added to the vector of items? - this.helpMenu = helpMenu; + if (helpMenu != null) + { + helpMenu.removeNotify (); + helpMenu.parent = null; + } - MenuBarPeer mbp = (MenuBarPeer)getPeer(); - if (mbp != null) - mbp.addHelpMenu(helpMenu); + if (menu.parent != null) + menu.parent.remove (menu); + if (menu.parent != null) + menu.parent.remove (menu); + menu.parent = this; + + if (peer != null) + { + MenuBarPeer mp = (MenuBarPeer) peer; + mp.addHelpMenu (menu); + } } /*************************************************************************/ -/** - * Adds the specified menu to this menu bar. - * - * @param menu The menu to add. - * - * @return The menu that was added. - */ +/** Add a menu to this MenuBar. If the menu has already has a + * parent, it is first removed from its old parent before being + * added. + * + * @param menu The menu to add. + * + * @return The menu that was added. + */ public synchronized Menu add(Menu menu) { + if (menu.parent != null) + menu.parent.remove (menu); + + menu.parent = this; menus.addElement(menu); - MenuBarPeer mbp = (MenuBarPeer)getPeer(); - if (mbp != null) - mbp.addMenu(menu); + if (peer != null) + { + MenuBarPeer mp = (MenuBarPeer) peer; + mp.addMenu (menu); + } return(menu); } @@ -145,11 +165,16 @@ add(Menu menu) public synchronized void remove(int index) { - menus.removeElementAt(index); + Menu m = (Menu) menus.get (index); + menus.remove (index); + m.removeNotify (); + m.parent = null; - MenuBarPeer mbp = (MenuBarPeer)getPeer(); - if (mbp != null) - mbp.delMenu(index); + if (peer != null) + { + MenuBarPeer mp = (MenuBarPeer) peer; + mp.delMenu (index); + } } /*************************************************************************/ @@ -295,10 +320,10 @@ getShortcutMenuItem(MenuShortcut shortcut) public void deleteShortcut(MenuShortcut shortcut) { - MenuItem mi = getShortcutMenuItem(shortcut); - if (mi != null) - mi.setShortcut(null); + MenuItem it; + // This is a slow implementation, but it probably doesn't matter. + while ((it = getShortcutMenuItem (shortcut)) != null) + it.deleteShortcut (); } } // class MenuBar - diff --git a/java/awt/MenuComponent.java b/java/awt/MenuComponent.java index 41a085ffb..d856b7592 100644 --- a/java/awt/MenuComponent.java +++ b/java/awt/MenuComponent.java @@ -221,7 +221,7 @@ getToolkit() * * @return The synchronization lock for this component. */ -public final Object +protected final Object getTreeLock() { return(tree_lock); @@ -292,7 +292,7 @@ processEvent(AWTEvent event) public String toString() { - return(getClass().getName() + "(" + getName() + ")"); + return this.getClass().getName() + "[" + paramString() + "]"; } /*************************************************************************/ @@ -303,7 +303,7 @@ toString() protected String paramString() { - return(toString()); + return "name=" + getName(); } // Accessibility API not yet implemented. diff --git a/java/awt/MenuContainer.java b/java/awt/MenuContainer.java index 4f53848ef..09fe0f046 100644 --- a/java/awt/MenuContainer.java +++ b/java/awt/MenuContainer.java @@ -1,5 +1,5 @@ /* MenuContainer.java -- Container for menu items. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -62,10 +62,8 @@ remove(MenuComponent component); * @param event The event to dispatch. * * @deprecated - + */ public abstract boolean postEvent(Event event); -*/ } // interface MenuContainer - diff --git a/java/awt/MenuItem.java b/java/awt/MenuItem.java index 538dbcfe1..742b23d43 100644 --- a/java/awt/MenuItem.java +++ b/java/awt/MenuItem.java @@ -437,8 +437,8 @@ processActionEvent(ActionEvent event) public String paramString() { - return(getClass().getName() + "(label+" + label + ",enabled=" + enabled + - ",actionCommand=" + actionCommand + ")"); + return ("label=" + label + ",enabled=" + enabled + + ",actionCommand=" + actionCommand + "," + super.paramString()); } // Accessibility API not yet implemented. diff --git a/java/awt/MenuShortcut.java b/java/awt/MenuShortcut.java index 5a2c8548a..c79635d30 100644 --- a/java/awt/MenuShortcut.java +++ b/java/awt/MenuShortcut.java @@ -1,5 +1,5 @@ /* MenuShortcut.java -- A class for menu accelerators - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -149,6 +149,17 @@ equals(MenuShortcut obj) return(true); } +public boolean +equals(Object obj) +{ + if (obj instanceof MenuShortcut) + { + MenuShortcut ms = (MenuShortcut) obj; + return (ms.key == key && ms.usesShift == usesShift); + } + return false; +} + /*************************************************************************/ /** @@ -159,8 +170,14 @@ equals(MenuShortcut obj) public String toString() { - return(getClass().getName() + "(key=" + key + ",usesShift=" + usesShift + - ")"); + return(getClass().getName() + "[" + paramString () + "]"); +} + +public int +hashCode() +{ + // Arbitrary. + return key + (usesShift ? 23 : 57); } /*************************************************************************/ @@ -173,8 +190,7 @@ toString() protected String paramString() { - return(toString()); + return "key=" + key + ",usesShift=" + usesShift; } } // class MenuShortcut - diff --git a/java/awt/PaintContext.java b/java/awt/PaintContext.java new file mode 100644 index 000000000..203772002 --- /dev/null +++ b/java/awt/PaintContext.java @@ -0,0 +1,46 @@ +/* Copyright (C) 2000, 2002 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package java.awt; + +/** + * @author Warren Levy <warrenl@cygnus.com> + * @date March 16, 2000. + */ + +/** + * Written using on-line Java Platform 1.2 API Specification, as well + * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). + * Status: Partially stubbed. + */ + +public interface PaintContext +{ + public void dispose(); + // FIXME + // public ColorModel getColorModel(); + // public Raster getRaster(int x, int y, int w, int h); +} diff --git a/java/awt/Panel.java b/java/awt/Panel.java index f544aa3b1..47b0b95d9 100644 --- a/java/awt/Panel.java +++ b/java/awt/Panel.java @@ -1,5 +1,5 @@ /* Panel.java -- Simple container object. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -79,10 +79,9 @@ Panel(LayoutManager layoutManager) public void addNotify() { - if (getPeer() != null) - return; - - setPeer((ComponentPeer)getToolkit().createPanel(this)); + if (peer == null) + peer = getToolkit().createPanel(this); + super.addNotify(); } } // class Panel diff --git a/java/awt/PopupMenu.java b/java/awt/PopupMenu.java index 17f27cba6..7ec2ad515 100644 --- a/java/awt/PopupMenu.java +++ b/java/awt/PopupMenu.java @@ -1,5 +1,5 @@ /* PopupMenu.java -- An AWT popup menu - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -86,10 +86,9 @@ PopupMenu(String label) public void addNotify() { - if (getPeer() != null) - return; - - setPeer((MenuComponentPeer)getToolkit().createPopupMenu(this)); + if (peer != null) + peer = getToolkit ().createPopupMenu (this); + super.addNotify (); } /*************************************************************************/ |