Skip to content

Commit c7c7761

Browse files
hansonrhansonr
authored andcommitted
JSFrame and JSDialog need parameter aliasing as Frame, Dialog
1 parent 3d3558b commit c7c7761

File tree

12 files changed

+1483
-1391
lines changed

12 files changed

+1483
-1391
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ public class JSDialog extends Window {
229229
public JSDialog(JSFrame owner) {
230230
this(owner, "", false);
231231
}
232+
public JSDialog(Frame owner) {
233+
this(owner, "", false);
234+
}
232235

233236
/**
234237
* Constructs an initially invisible <code>Dialog</code> with the specified
@@ -256,6 +259,10 @@ public JSDialog(JSFrame owner, boolean modal) {
256259
this(owner, "", modal);
257260
}
258261

262+
public JSDialog(Frame owner, boolean modal) {
263+
this(owner, "", modal);
264+
}
265+
259266
/**
260267
* Constructs an initially invisible, modeless <code>Dialog</code> with
261268
* the specified owner <code>Frame</code> and title.
@@ -277,6 +284,10 @@ public JSDialog(JSFrame owner, String title) {
277284
this(owner, title, false);
278285
}
279286

287+
public JSDialog(Frame owner, String title) {
288+
this(owner, title, false);
289+
}
290+
280291
/**
281292
* Constructs an initially invisible <code>Dialog</code> with the
282293
* specified owner <code>Frame</code>, title and modality.
@@ -307,6 +318,10 @@ public JSDialog(JSFrame owner, String title, boolean modal) {
307318
this(owner, title, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
308319
}
309320

321+
public JSDialog(Frame owner, String title, boolean modal) {
322+
this(owner, title, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
323+
}
324+
310325
/**
311326
* Constructs an initially invisible <code>Dialog</code> with the specified owner
312327
* <code>Frame</code>, title, modality, and <code>GraphicsConfiguration</code>.
@@ -341,6 +356,11 @@ public JSDialog(JSFrame owner, String title, boolean modal,
341356
this(owner, title, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS, gc);
342357
}
343358

359+
public JSDialog(Frame owner, String title, boolean modal,
360+
GraphicsConfiguration gc) {
361+
this(owner, title, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS, gc);
362+
}
363+
344364
/**
345365
* Constructs an initially invisible, modeless <code>Dialog</code> with
346366
* the specified owner <code>Dialog</code> and an empty title.
@@ -358,6 +378,10 @@ public JSDialog(JSDialog owner) {
358378
this(owner, "", false);
359379
}
360380

381+
public JSDialog(Dialog owner) {
382+
this(owner, "", false);
383+
}
384+
361385
/**
362386
* Constructs an initially invisible, modeless <code>Dialog</code>
363387
* with the specified owner <code>Dialog</code> and title.
@@ -378,6 +402,10 @@ public JSDialog(JSDialog owner, String title) {
378402
this(owner, title, false);
379403
}
380404

405+
public JSDialog(Dialog owner, String title) {
406+
this(owner, title, false);
407+
}
408+
381409
/**
382410
* Constructs an initially invisible <code>Dialog</code> with the
383411
* specified owner <code>Dialog</code>, title, and modality.
@@ -408,6 +436,10 @@ public JSDialog(JSDialog owner, String title, boolean modal) {
408436
this(owner, title, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
409437
}
410438

439+
public JSDialog(Dialog owner, String title, boolean modal) {
440+
this(owner, title, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
441+
}
442+
411443
/**
412444
* Constructs an initially invisible <code>Dialog</code> with the
413445
* specified owner <code>Dialog</code>, title, modality and
@@ -445,6 +477,10 @@ public JSDialog(JSDialog owner, String title, boolean modal,
445477
this(owner, title, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS, gc);
446478
}
447479

480+
public JSDialog(Dialog owner, String title, boolean modal, GraphicsConfiguration gc) {
481+
this(owner, title, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS, gc);
482+
}
483+
448484
/**
449485
* Constructs an initially invisible, modeless <code>Dialog</code> with the
450486
* specified owner <code>Window</code> and an empty title.

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ public abstract class Toolkit {
289289
* @see java.awt.peer.FramePeer
290290
*/
291291
protected abstract FramePeer createFrame(JSFrame target);
292+
protected abstract FramePeer createFrame(Frame target);
292293
//
293294
// /**
294295
// * Creates this toolkit's implementation of <code>Canvas</code> using
@@ -1177,6 +1178,9 @@ public abstract Image createImage(byte[] imagedata,
11771178
public abstract PrintJob getPrintJob(JSFrame frame, String jobtitle,
11781179
Properties props);
11791180

1181+
public abstract PrintJob getPrintJob(Frame frame, String jobtitle,
1182+
Properties props);
1183+
11801184
/**
11811185
* Gets a <code>PrintJob</code> object which is the result of initiating
11821186
* a print operation on the toolkit's platform.
@@ -1240,6 +1244,18 @@ public PrintJob getPrintJob(JSFrame frame, String jobtitle,
12401244
}
12411245
}
12421246

1247+
public PrintJob getPrintJob(Frame frame, String jobtitle,
1248+
JobAttributes jobAttributes,
1249+
PageAttributes pageAttributes) {
1250+
if (this != Toolkit.getDefaultToolkit()) {
1251+
return Toolkit.getDefaultToolkit().getPrintJob(frame, jobtitle,
1252+
jobAttributes,
1253+
pageAttributes);
1254+
} else {
1255+
return getPrintJob(frame, jobtitle, null);
1256+
}
1257+
}
1258+
12431259
//
12441260
// /**
12451261
// * Emits an audio beep.

sources/net.sf.j2s.java.core/src/javax/swing/JColorChooser.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.awt.Dialog;
3636
import java.awt.JSDialog;
3737
import java.awt.FlowLayout;
38+
import java.awt.Frame;
3839
import java.awt.JSFrame;
3940

4041
//import java.io.IOException;
@@ -623,13 +624,27 @@ public ColorChooserDialog(JSFrame owner, String title, boolean modal, Component
623624
initColorChooserDialog(c, chooserPane, okListener, cancelListener);
624625
}
625626

627+
public ColorChooserDialog(Frame owner, String title, boolean modal, Component c, JColorChooser chooserPane,
628+
ActionListener okListener, ActionListener cancelListener) {
629+
super(owner, title, modal);
630+
this.disposeOnHide = false;
631+
initColorChooserDialog(c, chooserPane, okListener, cancelListener);
632+
}
633+
626634
ColorChooserDialog(JSFrame owner, String title, boolean modal, Component c, JColorChooser chooserPane,
627635
ActionListener okListener, ActionListener cancelListener, boolean disposeOnHide) {
628636
super(owner, title, modal);
629637
this.disposeOnHide = disposeOnHide;
630638
initColorChooserDialog(c, chooserPane, okListener, cancelListener);
631639
}
632640

641+
ColorChooserDialog(Frame owner, String title, boolean modal, Component c, JColorChooser chooserPane,
642+
ActionListener okListener, ActionListener cancelListener, boolean disposeOnHide) {
643+
super(owner, title, modal);
644+
this.disposeOnHide = disposeOnHide;
645+
initColorChooserDialog(c, chooserPane, okListener, cancelListener);
646+
}
647+
633648
private boolean haveActionListener;
634649

635650

sources/net.sf.j2s.java.core/src/javax/swing/JDialog.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.awt.Component;
3333
import java.awt.Container;
3434
import java.awt.Dialog;
35+
import java.awt.Frame;
3536
import java.awt.JSDialog;
3637
import java.awt.JSFrame;
3738
import java.awt.Graphics;
@@ -220,6 +221,10 @@ public JDialog(JSFrame owner) {
220221
this(owner, false);
221222
}
222223

224+
public JDialog(Frame owner) {
225+
this(owner, false);
226+
}
227+
223228
/**
224229
* Creates a dialog with the specified owner <code>Frame</code>, modality
225230
* and an empty title. If <code>owner</code> is <code>null</code>,
@@ -247,6 +252,10 @@ public JDialog(JSFrame owner, boolean modal) {
247252
this(owner, null, modal);
248253
}
249254

255+
public JDialog(Frame owner, boolean modal) {
256+
this(owner, null, modal);
257+
}
258+
250259
/**
251260
* Creates a modeless dialog with the specified title and
252261
* with the specified owner frame. If <code>owner</code>
@@ -274,6 +283,10 @@ public JDialog(JSFrame owner, String title) {
274283
this(owner, title, false);
275284
}
276285

286+
public JDialog(Frame owner, String title) {
287+
this(owner, title, false);
288+
}
289+
277290
/**
278291
* Creates a dialog with the specified title, owner <code>Frame</code>
279292
* and modality. If <code>owner</code> is <code>null</code>,
@@ -320,6 +333,17 @@ public JDialog(JSFrame owner, String title, boolean modal) {
320333
dialogInit();
321334
}
322335

336+
public JDialog(Frame owner, String title, boolean modal) {
337+
super(owner == null? SwingUtilities.getSharedOwnerFrame() : owner,
338+
title, modal);
339+
if (owner == null) {
340+
WindowListener ownerShutdownListener =
341+
(WindowListener)SwingUtilities.getSharedOwnerFrameShutdownListener();
342+
addWindowListener(ownerShutdownListener);
343+
}
344+
dialogInit();
345+
}
346+
323347
/**
324348
* Creates a dialog with the specified title,
325349
* owner <code>Frame</code>, modality and <code>GraphicsConfiguration</code>.
@@ -372,6 +396,16 @@ public JDialog(JSFrame owner, String title, boolean modal,
372396
dialogInit();
373397
}
374398

399+
public JDialog(Frame owner, String title, boolean modal, GraphicsConfiguration gc) {
400+
super(owner == null ? SwingUtilities.getSharedOwnerFrame() : owner, title, modal, gc);
401+
if (owner == null) {
402+
WindowListener ownerShutdownListener = (WindowListener) SwingUtilities
403+
.getSharedOwnerFrameShutdownListener();
404+
addWindowListener(ownerShutdownListener);
405+
}
406+
dialogInit();
407+
}
408+
375409
/**
376410
* Creates a modeless dialog without a title with the
377411
* specified <code>Dialog</code> as its owner.

sources/net.sf.j2s.java.core/src/javax/swing/JOptionPane.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.awt.Container;
3434
import java.awt.JSDialog;
3535
import java.awt.Dimension;
36+
import java.awt.Frame;
3637
import java.awt.JSFrame;
3738
import java.awt.HeadlessException;
3839
import java.awt.KeyboardFocusManager;
@@ -1799,6 +1800,14 @@ public static void setRootFrame(JSFrame newRootFrame) {
17991800
}
18001801
}
18011802

1803+
public static void setRootFrame(Frame newRootFrame) {
1804+
if (newRootFrame != null) {
1805+
SwingUtilities.appContextPut(sharedFrameKey, newRootFrame);
1806+
} else {
1807+
SwingUtilities.appContextRemove(sharedFrameKey);
1808+
}
1809+
}
1810+
18021811
/**
18031812
* Returns the <code>Frame</code> to use for the class methods in which a
18041813
* frame is not provided.

sources/net.sf.j2s.java.core/src/javax/swing/JWindow.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.awt.BorderLayout;
3131
import java.awt.Component;
3232
import java.awt.Container;
33+
import java.awt.Frame;
3334
import java.awt.JSFrame;
3435
import java.awt.Graphics;
3536
import java.awt.GraphicsConfiguration;
@@ -193,6 +194,16 @@ public JWindow(JSFrame owner) {
193194
windowInit();
194195
}
195196

197+
public JWindow(Frame owner) {
198+
super(owner == null ? SwingUtilities.getSharedOwnerFrame() : owner);
199+
if (owner == null) {
200+
WindowListener ownerShutdownListener = (WindowListener) SwingUtilities
201+
.getSharedOwnerFrameShutdownListener();
202+
addWindowListener(ownerShutdownListener);
203+
}
204+
windowInit();
205+
}
206+
196207
/**
197208
* Creates a window with the specified owner window. This window will not be
198209
* focusable unless its owner is showing on the screen. If <code>owner</code>

sources/net.sf.j2s.java.core/src/swingjs/JSDnD.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
import java.awt.event.MouseEvent;
1515
import java.io.IOException;
1616
import java.util.ArrayList;
17+
import java.util.Hashtable;
1718
import java.util.List;
19+
import java.util.Map;
1820

1921
import javax.swing.JComponent;
2022

@@ -161,6 +163,7 @@ static public class FileTransferable implements Transferable {
161163

162164
public FileTransferable(String name, byte[] data) {
163165
file = new JSFileBytes(name, data);
166+
JSUtil.cacheFileData(name, data);
164167
}
165168

166169
@Override

sources/net.sf.j2s.java.core/src/swingjs/JSFileBytes.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@
22

33
import java.io.File;
44

5+
/**
6+
* A File subclass used by JSDnD to save the bytes as well as the file name in a File object.
7+
*
8+
* Also caches the data.
9+
*
10+
* @author hansonr
11+
*
12+
*/
513
public class JSFileBytes extends File {
614

715
public JSFileBytes(String name, byte[] data) {
816
super(name);
9-
_bytes = data;
17+
_bytes = data;
18+
JSUtil.cacheFileData(name, data);
1019
}
1120

1221
public byte[] getData() {

sources/net.sf.j2s.java.core/src/swingjs/JSToolkit.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.awt.EventQueue;
1313
import java.awt.Font;
1414
import java.awt.FontMetrics;
15+
import java.awt.Frame;
1516
import java.awt.JSFrame;
1617
import java.awt.GraphicsConfiguration;
1718
import java.awt.Image;
@@ -524,6 +525,16 @@ public FramePeer createFrame(JSFrame target) {
524525
return (FramePeer) ((WindowPeer) ui).setFrame(target, true);
525526
}
526527

528+
@Override
529+
protected FramePeer createFrame(Frame target) {
530+
ComponentUI ui = target.getUI();
531+
if (ui == null)
532+
return null;
533+
if (JSUtil.debugging)
534+
System.out.println("JSToolkit creating Frame Peer for " + target.getClass().getName() + ": " + target.getClass().getName());
535+
return (FramePeer) ((WindowPeer) ui).setFrame(target, true);
536+
}
537+
527538
@Override
528539
public WindowPeer createWindow(Window target) {
529540
ComponentUI ui = target.getUI();
@@ -932,6 +943,13 @@ public PrintJob getPrintJob(JSFrame frame, String jobtitle, Properties props) {
932943
return (PrintJob) (Object) job;
933944
}
934945

946+
@Override
947+
public PrintJob getPrintJob(Frame frame, String jobtitle, Properties props) {
948+
JSPrintJob job = (JSPrintJob) JSUtil.getInstance("swingjs.JSPrintJob");
949+
job.setProperties(jobtitle, props);
950+
return (PrintJob) (Object) job;
951+
}
952+
935953
/**
936954
* Get a gnu.jpdf.PDFJob.
937955
*
@@ -945,6 +963,14 @@ public PrintJob getPrintJob(JSFrame frame, String jobtitle,
945963
return (PrintJob) (Object) job;
946964
}
947965

966+
@Override
967+
public PrintJob getPrintJob(Frame frame, String jobtitle,
968+
JobAttributes jobAttributes, PageAttributes pageAttributes) {
969+
JSPrintJob job = (JSPrintJob) JSUtil.getInstance("swingjs.JSPrintJob");
970+
job.setAttributes(jobtitle, jobAttributes, pageAttributes);
971+
return (PrintJob) (Object) job;
972+
}
973+
948974
public static ImageIcon paintImageForIcon(JComponent c, Icon icon) {
949975
return JSImagekit.createImageIcon(c, icon);
950976
}
@@ -964,4 +990,5 @@ public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
964990
return focusManager;
965991
}
966992

993+
967994
}

0 commit comments

Comments
 (0)