summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames E. Blair <corvus@gnu.org>1999-01-31 04:37:44 +0000
committerJames E. Blair <corvus@gnu.org>1999-01-31 04:37:44 +0000
commit1b578bdf8f8fee828401646c366065fa544abdf7 (patch)
tree24dc5d11cda4358e2752bbeb4add7b02eed0a63a
parent22777ab47ec8641d333a5caf38d75661e8bdefd2 (diff)
downloadclasspath-1b578bdf8f8fee828401646c366065fa544abdf7.tar.gz
Cleaned up code. Resurrected syncAttrs() as syncAttributes(). All Peer
constructors now call syncAttributes() except top level windows. Moved visibility and size setting into syncAttributes() where applicable. TestAWT is now maintainable. Maybe.
-rw-r--r--gnu/java/awt/peer/gtk/GtkButtonPeer.java11
-rw-r--r--gnu/java/awt/peer/gtk/GtkCanvasPeer.java6
-rw-r--r--gnu/java/awt/peer/gtk/GtkCheckboxPeer.java14
-rw-r--r--gnu/java/awt/peer/gtk/GtkChoicePeer.java8
-rw-r--r--gnu/java/awt/peer/gtk/GtkComponentPeer.java273
-rw-r--r--gnu/java/awt/peer/gtk/GtkDialogPeer.java36
-rw-r--r--gnu/java/awt/peer/gtk/GtkFileDialogPeer.java43
-rw-r--r--gnu/java/awt/peer/gtk/GtkLabelPeer.java7
-rw-r--r--gnu/java/awt/peer/gtk/GtkListPeer.java118
-rw-r--r--gnu/java/awt/peer/gtk/GtkMainThread.java44
-rw-r--r--gnu/java/awt/peer/gtk/GtkPanelPeer.java12
-rw-r--r--gnu/java/awt/peer/gtk/GtkScrollPanePeer.java107
-rw-r--r--gnu/java/awt/peer/gtk/GtkScrollbarPeer.java6
-rw-r--r--gnu/java/awt/peer/gtk/GtkTextAreaPeer.java136
-rw-r--r--gnu/java/awt/peer/gtk/GtkTextFieldPeer.java83
-rw-r--r--gnu/java/awt/peer/gtk/TestAWT.java844
16 files changed, 804 insertions, 944 deletions
diff --git a/gnu/java/awt/peer/gtk/GtkButtonPeer.java b/gnu/java/awt/peer/gtk/GtkButtonPeer.java
index 0e2e8624b..4cc6e5569 100644
--- a/gnu/java/awt/peer/gtk/GtkButtonPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkButtonPeer.java
@@ -28,20 +28,18 @@ import java.awt.peer.*;
public class GtkButtonPeer extends GtkComponentPeer
implements ButtonPeer
{
- native void gtkButtonNewWithLabel (ComponentPeer parent,
- String label, boolean visible);
+ native void gtkButtonNewWithLabel (ComponentPeer parent, String label);
native void gtkButtonLabelSet (String label);
public GtkButtonPeer (Button b, ComponentPeer cp)
{
super (b);
- gtkButtonNewWithLabel (cp, b.getLabel(), b.isVisible());
- System.out.println ("buttonpeer <init>");
+ gtkButtonNewWithLabel (cp, b.getLabel());
+ syncAttributes ();
}
public void setLabel (String label)
{
- System.out.println ("java setlabel");
gtkButtonLabelSet (label);
}
@@ -68,3 +66,6 @@ public class GtkButtonPeer extends GtkComponentPeer
super.handleEvent (e);
}
}
+
+
+
diff --git a/gnu/java/awt/peer/gtk/GtkCanvasPeer.java b/gnu/java/awt/peer/gtk/GtkCanvasPeer.java
index 2dc30093b..c5605d5b9 100644
--- a/gnu/java/awt/peer/gtk/GtkCanvasPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkCanvasPeer.java
@@ -6,16 +6,16 @@ import java.awt.peer.*;
public class GtkCanvasPeer extends GtkComponentPeer implements CanvasPeer
{
native void gtkCanvasNew (ComponentPeer parent,
- int width, int height, boolean visible);
+ int width, int height);
public GtkCanvasPeer (Canvas c, ComponentPeer cp)
{
super (c);
Dimension d = c.getSize();
- gtkCanvasNew (cp, d.width, d.height, c.isVisible ());
+ gtkCanvasNew (cp, d.width, d.height);
Point p = c.getLocation ();
- System.out.println ("canvaspeer: location: "+p.x+","+p.y);
+ syncAttributes ();
}
public Graphics getGraphics ()
diff --git a/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java b/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
index 778aeedc6..0656c0b7c 100644
--- a/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
@@ -29,28 +29,24 @@ public class GtkCheckboxPeer extends GtkComponentPeer
native void gtkRadioButtonSetGroup (Object group);
native void gtkRadioButtonNew (ComponentPeer parent,
- Object group, boolean checked, String label,
- boolean visible);
+ Object group, boolean checked, String label);
native void gtkCheckButtonNew (ComponentPeer parent,
- boolean checked, String label,
- boolean visible);
+ boolean checked, String label);
native void gtkCheckButtonSetState (boolean checked);
native void gtkCheckButtonSetLabel (String label);
public GtkCheckboxPeer (Checkbox c, ComponentPeer cp)
{
super (c);
- Point p = c.getLocation();
-
- System.out.println("checkboxpeer: location: "+p.x+","+p.y);
CheckboxGroup group = c.getCheckboxGroup ();
if (group == null)
- gtkCheckButtonNew (cp, c.getState (), c.getLabel (), c.isVisible ());
+ gtkCheckButtonNew (cp, c.getState (), c.getLabel ());
else
- gtkRadioButtonNew (cp, group, c.getState(), c.getLabel (), c.isVisible ());
+ gtkRadioButtonNew (cp, group, c.getState(), c.getLabel ());
+ syncAttributes ();
}
public void setCheckboxGroup (CheckboxGroup group)
diff --git a/gnu/java/awt/peer/gtk/GtkChoicePeer.java b/gnu/java/awt/peer/gtk/GtkChoicePeer.java
index 748b4b5a6..f5c6d5867 100644
--- a/gnu/java/awt/peer/gtk/GtkChoicePeer.java
+++ b/gnu/java/awt/peer/gtk/GtkChoicePeer.java
@@ -28,8 +28,7 @@ public class GtkChoicePeer extends GtkComponentPeer
implements ChoicePeer
{
- native void gtkOptionMenuNew (ComponentPeer parent,
- String [] items, boolean visible);
+ native void gtkOptionMenuNew (ComponentPeer parent, String [] items);
native void gtkOptionMenuAdd (String item, int index);
native void gtkOptionMenuRemove (int index);
native void gtkOptionMenuSelect (int index);
@@ -38,8 +37,6 @@ public class GtkChoicePeer extends GtkComponentPeer
{
super (c);
- System.out.println("choicepeer: <init>");
-
int count = c.getItemCount();
String [] items=new String[count];
@@ -47,7 +44,8 @@ public class GtkChoicePeer extends GtkComponentPeer
for (int i = 0; i < count; i++)
items[i] = c.getItem(i);
- gtkOptionMenuNew (parent, items, c.isVisible ());
+ gtkOptionMenuNew (parent, items);
+ syncAttributes ();
}
public void add (String item, int index)
diff --git a/gnu/java/awt/peer/gtk/GtkComponentPeer.java b/gnu/java/awt/peer/gtk/GtkComponentPeer.java
index 07a507a52..91066883c 100644
--- a/gnu/java/awt/peer/gtk/GtkComponentPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkComponentPeer.java
@@ -31,180 +31,171 @@ public class GtkComponentPeer extends GtkGenericPeer
Component awtComponent;
/* this isEnabled differs from Component.isEnabled, in that it
- knows if a parent is disabled, in which case Component.isEnabled
- will return true, but our isEnabled will return false */
+ knows if a parent is disabled. In that case Component.isEnabled
+ may return true, but our isEnabled will always return false */
native boolean isEnabled ();
native static boolean modalHasGrab ();
- // native void gtkWidgetPaint();
native int[] gtkWidgetGetForeground ();
native int[] gtkWidgetGetBackground ();
native void gtkWidgetSetVisible (boolean b);
native void gtkWidgetGetDimensions(int[] dim);
native void gtkWidgetGetLocationOnScreen(int[] point);
-// native void gtkWidgetSetUsize(int width, int height);
native void gtkWidgetSetCursor (int type);
- native void gtkFixedNew (int w, int h, boolean visible);
- native void gtkFixedPut (Object parent, int x, int y);
-// native void gtkFixedMove(int x, int y);
-
protected GtkComponentPeer (Component awtComponent)
- {
- super (awtComponent);
- this.awtComponent = awtComponent;
- }
-
- /* this method should be called from a gtk-realize hook */
- protected void syncAttrs ()
- {
- setCursor (awtComponent.getCursor ());
- }
+ {
+ super (awtComponent);
+ this.awtComponent = awtComponent;
+ }
+
+ /* This method should be called from Peer constructors
+ to synchronize mundane attributes. */
+ protected void syncAttributes ()
+ {
+ setCursor (awtComponent.getCursor ());
+ Dimension d = awtComponent.getSize ();
+
+ Point p = awtComponent.getLocation ();
+ setBounds (p.x, p.y, d.width, d.height);
+
+ setVisible (awtComponent.isVisible ());
+ }
public int checkImage (Image image, int width, int height,
ImageObserver observer)
- {
- return 0;
- }
+ {
+ return 0;
+ }
public Image createImage (ImageProducer producer)
- {
- return null;
- }
+ {
+ return null;
+ }
public Image createImage (int width, int height)
- {
- return null;
- }
+ {
+ return null;
+ }
public void disable ()
- {
- setEnabled (false);
- }
+ {
+ setEnabled (false);
+ }
native public void dispose ();
public void enable ()
- {
- setEnabled (true);
- }
+ {
+ setEnabled (true);
+ }
public ColorModel getColorModel ()
- {
- System.out.println("componentpeer: getcolormodel");
- return null;
- }
+ {
+ System.out.println("componentpeer: getcolormodel");
+ return null;
+ }
public FontMetrics getFontMetrics (Font f)
- {
- System.out.println("componentpeer: getfontmetrics");
- return null;
- }
+ {
+ System.out.println("componentpeer: getfontmetrics");
+ return null;
+ }
public Graphics getGraphics ()
{
return new GdkGraphics (this);
}
-// public Graphics getGraphics ()
-// {
-// throw new InternalError ("Graphics object unavailable for " +
-// awtComponent);
-// }
-
public Point getLocationOnScreen ()
- {
- int point[] = new int[2];
- gtkWidgetGetLocationOnScreen (point);
- return new Point (point[0], point[1]);
- }
+ {
+ int point[] = new int[2];
+ gtkWidgetGetLocationOnScreen (point);
+ return new Point (point[0], point[1]);
+ }
public Dimension getMinimumSize ()
- {
- int dim[]=new int[2];
- gtkWidgetGetDimensions (dim);
- System.out.println ("componentpeer: min: " + dim[0] + ", " + dim[1]);
- Dimension d = new Dimension (dim[0],dim[1]);
- return (d);
- }
+ {
+ int dim[]=new int[2];
+ gtkWidgetGetDimensions (dim);
+ Dimension d = new Dimension (dim[0],dim[1]);
+ System.out.println ("min: " + this + d);
+ return (d);
+ }
public Dimension getPreferredSize ()
- {
- int dim[]=new int[2];
- gtkWidgetGetDimensions (dim);
- Dimension d = new Dimension (dim[0],dim[1]);
-
- System.out.println ("Cpeer.pref: " +this+":"+ dim[0] + ", " + dim[1]);
- return (d);
- }
+ {
+ int dim[]=new int[2];
+ gtkWidgetGetDimensions (dim);
+ Dimension d = new Dimension (dim[0],dim[1]);
+ System.out.println ("min: " + this + d);
+ return (d);
+ }
public Toolkit getToolkit ()
- {
- return Toolkit.getDefaultToolkit();
- }
+ {
+ return Toolkit.getDefaultToolkit();
+ }
public void handleEvent (AWTEvent event)
- {
- int id = event.getID();
+ {
+ int id = event.getID();
- switch (id)
+ switch (id)
+ {
+ case PaintEvent.PAINT:
+ case PaintEvent.UPDATE:
{
- case PaintEvent.PAINT:
- case PaintEvent.UPDATE:
- {
- try
- {
- Graphics g = getGraphics ();
+ try
+ {
+ Graphics g = getGraphics ();
- if (id == PaintEvent.PAINT)
- awtComponent.paint (g);
- else
- awtComponent.update (g);
+ if (id == PaintEvent.PAINT)
+ awtComponent.paint (g);
+ else
+ awtComponent.update (g);
- g.dispose ();
- }
- catch (InternalError e)
- {
- System.err.println (e);
- }
- }
- break;
+ g.dispose ();
+ }
+ catch (InternalError e)
+ {
+ System.err.println (e);
+ }
}
- }
+ break;
+ }
+ }
public boolean isFocusTraversable ()
- {
- return true;
- }
+ {
+ return true;
+ }
public Dimension minimumSize ()
- {
- System.out.println("componentpeer: minimumsize");
- return getMinimumSize();
- }
+ {
+ return getMinimumSize();
+ }
public void paint (Graphics g)
- {
- // gtkWidgetPaint();
- awtComponent.paint (g);
- }
+ {
+ awtComponent.paint (g);
+ }
public Dimension preferredSize()
- {
- System.out.println("Cpeer.preferredsize");
- return getPreferredSize();
- }
+ {
+ return getPreferredSize();
+ }
public boolean prepareImage (Image image, int width, int height,
ImageObserver observer)
- {
- return false;
- }
+ {
+ return false;
+ }
public void print (Graphics g)
- {
- throw new RuntimeException();
- }
+ {
+ throw new RuntimeException();
+ }
public void repaint (long tm, int x, int y, int width, int height)
{
@@ -215,58 +206,58 @@ public class GtkComponentPeer extends GtkGenericPeer
native public void requestFocus ();
public void reshape (int x, int y, int width, int height)
- {
- setBounds (x, y, width, height);
- }
+ {
+ setBounds (x, y, width, height);
+ }
public void setBackground (Color c)
- {
- }
+ {
+ }
native public void setBounds (int x, int y, int width, int height);
public void setCursor (Cursor cursor)
- {
- System.out.println("setCursorCalled");
- gtkWidgetSetCursor (cursor.getType ());
- }
+ {
+ gtkWidgetSetCursor (cursor.getType ());
+ }
native public void setEnabled (boolean b);
public void setFont (Font f)
- {
- }
+ {
+ }
public void setForeground (Color c)
- {
- }
+ {
+ }
public Color getForeground ()
- {
- int rgb[] = gtkWidgetGetForeground ();
- return new Color (rgb[0], rgb[1], rgb[2]);
- }
+ {
+ int rgb[] = gtkWidgetGetForeground ();
+ return new Color (rgb[0], rgb[1], rgb[2]);
+ }
public Color getBackground ()
- {
- int rgb[] = gtkWidgetGetBackground ();
- return new Color (rgb[0], rgb[1], rgb[2]);
- }
+ {
+ int rgb[] = gtkWidgetGetBackground ();
+ return new Color (rgb[0], rgb[1], rgb[2]);
+ }
native public void setVisible (boolean b);
public void hide ()
- {
- setVisible (false);
- }
+ {
+ setVisible (false);
+ }
public void show ()
- {
- setVisible (true);
- }
+ {
+ setVisible (true);
+ }
protected void postMouseEvent(int id, long when, int mods, int x, int y,
- int clickCount, boolean popupTrigger) {
+ int clickCount, boolean popupTrigger)
+ {
q.postEvent(new MouseEvent(awtComponent, id, when, mods, x, y,
clickCount, popupTrigger));
}
diff --git a/gnu/java/awt/peer/gtk/GtkDialogPeer.java b/gnu/java/awt/peer/gtk/GtkDialogPeer.java
index 007433ab7..ec1053832 100644
--- a/gnu/java/awt/peer/gtk/GtkDialogPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkDialogPeer.java
@@ -24,37 +24,35 @@ import java.awt.*;
import java.awt.peer.*;
public class GtkDialogPeer extends GtkWindowPeer
- implements DialogPeer
+ implements DialogPeer
{
native void gtkDialogNew(int width, int height, boolean visible,
boolean resizable, String title, boolean modal,
Object parent);
public GtkDialogPeer (Dialog w, ComponentPeer parent)
- {
- super (bogusType, w);
+ {
+ super (bogusType, w);
- Dimension d = w.getSize();
- System.out.println ("DIALOG: modal =" + w.isModal());
- gtkDialogNew (d.width, d.height, w.isVisible (), w.isResizable (),
- w.getTitle (), w.isModal(), parent);
- }
+ Dimension d = w.getSize();
+ gtkDialogNew (d.width, d.height, w.isVisible (), w.isResizable (),
+ w.getTitle (), w.isModal(), parent);
+ }
public GtkDialogPeer (int type, Dialog w)
- {
- super (bogusType, w);
- }
+ {
+ super (bogusType, w);
+ }
public void setTitle(String title)
- {
- System.out.println("setting title");
- gtkWindowSetTitle(title);
- }
+ {
+ gtkWindowSetTitle(title);
+ }
public void setResizable(boolean resizable)
- {
- int r=resizable?1:0;
+ {
+ int r=resizable?1:0;
- gtkWindowSetPolicy(r,r,0); //shrink,grow,auto
- }
+ gtkWindowSetPolicy(r,r,0); //shrink,grow,auto
+ }
}
diff --git a/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java b/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java
index 8e2ef6ce3..f198145b7 100644
--- a/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java
@@ -25,35 +25,34 @@ import java.awt.peer.*;
import java.awt.*;
public class GtkFileDialogPeer extends GtkDialogPeer
- implements FileDialogPeer
+ implements FileDialogPeer
{
native void gtkFileSelectionNew();
native void gtkFileSelectionSetFilename(String file);
- public GtkFileDialogPeer(FileDialog fd)
- {
- super (bogusType, fd);
- System.out.println("FileDialogPeer contructor");
- gtkFileSelectionNew();
- /*
- FIXME: need to work like DialogPeer
- */
- }
+ public GtkFileDialogPeer(FileDialog fd)
+ {
+ super (bogusType, fd);
+ gtkFileSelectionNew();
+ /*
+ FIXME: need to work like DialogPeer
+ */
+ }
- public void setDirectory(String directory)
- {
- gtkFileSelectionSetFilename(directory);
- }
+ public void setDirectory(String directory)
+ {
+ gtkFileSelectionSetFilename(directory);
+ }
- public void setFile(String file)
- {
- gtkFileSelectionSetFilename(file);
- }
+ public void setFile(String file)
+ {
+ gtkFileSelectionSetFilename(file);
+ }
- public void setFilenameFilter(FilenameFilter filter)
- {
- /* GTK has no filters. */
- }
+ public void setFilenameFilter(FilenameFilter filter)
+ {
+ /* GTK has no filters. */
+ }
}
diff --git a/gnu/java/awt/peer/gtk/GtkLabelPeer.java b/gnu/java/awt/peer/gtk/GtkLabelPeer.java
index 03d26d0c6..6f1c2427b 100644
--- a/gnu/java/awt/peer/gtk/GtkLabelPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkLabelPeer.java
@@ -27,14 +27,13 @@ public class GtkLabelPeer extends GtkComponentPeer
implements LabelPeer
{
- native void gtkLabelNew (ComponentPeer parent,
- String text, int just, boolean visible);
+ native void gtkLabelNew (ComponentPeer parent, String text, int just);
public GtkLabelPeer (Label l, ComponentPeer cp)
{
super (l);
- System.out.println("labelpeer<init> called");
- gtkLabelNew (cp, l.getText(), l.getAlignment (), l.isVisible ());
+ gtkLabelNew (cp, l.getText (), l.getAlignment ());
+ syncAttributes ();
}
native public void setText (String text);
diff --git a/gnu/java/awt/peer/gtk/GtkListPeer.java b/gnu/java/awt/peer/gtk/GtkListPeer.java
index 5d38911ac..d37ed6703 100644
--- a/gnu/java/awt/peer/gtk/GtkListPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkListPeer.java
@@ -24,11 +24,10 @@ import java.awt.*;
import java.awt.peer.*;
public class GtkListPeer extends GtkComponentPeer
- implements ListPeer
+ implements ListPeer
{
native void gtkListNew (ComponentPeer parent,
- Object list, String [] items, boolean mode,
- boolean visible);
+ Object list, String [] items, boolean mode);
native void gtkListInsert (Object list, String item, int index);
native void gtkListClearItems (Object list, int start, int end);
native void gtkListSelectItem (Object list, int index);
@@ -41,97 +40,96 @@ public class GtkListPeer extends GtkComponentPeer
Object myGtkList;
public GtkListPeer (List l, ComponentPeer cp)
- {
- super (l);
- String items[] = l.getItems();
+ {
+ super (l);
+ String items[] = l.getItems();
- myGtkList = new Object();
+ myGtkList = new Object();
- gtkListNew (cp, myGtkList, items,
- l.isMultipleMode(),
- l.isVisible ());
- }
+ gtkListNew (cp, myGtkList, items, l.isMultipleMode());
+ syncAttributes ();
+ }
public void add (String item, int index)
- {
- gtkListInsert (myGtkList, item, index);
- }
+ {
+ gtkListInsert (myGtkList, item, index);
+ }
public void addItem (String item, int index)
- {
- add (item, index);
- }
+ {
+ add (item, index);
+ }
public void clear ()
- {
- removeAll ();
- }
+ {
+ removeAll ();
+ }
public void delItems (int start, int end)
- {
- gtkListClearItems (myGtkList, start, end);
- }
+ {
+ gtkListClearItems (myGtkList, start, end);
+ }
public void deselect (int index)
- {
- gtkListUnselectItem (myGtkList, index);
- }
+ {
+ gtkListUnselectItem (myGtkList, index);
+ }
public Dimension getMinimumSize (int rows)
- {
- int dims[] = new int[2];
+ {
+ int dims[] = new int[2];
- gtkListGetSize (myGtkList, rows, dims);
- return (new Dimension (dims[0], dims[1]));
- }
+ gtkListGetSize (myGtkList, rows, dims);
+ return (new Dimension (dims[0], dims[1]));
+ }
public Dimension getPreferredSize (int rows)
- {
- int dims[] = new int[2];
+ {
+ int dims[] = new int[2];
- gtkListGetSize (myGtkList, rows, dims);
- return (new Dimension (dims[0], dims[1]));
- }
+ gtkListGetSize (myGtkList, rows, dims);
+ return (new Dimension (dims[0], dims[1]));
+ }
public int[] getSelectedIndexes ()
- {
- return (gtkListGetSelected (myGtkList));
- }
+ {
+ return (gtkListGetSelected (myGtkList));
+ }
public void makeVisible (int index)
- {
- gtkListScrollVertical (myGtkList, index);
- }
+ {
+ gtkListScrollVertical (myGtkList, index);
+ }
public Dimension minimumSize (int rows)
- {
- return (getMinimumSize (rows));
- }
+ {
+ return (getMinimumSize (rows));
+ }
public Dimension preferredSize (int rows)
- {
- return (getPreferredSize (rows));
- }
+ {
+ return (getPreferredSize (rows));
+ }
public void removeAll ()
- {
- gtkListClearItems (myGtkList, 0, -1);
- }
+ {
+ gtkListClearItems (myGtkList, 0, -1);
+ }
public void select (int index)
- {
- gtkListSelectItem (myGtkList, index);
- }
+ {
+ gtkListSelectItem (myGtkList, index);
+ }
public void setMultipleMode (boolean b)
- {
- gtkListSetSelectionMode (myGtkList, b);
- }
+ {
+ gtkListSetSelectionMode (myGtkList, b);
+ }
public void setMultipleSelections (boolean b)
- {
- setMultipleMode (b);
- }
+ {
+ setMultipleMode (b);
+ }
protected void postItemEvent (int item, int stateChange)
{
diff --git a/gnu/java/awt/peer/gtk/GtkMainThread.java b/gnu/java/awt/peer/gtk/GtkMainThread.java
index 6d6868ab5..2dc7639cd 100644
--- a/gnu/java/awt/peer/gtk/GtkMainThread.java
+++ b/gnu/java/awt/peer/gtk/GtkMainThread.java
@@ -28,30 +28,32 @@ public class GtkMainThread extends GtkGenericPeer implements Runnable
static native void gtkInit();
native void gtkMain();
- public GtkMainThread() {
+ public GtkMainThread()
+ {
super (null);
- synchronized (mainThreadLock) {
- if (mainThread != null)
- throw new IllegalStateException();
- mainThread = new Thread(this, "GtkMain");
- }
-
- synchronized (this) {
- mainThread.start();
- try {
- wait();
- } catch (InterruptedException e) { }
- }
+ synchronized (mainThreadLock)
+ {
+ if (mainThread != null)
+ throw new IllegalStateException();
+ mainThread = new Thread(this, "GtkMain");
+ }
+
+ synchronized (this)
+ {
+ mainThread.start();
+ try {
+ wait();
+ } catch (InterruptedException e) { }
+ }
}
- public void run() {
- synchronized (this) {
- gtkInit();
- notify();
- }
-// try {
-// Thread.sleep (5000);
-// } catch (InterruptedException e) {}
+ public void run()
+ {
+ synchronized (this)
+ {
+ gtkInit();
+ notify();
+ }
gtkMain();
}
}
diff --git a/gnu/java/awt/peer/gtk/GtkPanelPeer.java b/gnu/java/awt/peer/gtk/GtkPanelPeer.java
index 963253ce7..3be5b4403 100644
--- a/gnu/java/awt/peer/gtk/GtkPanelPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkPanelPeer.java
@@ -26,18 +26,12 @@ public class GtkPanelPeer extends GtkContainerPeer
implements PanelPeer
{
- native protected void gtkPanelNew (ComponentPeer parent, boolean visible);
+ native protected void gtkPanelNew (ComponentPeer parent);
public GtkPanelPeer(Panel p, ComponentPeer parent)
{
super (p);
- System.out.println("new panelpeer: parent: "+ parent);
-
- Dimension d=p.getSize();
- Point pnt=p.getLocation();
-
- gtkPanelNew (parent, p.isVisible ());
-// gtkFixedNew (d.width, d.height, p.isVisible ());
-// gtkFixedPut (parent, pnt.x, pnt.y);
+ gtkPanelNew (parent);
+ syncAttributes ();
}
}
diff --git a/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java b/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java
index 5244ace81..95f292328 100644
--- a/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java
+++ b/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java
@@ -30,85 +30,80 @@ public class GtkScrollPanePeer extends GtkContainerPeer
ScrollPane myScrollPane;
native void gtkScrolledWindowNew(ComponentPeer parent,
- int policy, int w, int h, int[] dims,
- boolean visible);
+ int policy, int w, int h, int[] dims);
native void gtkScrolledWindowSetScrollPosition(int x, int y);
native void gtkScrolledWindowSetHScrollIncrement (int u);
native void gtkScrolledWindowSetVScrollIncrement (int u);
native void gtkScrolledWindowSetSize(int w, int h);
-
+
public GtkScrollPanePeer(ScrollPane p, ComponentPeer parent)
- {
- super (p);
- System.out.println("new scrollpanepeer");
+ {
+ super (p);
- myScrollPane=p;
- policy=p.getScrollbarDisplayPolicy();
+ myScrollPane=p;
+ policy=p.getScrollbarDisplayPolicy();
- int mypolicy=1;
- switch (policy)
- {
- case ScrollPane.SCROLLBARS_ALWAYS: mypolicy=1; break;
- case ScrollPane.SCROLLBARS_AS_NEEDED: mypolicy=2; break;
- case ScrollPane.SCROLLBARS_NEVER: mypolicy=3; break;
- }
-
- Point pnt=p.getLocation();
- Dimension pdim=p.getSize();
+ int mypolicy=1;
+ switch (policy)
+ {
+ case ScrollPane.SCROLLBARS_ALWAYS: mypolicy=1; break;
+ case ScrollPane.SCROLLBARS_AS_NEEDED: mypolicy=2; break;
+ case ScrollPane.SCROLLBARS_NEVER: mypolicy=3; break;
+ }
- System.out.println(":" + pdim.width + " " + pdim.height);
+ Point pnt=p.getLocation();
+ Dimension pdim=p.getSize();
- int dims[]=new int[2];
+ int dims[]=new int[2];
- gtkScrolledWindowNew(parent,
- mypolicy, pdim.width, pdim.height, dims,
- p.isVisible ());
+ gtkScrolledWindowNew(parent, mypolicy, pdim.width, pdim.height, dims);
+ syncAttributes ();
- sbWidth=dims[0];
- sbHeight=dims[1];
- }
+ sbWidth=dims[0];
+ sbHeight=dims[1];
+ }
public void childResized (int w, int h)
- {
- System.out.println("SPP: child resized to: "+ w + " x " + h);
+ {
+ System.out.println("SPP: child resized to: "+ w + " x " + h);
- gtkScrolledWindowSetSize(w, h);
- }
+ gtkScrolledWindowSetSize(w, h);
+ }
public int getHScrollbarHeight ()
- {
- return sbHeight;
- }
+ {
+ return sbHeight;
+ }
public int getVScrollbarWidth ()
- {
- return sbWidth;
- }
+ {
+ return sbWidth;
+ }
public void setScrollPosition (int x, int y)
- {
- gtkScrolledWindowSetScrollPosition(x, y);
- }
+ {
+ gtkScrolledWindowSetScrollPosition(x, y);
+ }
public void setUnitIncrement (Adjustable adj, int u)
- {
- /* Er... What calls this? */
+ {
+ /* Er... What calls this? */
- System.out.println("SPP: setUI: "+adj+":"+u);
- if (adj.getOrientation()==Adjustable.HORIZONTAL)
- gtkScrolledWindowSetHScrollIncrement (u);
- else
- gtkScrolledWindowSetVScrollIncrement (u);
- }
+ System.out.println("SPP: setUI: "+adj+":"+u);
+ if (adj.getOrientation()==Adjustable.HORIZONTAL)
+ gtkScrolledWindowSetHScrollIncrement (u);
+ else
+ gtkScrolledWindowSetVScrollIncrement (u);
+ }
public void setValue (Adjustable adj, int v)
- {
- System.out.println("SPP: setVal: "+adj+":"+v);
- Point p=myScrollPane.getScrollPosition ();
- if (adj.getOrientation()==Adjustable.HORIZONTAL)
- gtkScrolledWindowSetScrollPosition (v,p.y);
- else
- gtkScrolledWindowSetScrollPosition (p.x,v);
- adj.setValue(v);
- }
+ {
+ System.out.println("SPP: setVal: "+adj+":"+v);
+ Point p=myScrollPane.getScrollPosition ();
+ if (adj.getOrientation()==Adjustable.HORIZONTAL)
+ gtkScrolledWindowSetScrollPosition (v,p.y);
+ else
+ gtkScrolledWindowSetScrollPosition (p.x,v);
+ adj.setValue(v);
+ }
}
diff --git a/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java b/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java
index 86b1097af..4b6521745 100644
--- a/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java
@@ -30,7 +30,7 @@ public class GtkScrollbarPeer extends GtkComponentPeer
native void gtkScrollbarNew (ComponentPeer parent,
int orientation, int value, int visibleAmount,
- int min, int max, boolean visible);
+ int min, int max);
native public void setLineIncrement (int amount);
native public void setPageIncrement (int amount);
native public void setValues (int value, int visible, int min, int max);
@@ -44,8 +44,8 @@ public class GtkScrollbarPeer extends GtkComponentPeer
s.getValue(),
s.getVisibleAmount(),
s.getMinimum(),
- s.getMaximum(),
- s.isVisible ());
+ s.getMaximum());
+ syncAttributes ();
}
protected void postAdjustmentEvent (int type, int value)
diff --git a/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java b/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java
index fd2033265..29fe877e5 100644
--- a/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java
@@ -27,8 +27,8 @@ public class GtkTextAreaPeer extends GtkTextComponentPeer
implements TextAreaPeer
{
- native void gtkTextNew (Object edit, String text, int hscroll, int vscroll,
- boolean visible);
+ native void gtkTextNew (Object parent, Object edit, String text,
+ int hscroll, int vscroll);
native void gtkTextGetSize (Object edit, int rows, int cols, int dims[]);
native String gtkTextGetText (Object edit);
native void gtkTextSetText (Object edit, String text);
@@ -36,100 +36,96 @@ public class GtkTextAreaPeer extends GtkTextComponentPeer
native void gtkTextReplace (Object edit, String text, int start, int end);
public GtkTextAreaPeer (TextArea ta, ComponentPeer cp)
- {
- super (ta);
- String text = ta.getText();
- int hscroll=0;
- int vscroll=0;
-
- switch (ta.getScrollbarVisibility())
- {
- case TextArea.SCROLLBARS_BOTH:
- hscroll=vscroll=1;
- break;
- case TextArea.SCROLLBARS_HORIZONTAL_ONLY:
- hscroll=1;
- break;
- case TextArea.SCROLLBARS_VERTICAL_ONLY:
- vscroll=1;
- break;
- }
-
- System.out.println ("TAP: new: "+ text + " - " + hscroll + " - " + vscroll);
-
- editable = new Object();
-
- gtkTextNew (editable, text, hscroll, vscroll, ta.isVisible ());
-
- Point p=ta.getLocation();
- gtkFixedPut (cp,p.x,p.y);
- }
+ {
+ super (ta);
+ String text = ta.getText();
+ int hscroll=0;
+ int vscroll=0;
+
+ switch (ta.getScrollbarVisibility())
+ {
+ case TextArea.SCROLLBARS_BOTH:
+ hscroll=vscroll=1;
+ break;
+ case TextArea.SCROLLBARS_HORIZONTAL_ONLY:
+ hscroll=1;
+ break;
+ case TextArea.SCROLLBARS_VERTICAL_ONLY:
+ vscroll=1;
+ break;
+ }
+
+ editable = new Object();
+
+ gtkTextNew (cp, editable, text, hscroll, vscroll);
+ syncAttributes ();
+ }
public Dimension getMinimumSize (int rows, int cols)
- {
- int dims[] = new int[2];
+ {
+ int dims[] = new int[2];
- gtkTextGetSize (editable, rows, cols, dims);
+ gtkTextGetSize (editable, rows, cols, dims);
- System.out.println ("TAP: getMinimumSize " + cols + " = " + dims[0] +
- " x " + dims[1]);
+ System.out.println ("TAP: getMinimumSize " + cols + " = " + dims[0] +
+ " x " + dims[1]);
- return (new Dimension (dims[0], dims[1]));
- }
+ return (new Dimension (dims[0], dims[1]));
+ }
public Dimension getPreferredSize (int rows, int cols)
- {
- int dims[] = new int[2];
+ {
+ int dims[] = new int[2];
- gtkTextGetSize (editable, rows, cols, dims);
+ gtkTextGetSize (editable, rows, cols, dims);
- System.out.println ("TAP: getPreferredSize " + cols + " = " + dims[0] +
- " x " + dims[1]);
+ System.out.println ("TAP: getPreferredSize " + cols + " = " + dims[0] +
+ " x " + dims[1]);
- return (new Dimension (dims[0], dims[1]));
- }
+ return (new Dimension (dims[0], dims[1]));
+ }
public String getText ()
- {
- System.out.println ("TAP: getText");
- return (gtkTextGetText(editable));
- }
+ {
+ System.out.println ("TAP: getText");
+ return (gtkTextGetText(editable));
+ }
public void setText (String text)
- {
- System.out.println ("TAP: setText");
- gtkTextSetText (editable, text);
- }
+ {
+ System.out.println ("TAP: setText");
+ gtkTextSetText (editable, text);
+ }
public void insert (String str, int pos)
- {
- gtkTextInsert (editable, str, pos);
- }
+ {
+ gtkTextInsert (editable, str, pos);
+ }
public void replaceRange (String str, int start, int end)
- {
- gtkTextReplace (editable, str, start, end);
- }
+ {
+ gtkTextReplace (editable, str, start, end);
+ }
/* Deprecated */
public Dimension minimumSize (int rows, int cols)
- {
- return getMinimumSize (rows, cols);
- }
+ {
+ return getMinimumSize (rows, cols);
+ }
public Dimension preferredSize (int rows, int cols)
- {
- return getPreferredSize (rows, cols);
- }
+ {
+ return getPreferredSize (rows, cols);
+ }
public void replaceText (String str, int start, int end)
- {
- replaceRange (str, start, end);
- }
+ {
+ replaceRange (str, start, end);
+ }
public void insertText (String str, int pos)
- {
- insert (str, pos);
- }
+ {
+ insert (str, pos);
+ }
}
diff --git a/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java b/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java
index be370ee0a..233ed233d 100644
--- a/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java
@@ -27,77 +27,76 @@ public class GtkTextFieldPeer extends GtkTextComponentPeer
implements TextFieldPeer
{
- native void gtkEntryNew (ComponentPeer parent, String text, boolean visible);
+ native void gtkEntryNew (ComponentPeer parent, String text);
native void gtkEntryGetSize (int cols, int dims[]);
native void gtkEntrySetEchoChar (char c);
native String gtkEntryGetText ();
native void gtkEntrySetText (String text);
public GtkTextFieldPeer (TextField tf, ComponentPeer cp)
- {
- super (tf);
- String text = tf.getText();
+ {
+ super (tf);
+ String text = tf.getText();
- System.out.println ("TFP: new");
-
- gtkEntryNew (cp, text, tf.isVisible ());
- }
+ gtkEntryNew (cp, text);
+ syncAttributes ();
+ }
public Dimension getMinimumSize (int cols)
- {
- int dims[] = new int[2];
+ {
+ int dims[] = new int[2];
- gtkEntryGetSize (cols, dims);
+ gtkEntryGetSize (cols, dims);
- System.out.println ("TFP: getMinimumSize " + cols + " = " + dims[0] +
- " x " + dims[1]);
+ System.out.println ("TFP: getMinimumSize " + cols + " = " + dims[0] +
+ " x " + dims[1]);
- return (new Dimension (dims[0], dims[1]));
- }
+ return (new Dimension (dims[0], dims[1]));
+ }
public Dimension getPreferredSize (int cols)
- {
- int dims[] = new int[2];
+ {
+ int dims[] = new int[2];
- gtkEntryGetSize (cols, dims);
+ gtkEntryGetSize (cols, dims);
- System.out.println ("TFP: getPreferredSize " + cols + " = " + dims[0] +
- " x " + dims[1]);
+ System.out.println ("TFP: getPreferredSize " + cols + " = " + dims[0] +
+ " x " + dims[1]);
- return (new Dimension (dims[0], dims[1]));
- }
+ return (new Dimension (dims[0], dims[1]));
+ }
public void setEchoChar (char c)
- {
- gtkEntrySetEchoChar (c);
- }
+ {
+ gtkEntrySetEchoChar (c);
+ }
public String getText ()
- {
- System.out.println ("TFP: getText");
- return (gtkEntryGetText());
- }
+ {
+ System.out.println ("TFP: getText");
+ return (gtkEntryGetText());
+ }
public void setText (String text)
- {
- System.out.println ("TFP: setText");
- gtkEntrySetText (text);
- }
+ {
+ System.out.println ("TFP: setText");
+ gtkEntrySetText (text);
+ }
/* Deprecated */
public Dimension minimumSize (int cols)
- {
- return getMinimumSize (cols);
- }
+ {
+ return getMinimumSize (cols);
+ }
public Dimension preferredSize (int cols)
- {
- return getPreferredSize (cols);
- }
+ {
+ return getPreferredSize (cols);
+ }
public void setEchoCharacter (char c)
- {
- setEchoChar (c);
- }
+ {
+ setEchoChar (c);
+ }
}
diff --git a/gnu/java/awt/peer/gtk/TestAWT.java b/gnu/java/awt/peer/gtk/TestAWT.java
index c49ad2b04..13ab892f8 100644
--- a/gnu/java/awt/peer/gtk/TestAWT.java
+++ b/gnu/java/awt/peer/gtk/TestAWT.java
@@ -27,15 +27,20 @@ import java.awt.peer.*;
class TestAWT
{
public static void main(String args[])
- {
- if (args.length==0)
- {
- Properties prop = System.getProperties ();
- prop.put ("awt.toolkit", "gnu.java.awt.peer.gtk.GtkToolkit");
- }
- MainWindow f = new MainWindow();
- f.show();
- }
+ {
+ if (args.length==0)
+ {
+ Properties prop = System.getProperties ();
+ prop.put ("awt.toolkit", "gnu.java.awt.peer.gtk.GtkToolkit");
+ }
+ MainWindow f = new MainWindow();
+ f.show();
+ }
+}
+
+interface SubWindow
+{
+ public void init ();
}
class PrettyPanel extends Panel
@@ -43,556 +48,445 @@ class PrettyPanel extends Panel
Insets myInsets;
public PrettyPanel ()
- {
- myInsets = new Insets (10, 10, 10, 10);
- }
+ {
+ myInsets = new Insets (10, 10, 10, 10);
+ }
public Insets getInsets ()
- {
- return myInsets;
- }
+ {
+ return myInsets;
+ }
}
-class PrettyFrame extends Frame
+abstract class PrettyFrame extends Frame
{
- Insets myInsets;
-
- public PrettyFrame (String title)
- {
- super (title);
- myInsets = new Insets (10, 10, 10, 10);
- ((BorderLayout) getLayout ()).setHgap (5);
- ((BorderLayout) getLayout ()).setVgap (5);
- }
-
public PrettyFrame ()
- {
- this ("");
- }
+ {
+ ((BorderLayout) getLayout ()).setHgap (5);
+ ((BorderLayout) getLayout ()).setVgap (5);
+ }
public Insets getInsets()
- {
- return myInsets;
- }
+ {
+ Insets oldInsets = super.getInsets ();
+ return new Insets (oldInsets.top+10,
+ oldInsets.left+10,
+ oldInsets.bottom+10,
+ oldInsets.right+10);
+ }
}
+abstract class SubFrame extends PrettyFrame implements SubWindow
+{
+ boolean initted = false;
+
+ public void setVisible (boolean visible)
+ {
+ if (!initted && visible)
+ init();
+ super.setVisible (visible);
+ }
+}
class MainWindow extends PrettyFrame implements ActionListener
{
- Button closeButton, buttonsButton, dialogButton, cursorsButton,
- textFieldButton, fileButton, labelButton, radioButton;
- Window buttonsWindow = null, dialogWindow = null, cursorsWindow = null,
- textFieldWindow = null, fileWindow = null, labelWindow = null,
- radioWindow = null;
-
- MainWindow ()
- {
- super ("TestAWT");
+ Button closeButton;
- System.out.println (getInsets ());
+ Hashtable windows;
+ Vector buttons;
- ScrollPane sp = new ScrollPane();
+ void addSubWindow (String name, SubWindow w)
+ {
+ Button b = new Button (name);
+ b.addActionListener (this);
- PrettyPanel p = new PrettyPanel();
+ buttons.addElement (b);
+ windows.put (b, w);
+ }
- p.setLayout (new GridLayout (10, 1));
- sp.add (p);
- add (sp, "Center");
+ MainWindow ()
+ {
+ System.out.println (getInsets ());
- add (new Label ("Classpath v0.0.0"), "North");
+ add (new Label ("Classpath v0.0.0"), "North");
- closeButton = new Button ("Close");
- closeButton.addActionListener (this);
- add (closeButton, "South");
-
- buttonsButton = new Button ("buttons");
- buttonsButton.addActionListener (this);
- p.add (buttonsButton);
+ closeButton = new Button ("Close");
+ closeButton.addActionListener (this);
+ add (closeButton, "South");
- dialogButton = new Button ("dialog");
- dialogButton.addActionListener (this);
- p.add (dialogButton);
+ windows = new Hashtable ();
+ buttons = new Vector ();
- cursorsButton = new Button ("cursors");
- cursorsButton.addActionListener (this);
- p.add (cursorsButton);
+ addSubWindow ("Buttons", new ButtonsWindow ());
+ addSubWindow ("Dialog", new DialogWindow (this));
+ addSubWindow ("Cursors", new CursorsWindow ());
+ addSubWindow ("TextField", new TextFieldWindow ());
+ addSubWindow ("File", new FileWindow (this));
+ addSubWindow ("Labels", new LabelWindow ());
+ addSubWindow ("Radio Buttons", new RadioWindow ());
- textFieldButton = new Button ("text field");
- textFieldButton.addActionListener (this);
- p.add (textFieldButton);
+ ScrollPane sp = new ScrollPane();
+ PrettyPanel p = new PrettyPanel();
+ p.setLayout (new GridLayout (windows.size(), 1));
- fileButton = new Button ("file selection");
- fileButton.addActionListener (this);
- p.add (fileButton);
+ for (Enumeration e = buttons.elements (); e.hasMoreElements (); )
+ {
+ p.add ((Button) e.nextElement ());
+ }
- labelButton = new Button ("labels");
- labelButton.addActionListener (this);
- p.add (labelButton);
+ sp.add (p);
+ add (sp, "Center");
- radioButton = new Button ("radio button");
- radioButton.addActionListener (this);
- p.add (radioButton);
-
- setSize (200, 400);
- }
+ setSize (200, 86 + (windows.size ()*22));
+ setTitle ("TestAWT");
+ }
public void actionPerformed (ActionEvent evt)
- {
- Button source = (Button) evt.getSource ();
+ {
+ Button source = (Button) evt.getSource ();
- System.out.println (source);
- System.out.println (closeButton);
-
- if (source==closeButton)
- {
- dispose();
- System.exit (0);
- }
- if (source==buttonsButton)
- {
- if (buttonsWindow == null)
- {
- buttonsWindow = new ButtonsWindow (this);
- buttonsWindow.show();
- }
- else
- buttonsWindow.dispose();
- }
- if (source==dialogButton)
- {
- if (dialogWindow == null)
- {
- dialogWindow = new DialogWindow (this);
- dialogWindow.show();
- }
- else
- dialogWindow.dispose();
- }
- if (source==cursorsButton)
- {
- if (cursorsWindow == null)
- {
- cursorsWindow = new CursorsWindow (this);
- cursorsWindow.show();
- }
- else
- cursorsWindow.dispose();
- }
- if (source==textFieldButton)
- {
- if (textFieldWindow == null)
- {
- textFieldWindow = new TextFieldWindow (this);
- textFieldWindow.show();
- }
- else
- textFieldWindow.dispose();
- }
- if (source==fileButton)
- {
- if (fileWindow == null)
- {
- fileWindow = new FileWindow (this);
- fileWindow.show();
- }
- else
- fileWindow.dispose();
- }
- if (source==labelButton)
- {
- if (labelWindow == null)
- {
- labelWindow = new LabelWindow (this);
- labelWindow.show();
- }
- else
- labelWindow.dispose();
- }
- if (source==radioButton)
- {
- if (radioWindow == null)
- {
- radioWindow = new RadioWindow (this);
- radioWindow.show();
- }
- else
- radioWindow.dispose();
- }
- }
+ System.out.println (source);
+ System.out.println (closeButton);
+
+ if (source==closeButton)
+ {
+ dispose();
+ System.exit (0);
+ }
+
+ Window w = (Window) windows.get (source);
+ if (w.isVisible ())
+ w.dispose ();
+ else
+ w.setVisible (true);
+ }
}
-class ButtonsWindow extends PrettyFrame
+class ButtonsWindow extends SubFrame implements ActionListener
{
- static Frame f;
- MainWindow mainWindow;
-
- public ButtonsWindow (MainWindow mw)
- {
- super ("GtkButton");
+ Button b[] = new Button [9];
- mainWindow=mw;
- Panel p = new Panel ();
- p.setLayout (new GridLayout (0, 3, 5, 5));
+ public void init ()
+ {
+ initted = true;
+ Panel p = new Panel ();
+ p.setLayout (new GridLayout (0, 3, 5, 5));
- final Button b[] = new Button [9];
-
- for (int i=0; i<9; i++)
+ 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]);
+ p.add (b[8]);
+ p.add (b[1]);
+ p.add (b[7]);
+ 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();
+ }
+ });
+ add (cb, "South");
+ setTitle ("Buttons");
+ pack ();
+ }
- p.add (b[0]);
- p.add (b[6]);
- p.add (b[4]);
- p.add (b[8]);
- p.add (b[1]);
- p.add (b[7]);
- p.add (b[3]);
- p.add (b[5]);
- p.add (b[2]);
-
- for (int i=0; i<9; i++)
- {
- final int i2=((i+1)==9)?0:(i+1);
-
- b[i].addActionListener(new ActionListener () {
- public void actionPerformed (ActionEvent e) {
- if (b[i2].isVisible())
- b[i2].setVisible(false);
- else
- b[i2].setVisible(true);
- }
- });
- }
-
- add (p, "North");
-
- Button cb = new Button ("close");
- cb.addActionListener(new ActionListener () {
- public void actionPerformed (ActionEvent e) {
- dispose();
- }
- });
- add (cb, "South");
-
- setTitle ("GtkButton");
- pack ();
- }
-
- public void dispose()
- {
- mainWindow.buttonsWindow=null;
- super.dispose();
- }
+ 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);
+ }
+ }
+ }
}
-class DialogWindow extends Dialog
+class DialogWindow extends Dialog implements SubWindow
{
- static Frame f;
- MainWindow mainWindow;
Label text;
+ boolean initted = false;
- public DialogWindow (MainWindow mw)
- {
- super (mw);
+ public DialogWindow (Frame f)
+ {
+ super (f);
+ }
- mainWindow = mw;
+ public void setVisible (boolean visible)
+ {
+ if (!initted && visible)
+ init();
+ super.setVisible (visible);
+ }
- setModal (true);
+ public void init ()
+ {
+ text = new Label ("Dialog Test");
+ text.setAlignment (Label.CENTER);
- text = new Label ("Dialog Test");
- text.setAlignment (Label.CENTER);
+ add (text, "North");
+ text.setVisible (false);
- add (text, "North");
- text.setVisible (false);
+ Panel p = new PrettyPanel();
- Panel p = new PrettyPanel();
-
- Button cb = new Button ("OK");
- cb.addActionListener(new ActionListener () {
- public void actionPerformed (ActionEvent e) {
+ Button cb = new Button ("OK");
+ cb.addActionListener(new ActionListener () {
+ public void actionPerformed (ActionEvent e)
+ {
dispose();
- }
- });
- p.setLayout (new GridLayout (1, 2));
- ((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);
+ }
+ });
+
+ p.setLayout (new GridLayout (1, 2));
+ ((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);
+ text.setVisible (true);
doLayout();
}
- });
-
- add (p, "South");
- setTitle ("AWTDialog");
- setSize (130, 70);
- }
-
- public void dispose()
- {
- mainWindow.dialogWindow=null;
- super.dispose();
- }
+ });
+
+ add (p, "South");
+ setTitle ("Dialog");
+ setSize (130, 70);
+ }
}
-class CursorsWindow extends PrettyFrame implements ItemListener
+class CursorsWindow extends SubFrame implements ItemListener
{
- static Frame f;
- MainWindow mainWindow;
Choice cursorChoice;
Canvas cursorCanvas;
- public CursorsWindow (MainWindow mw)
- {
- super ("Cursors");
-
- mainWindow = mw;
-
- cursorChoice = new Choice();
- cursorChoice.add ("Default");
- cursorChoice.add ("Crosshair");
- cursorChoice.add ("Text");
- cursorChoice.add ("Wait");
- cursorChoice.add ("Southwest Resize");
- cursorChoice.add ("Southeast Resize");
- cursorChoice.add ("Northwest Resize");
- cursorChoice.add ("Northeast Resize");
- cursorChoice.add ("North Resize");
- cursorChoice.add ("South Resize");
- cursorChoice.add ("West Resize");
- 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 = 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 (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();
- }
- });
-
- add (cb, "South");
-
- setSize (160, 180);
- }
+ public void init ()
+ {
+ cursorChoice = new Choice();
+ cursorChoice.add ("Default");
+ cursorChoice.add ("Crosshair");
+ cursorChoice.add ("Text");
+ cursorChoice.add ("Wait");
+ cursorChoice.add ("Southwest Resize");
+ cursorChoice.add ("Southeast Resize");
+ cursorChoice.add ("Northwest Resize");
+ cursorChoice.add ("Northeast Resize");
+ cursorChoice.add ("North Resize");
+ cursorChoice.add ("South Resize");
+ cursorChoice.add ("West Resize");
+ 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 = 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 (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();
+ }
+ });
+
+ add (cb, "South");
+ setTitle ("Cursors");
+ setSize (160, 180);
+ }
public void itemStateChanged (ItemEvent e)
- {
- System.out.println (cursorChoice.getSelectedIndex());
- cursorCanvas.setCursor (Cursor.getPredefinedCursor (cursorChoice.getSelectedIndex()));
- }
-
- public void dispose()
- {
- mainWindow.cursorsWindow=null;
- super.dispose();
- }
+ {
+ System.out.println (cursorChoice.getSelectedIndex());
+ cursorCanvas.setCursor (Cursor.getPredefinedCursor (cursorChoice.getSelectedIndex()));
+ }
}
-
-class TextFieldWindow extends PrettyFrame implements ItemListener
+class TextFieldWindow extends SubFrame implements ItemListener
{
- static Frame f;
- MainWindow mainWindow;
Checkbox editable, visible, sensitive;
TextField text;
- public TextFieldWindow (MainWindow mw)
- {
- super ("TextField");
-
- mainWindow = mw;
-
- 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);
+ public void init ()
+ {
+ initted = true;
+ text = new TextField ("hello world");
+ add (text, "North");
- editable = new Checkbox("Editable", true);
- p.add (editable);
- editable.addItemListener (this);
+ Panel p = new Panel();
+ p.setLayout (new GridLayout (3, 1));
+ ((GridLayout) p.getLayout ()).setHgap (5);
+ ((GridLayout) p.getLayout ()).setVgap (5);
- visible = new Checkbox("Visible", true);
- p.add (visible);
- visible.addItemListener (this);
+ editable = new Checkbox("Editable", true);
+ p.add (editable);
+ editable.addItemListener (this);
- sensitive = new Checkbox("Sensitive", true);
- p.add (sensitive);
- sensitive.addItemListener (this);
+ visible = new Checkbox("Visible", true);
+ p.add (visible);
+ visible.addItemListener (this);
- add (p, "Center");
+ sensitive = new Checkbox("Sensitive", true);
+ p.add (sensitive);
+ sensitive.addItemListener (this);
- Button cb = new Button ("Close");
- cb.addActionListener(new ActionListener () {
- public void actionPerformed (ActionEvent e) {
- dispose();
- }
- });
+ add (p, "Center");
- add (cb, "South");
+ Button cb = new Button ("Close");
+ cb.addActionListener(new ActionListener () {
+ public void actionPerformed (ActionEvent e) {
+ dispose();
+ }
+ });
- setSize (160, 180);
- }
+ add (cb, "South");
+ setTitle ("TextField");
+ setSize (160, 180);
+ }
public void itemStateChanged (ItemEvent e)
- {
- boolean on=true;
-
- if (e.getStateChange () == ItemEvent.DESELECTED)
- on=false;
- if (e.getSource() == editable)
- text.setEditable (on);
- if (e.getSource() == visible)
- if (on)
- text.setEchoChar ((char) 0);
- else
- text.setEchoChar ('*');
- if (e.getSource() == sensitive)
- text.setEnabled (on);
+ {
+ boolean on=true;
+
+ if (e.getStateChange () == ItemEvent.DESELECTED)
+ on=false;
+ if (e.getSource() == editable)
+ text.setEditable (on);
+ if (e.getSource() == visible)
+ if (on)
+ text.setEchoChar ((char) 0);
+ else
+ text.setEchoChar ('*');
+ if (e.getSource() == sensitive)
+ text.setEnabled (on);
- }
-
- public void dispose()
- {
- mainWindow.textFieldWindow=null;
- super.dispose();
- }
+ }
}
-
-class FileWindow extends FileDialog
+class FileWindow extends FileDialog implements SubWindow
{
- static FileDialog f;
- MainWindow mainWindow;
+ boolean initted = false;
public FileWindow (MainWindow mw)
- {
- super (mw);
- mainWindow = mw;
- }
-
- public void dispose()
- {
- mainWindow.fileWindow=null;
- super.dispose();
- }
+ {
+ super (mw);
+ }
+
+ public void setVisible (boolean visible)
+ {
+ if (!initted && visible)
+ init();
+ super.setVisible (visible);
+ }
+
+ public void init()
+ {
+ initted = true;
+ }
}
-class LabelWindow extends PrettyFrame
+class LabelWindow extends SubFrame
{
- static Frame f;
- MainWindow mainWindow;
-
- public LabelWindow (MainWindow mw)
- {
- super ("Labels");
-
- mainWindow = mw;
-
- 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();
- }
- });
-
- add (cb, "South");
-
- setSize (160, 180);
- }
-
- public void dispose()
- {
- mainWindow.labelWindow=null;
- super.dispose();
- }
+ 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();
+ }
+ });
+
+ add (cb, "South");
+ setTitle ("Labels");
+ setSize (160, 180);
+ }
}
-class
-RadioWindow extends PrettyFrame
+class RadioWindow extends SubFrame
{
- static Frame f;
- MainWindow mainWindow;
-
- public RadioWindow (MainWindow mw)
- {
- super ("Radio Buttons");
-
- mainWindow = mw;
-
- Panel p = new Panel();
- p.setLayout (new GridLayout (3, 1));
- ((GridLayout) p.getLayout ()).setHgap (5);
- ((GridLayout) p.getLayout ()).setVgap (5);
-
- CheckboxGroup cg = new CheckboxGroup();
- p.add(new Checkbox("button1", cg, true));
- p.add(new Checkbox("button2", cg, false));
- p.add(new Checkbox("button3", cg, false));
-
- add (p, "Center");
-
- Button cb = new Button ("Close");
- cb.addActionListener(new ActionListener () {
- public void actionPerformed (ActionEvent e) {
- dispose();
- }
- });
-
- add (cb, "South");
-
- setSize (85, 167);
- }
-
- public void dispose()
- {
- mainWindow.radioWindow=null;
- super.dispose();
- }
+ 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);
+
+ CheckboxGroup cg = new CheckboxGroup();
+ p.add(new Checkbox("button1", cg, true));
+ p.add(new Checkbox("button2", cg, false));
+ p.add(new Checkbox("button3", cg, false));
+
+ add (p, "Center");
+
+ Button cb = new Button ("Close");
+ cb.addActionListener(new ActionListener () {
+ public void actionPerformed (ActionEvent e) {
+ dispose();
+ }
+ });
+
+ add (cb, "South");
+ setTitle ("Radio Buttons");
+ setSize (85, 167);
+ }
}
+