Skip to content

Commit 45138ce

Browse files
hansonrhansonr
authored andcommitted
AWT/swing support for JSFrame, JSDialog, JSPanel
1 parent 180f0d9 commit 45138ce

31 files changed

+203
-187
lines changed

sources/net.sf.j2s.java.core/src/java/applet/AppletContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public interface AppletContext {
7878
* @return the applet with the given name, or <code>null</code> if
7979
* not found.
8080
*/
81-
Applet getApplet(String name);
81+
JSApplet getApplet(String name);
8282

8383
/**
8484
* Finds all the applets in the document represented by this applet
@@ -87,7 +87,7 @@ public interface AppletContext {
8787
* @return an enumeration of all applets in the document represented by
8888
* this applet context.
8989
*/
90-
Enumeration<Applet> getApplets();
90+
Enumeration<JSApplet> getApplets();
9191

9292
/**
9393
* Requests that the browser or applet viewer show the Web page

sources/net.sf.j2s.java.core/src/java/awt/Component.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
*/
2828
package java.awt;
2929

30-
import java.applet.Applet;
3130
import java.awt.dnd.DropTarget;
3231
import java.awt.event.ActionEvent;
3332
import java.awt.event.AdjustmentEvent;
@@ -4156,8 +4155,8 @@ boolean dispatchMouseWheelToAncestor(MouseWheelEvent e) {
41564155

41574156
boolean checkWindowClosingException() {
41584157
if (windowClosingException != null) {
4159-
if (this instanceof Dialog) {
4160-
((Dialog) this).interruptBlocking();
4158+
if (this instanceof JSDialog) {
4159+
((JSDialog) this).interruptBlocking();
41614160
} else {
41624161
windowClosingException.fillInStackTrace();
41634162
windowClosingException.printStackTrace();

sources/net.sf.j2s.java.core/src/java/awt/DefaultKeyboardFocusManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ public String toString() {
105105
}
106106

107107
private Window getOwningFrameDialog(Window window) {
108-
while (window != null && !(window instanceof Frame ||
109-
window instanceof Dialog)) {
108+
while (window != null && !(window instanceof JSFrame ||
109+
window instanceof JSDialog)) {
110110
window = (Window)window.getParent();
111111
}
112112
return window;

sources/net.sf.j2s.java.core/src/java/awt/GraphicsConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
* } </pre>
9898
*
9999
* @see Window
100-
* @see Frame
100+
* @see JSFrame
101101
* @see GraphicsEnvironment
102102
* @see GraphicsDevice
103103
* @see swingjs.JSGraphicsConfiguration

sources/net.sf.j2s.java.core/src/java/awt/JSPanel.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* @see java.awt.FlowLayout
4242
* @since JDK1.0
4343
*/
44-
public class Panel extends Container {
44+
public class JSPanel extends Container {
4545
private static final String base = "panel";
4646
private static int nameCounter = 0;
4747

@@ -56,7 +56,7 @@ public class Panel extends Container {
5656
* <code>FlowLayout</code> class.
5757
*
5858
*/
59-
public Panel() {
59+
public JSPanel() {
6060
this(new FlowLayout());
6161
}
6262

@@ -72,7 +72,7 @@ protected boolean canPaint() {
7272
* @param layout the layout manager for this panel.
7373
* @since JDK1.1
7474
*/
75-
public Panel(LayoutManager layout) {
75+
public JSPanel(LayoutManager layout) {
7676
setAppContext();
7777
setLayout(layout);
7878
}
@@ -83,9 +83,9 @@ public Panel(LayoutManager layout) {
8383
*/
8484
@Override
8585
String constructComponentName() {
86-
synchronized (Panel.class) {
86+
// synchronized (JSPanel.class) {
8787
return base + nameCounter++;
88-
}
88+
// }
8989
}
9090

9191
/**
@@ -103,7 +103,7 @@ public void addNotify() {
103103

104104
@Override
105105
protected ComponentPeer getOrCreatePeer() {
106-
return (ui == null ? null : peer == null ? (peer = getToolkit().createPanel(this)) : peer);
106+
return (ui == null ? null : peer == null ? (peer = getToolkit().createPanel((Panel) (Object) this)) : peer);
107107
}
108108

109109

sources/net.sf.j2s.java.core/src/java/awt/KeyboardFocusManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@
9898
* @author David Mendenhall
9999
*
100100
* @see Window
101-
* @see Frame
102-
* @see Dialog
101+
* @see JSFrame
102+
* @see JSDialog
103103
* @see java.awt.event.FocusEvent
104104
* @see java.awt.event.WindowEvent
105105
* @see java.awt.event.KeyEvent
@@ -2555,8 +2555,8 @@ static Window markClearGlobalFocusOwner() {
25552555
? SunToolkit.getContainingWindow(hwFocusRequest.heavyweight)
25562556
: nativeFocusedWindow);
25572557
while (activeWindow != null &&
2558-
!((activeWindow instanceof Frame) ||
2559-
(activeWindow instanceof Dialog)))
2558+
!((activeWindow instanceof JSFrame) ||
2559+
(activeWindow instanceof JSDialog)))
25602560
{
25612561
activeWindow = activeWindow.getParent_NoClientCode();
25622562
}

sources/net.sf.j2s.java.core/src/java/awt/ModalEventFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ int compareTo(ModalEventFilter another) {
107107
c = c.getParent_NoClientCode();
108108
}
109109
// check if one dialog blocks (directly or indirectly) another
110-
Dialog blocker = modalDialog.getModalBlocker();
110+
Dialog blocker = ((a2s.Dialog) modalDialog).getModalBlocker();
111111
while (blocker != null) {
112112
if (blocker == anotherDialog) {
113113
return -1;

sources/net.sf.j2s.java.core/src/java/awt/Toolkit.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,10 @@ public abstract class Toolkit {
285285
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
286286
* returns true
287287
* @see java.awt.GraphicsEnvironment#isHeadless
288-
* @see java.awt.Frame
288+
* @see java.awt.JSFrame
289289
* @see java.awt.peer.FramePeer
290290
*/
291-
protected abstract FramePeer createFrame(Frame target);
291+
protected abstract FramePeer createFrame(JSFrame target);
292292
//
293293
// /**
294294
// * Creates this toolkit's implementation of <code>Canvas</code> using
@@ -305,7 +305,7 @@ public abstract class Toolkit {
305305
* the specified peer interface.
306306
* @param target the panel to be implemented.
307307
* @return this toolkit's implementation of <code>Panel</code>.
308-
* @see java.awt.Panel
308+
* @see java.awt.JSPanel
309309
* @see java.awt.peer.PanelPeer
310310
*/
311311
protected abstract PanelPeer createPanel(Panel target);
@@ -331,7 +331,7 @@ public abstract class Toolkit {
331331
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
332332
* returns true
333333
* @see java.awt.GraphicsEnvironment#isHeadless
334-
* @see java.awt.Dialog
334+
* @see java.awt.JSDialog
335335
* @see java.awt.peer.DialogPeer
336336
*/
337337
protected abstract java.awt.peer.DialogPeer createDialog(Dialog target)
@@ -1174,7 +1174,7 @@ public abstract Image createImage(byte[] imagedata,
11741174
* @see java.lang.RuntimePermission
11751175
* @since JDK1.1
11761176
*/
1177-
public abstract PrintJob getPrintJob(Frame frame, String jobtitle,
1177+
public abstract PrintJob getPrintJob(JSFrame frame, String jobtitle,
11781178
Properties props);
11791179

11801180
/**
@@ -1226,7 +1226,7 @@ public abstract PrintJob getPrintJob(Frame frame, String jobtitle,
12261226
* @see java.awt.PageAttributes
12271227
* @since 1.3
12281228
*/
1229-
public PrintJob getPrintJob(Frame frame, String jobtitle,
1229+
public PrintJob getPrintJob(JSFrame frame, String jobtitle,
12301230
JobAttributes jobAttributes,
12311231
PageAttributes pageAttributes) {
12321232
// Override to add printing support with new job/page control classes
@@ -1553,13 +1553,13 @@ public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
15531553
* @exception HeadlessException
15541554
* if <code>GraphicsEnvironment.isHeadless()</code>
15551555
* returns <code>true</code>.
1556-
* @see java.awt.Frame#setExtendedState
1556+
* @see java.awt.JSFrame#setExtendedState
15571557
* @since 1.4
15581558
*/
15591559
public boolean isFrameStateSupported(int state)
15601560

15611561
{
1562-
return (state == Frame.NORMAL); // others are not guaranteed
1562+
return (state == JSFrame.NORMAL); // others are not guaranteed
15631563
}
15641564

15651565
/**
@@ -1825,8 +1825,8 @@ public boolean isAlwaysOnTopSupported() {
18251825
* type, <code>false</code> otherwise
18261826
*
18271827
* @see java.awt.Dialog.ModalityType
1828-
* @see java.awt.Dialog#getModalityType
1829-
* @see java.awt.Dialog#setModalityType
1828+
* @see java.awt.JSDialog#getModalityType
1829+
* @see java.awt.JSDialog#setModalityType
18301830
*
18311831
* @since 1.6
18321832
*/

sources/net.sf.j2s.java.core/src/java/awt/Window.java

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,7 @@
2727
*/
2828
package java.awt;
2929

30-
//import java.lang.ref.WeakReference;
31-
//import java.lang.reflect.InvocationTargetException;
32-
//import java.awt.AWTPermission;
33-
//import java.awt.HeadlessException;
34-
import java.awt.KeyboardFocusManager;
35-
import java.util.ArrayList;
36-
import java.util.Arrays;
37-
import java.util.EventListener;
38-
import java.util.Set;
39-
import java.util.Vector;
40-
41-
import java.applet.Applet;
30+
import java.applet.JSApplet;
4231
import java.awt.event.ComponentEvent;
4332
import java.awt.event.KeyEvent;
4433
import java.awt.event.MouseWheelEvent;
@@ -49,8 +38,14 @@
4938
import java.awt.peer.ComponentPeer;
5039
import java.awt.peer.WindowPeer;
5140
import java.beans.PropertyChangeListener;
41+
import java.util.ArrayList;
42+
import java.util.Arrays;
43+
import java.util.EventListener;
5244
import java.util.Locale;
5345
import java.util.ResourceBundle;
46+
import java.util.Set;
47+
import java.util.Vector;
48+
5449
import javax.swing.JComponent;
5550
import javax.swing.JLayeredPane;
5651
import javax.swing.JRootPane;
@@ -62,7 +57,6 @@
6257
//import java.util.concurrent.atomic.AtomicBoolean;
6358
//import java.util.logging.Logger;
6459
import swingjs.JSUtil;
65-
import swingjs.plaf.JSComponentUI;
6660

6761
/**
6862
*
@@ -232,7 +226,7 @@ public class Window extends JComponent {
232226
*
233227
* @since 1.6
234228
*/
235-
transient Dialog modalBlocker;
229+
transient JSDialog modalBlocker;
236230

237231
/**
238232
* @serial
@@ -924,7 +918,7 @@ public void show() {
924918
// // should be raised to front
925919
// modalBlocker.toFront_NoClientCode();
926920
// }
927-
if (this instanceof Frame || this instanceof Dialog) {
921+
if (this instanceof JSFrame || this instanceof JSDialog) {
928922
updateChildFocusableWindowState(this);
929923
}
930924
}
@@ -1369,7 +1363,7 @@ boolean isModalBlocked() {
13691363
return modalBlocker != null;
13701364
}
13711365

1372-
void setModalBlocked(Dialog blocker, boolean blocked, boolean peerCall) {
1366+
void setModalBlocked(JSDialog blocker, boolean blocked, boolean peerCall) {
13731367
// this.modalBlocker = blocked ? blocker : null;
13741368
// if (peerCall) {
13751369
// WindowPeer peer = (WindowPeer)this.peer;
@@ -1379,8 +1373,12 @@ void setModalBlocked(Dialog blocker, boolean blocked, boolean peerCall) {
13791373
// }
13801374
}
13811375

1382-
Dialog getModalBlocker() {
1383-
return modalBlocker;
1376+
void setModalBlocked(Dialog blocker, boolean blocked, boolean peerCall) {
1377+
setModalBlocked((JSDialog) blocker, blocked, peerCall);
1378+
}
1379+
1380+
public Dialog getModalBlocker() {
1381+
return (Dialog)(Object) modalBlocker;
13841382
}
13851383

13861384
/*
@@ -1451,7 +1449,7 @@ private static Window[] getWindows(AppContext appContext) {
14511449
* dialogs such as component positions, <code>LayoutManager</code>s
14521450
* or serialization.
14531451
*
1454-
* @see Frame#getFrames
1452+
* @see JSFrame#getFrames
14551453
* @see Window#getOwnerlessWindows
14561454
*
14571455
* @since 1.6
@@ -1473,7 +1471,7 @@ public static Window[] getWindows() {
14731471
* dialogs such as component positions, <code>LayoutManager</code>s
14741472
* or serialization.
14751473
*
1476-
* @see Frame#getFrames
1474+
* @see JSFrame#getFrames
14771475
* @see Window#getWindows()
14781476
*
14791477
* @since 1.6
@@ -1499,7 +1497,7 @@ public static Window[] getOwnerlessWindows() {
14991497
return ownerless;
15001498
}
15011499

1502-
Window getDocumentRoot() {
1500+
public Window getDocumentRoot() {
15031501
synchronized (getTreeLock()) {
15041502
Window w = this;
15051503
while (w.getOwner() != null) {
@@ -1521,7 +1519,7 @@ Window getDocumentRoot() {
15211519
* effect until it is hidden and then shown again.
15221520
*
15231521
* @param exclusionType the modal exclusion type for this window; a <code>null</code>
1524-
* value is equivivalent to {@link Dialog.ModalExclusionType#NO_EXCLUDE
1522+
* value is equivivalent to {@link JSDialog.ModalExclusionType#NO_EXCLUDE
15251523
* NO_EXCLUDE}
15261524
* @throws SecurityException if the calling thread does not have permission
15271525
* to set the modal exclusion property to the window with the given
@@ -2344,7 +2342,7 @@ public final boolean isFocusableWindow() {
23442342
}
23452343

23462344
// All other tests apply only to Windows.
2347-
if (this instanceof Frame || this instanceof Dialog) {
2345+
if (this instanceof JSFrame || this instanceof JSDialog) {
23482346
return true;
23492347
}
23502348

@@ -2359,7 +2357,7 @@ public final boolean isFocusableWindow() {
23592357
for (Window owner = getOwner(); owner != null;
23602358
owner = owner.getOwner())
23612359
{
2362-
if (owner instanceof Frame || owner instanceof Dialog) {
2360+
if (owner instanceof JSFrame || owner instanceof JSDialog) {
23632361
return owner.isShowing();
23642362
}
23652363
}
@@ -2979,12 +2977,12 @@ public void setLocationRelativeTo(Component c) {
29792977
Container root=null;
29802978

29812979
if (c != null) {
2982-
if (c instanceof Window || c instanceof Applet) {
2980+
if (c instanceof Window || c instanceof JSApplet) {
29832981
root = (Container)c;
29842982
} else {
29852983
Container parent;
29862984
for(parent = c.getParent() ; parent != null ; parent = parent.getParent()) {
2987-
if (parent instanceof Window || parent instanceof Applet) {
2985+
if (parent instanceof Window || parent instanceof JSApplet) {
29882986
root = parent;
29892987
break;
29902988
}

sources/net.sf.j2s.java.core/src/java/awt/event/WindowEvent.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public class WindowEvent extends ComponentEvent {
8888
* the window has been changed from a normal to a minimized state.
8989
* For many platforms, a minimized window is displayed as
9090
* the icon specified in the window's iconImage property.
91-
* @see java.awt.Frame#setIconImage
91+
* @see java.awt.JSFrame#setIconImage
9292
*/
9393
public static final int WINDOW_ICONIFIED = 3 + WINDOW_FIRST; //Event.WINDOW_ICONIFY
9494

@@ -325,7 +325,7 @@ public Window getOppositeWindow() {
325325
* </ul>
326326
*
327327
* @return a bitwise mask of the previous window state
328-
* @see java.awt.Frame#getExtendedState()
328+
* @see java.awt.JSFrame#getExtendedState()
329329
* @since 1.4
330330
*/
331331
public int getOldState() {
@@ -348,7 +348,7 @@ public int getOldState() {
348348
* </ul>
349349
*
350350
* @return a bitwise mask of the new window state
351-
* @see java.awt.Frame#getExtendedState()
351+
* @see java.awt.JSFrame#getExtendedState()
352352
* @since 1.4
353353
*/
354354
public int getNewState() {

0 commit comments

Comments
 (0)