Skip to content

Commit 253cb6a

Browse files
hansonrhansonr
authored andcommitted
JInternalFrame should not addNotify the way JFrame does
1 parent 3bfb4f0 commit 253cb6a

File tree

3 files changed

+27
-19
lines changed

3 files changed

+27
-19
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,4 +722,9 @@ protected boolean canPaint() {
722722
return 秘isDesktop;
723723
}
724724

725+
protected void 秘frameAddNodify(JRootPane rootPane) {
726+
addNotify(); // BH added; applet will not do this automatically
727+
rootPane.addNotify(); // builds a peer for the root pane
728+
}
729+
725730
}

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

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -245,25 +245,24 @@ public JFrame(String title) {
245245
* This constructor sets the component's locale property to the value returned
246246
* by <code>JComponent.getDefaultLocale</code>.
247247
*
248-
* @param title
249-
* the title to be displayed in the frame's border. A
250-
* <code>null</code> value is treated as an empty string, "".
251-
* @param gc
252-
* the <code>GraphicsConfiguration</code> that is used to construct
253-
* the new <code>JFrame</code> with; if <code>gc</code> is
254-
* <code>null</code>, the system default
255-
* <code>GraphicsConfiguration</code> is assumed
256-
* @exception IllegalArgumentException
257-
* if <code>gc</code> is not from a screen device. This exception
258-
* is always thrown when GraphicsEnvironment.isHeadless() returns
259-
* true.
248+
* @param title the title to be displayed in the frame's border. A
249+
* <code>null</code> value is treated as an empty string, "".
250+
* @param gc the <code>GraphicsConfiguration</code> that is used to construct
251+
* the new <code>JFrame</code> with; if <code>gc</code> is
252+
* <code>null</code>, the system default
253+
* <code>GraphicsConfiguration</code> is assumed
254+
* @exception IllegalArgumentException if <code>gc</code> is not from a screen
255+
* device. This exception is always thrown
256+
* when GraphicsEnvironment.isHeadless()
257+
* returns true.
260258
* @see java.awt.GraphicsEnvironment#isHeadless
261259
* @see JComponent#getDefaultLocale
262260
* @since 1.3
263261
*
264262
*/
265263
public JFrame(String title, GraphicsConfiguration gc) {
266-
秘paintClass = 秘updateClass = /**@j2sNative C$ || */null;
264+
秘paintClass = 秘updateClass = /** @j2sNative C$ || */
265+
null;
267266
initTitleGC(title, gc);
268267
enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.WINDOW_EVENT_MASK);
269268
setLocale(JComponent.getDefaultLocale());
@@ -272,17 +271,15 @@ public JFrame(String title, GraphicsConfiguration gc) {
272271
setBackground(UIManager.getColor("control"));
273272
setRootPaneCheckingEnabled(true);
274273
if (JFrame.isDefaultLookAndFeelDecorated()) {
275-
boolean supportsWindowDecorations = UIManager.getLookAndFeel()
276-
.getSupportsWindowDecorations();
274+
boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations();
277275
if (supportsWindowDecorations) {
278276
setUndecorated(true);
279277
getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
280278
}
281279
}
282-
updateUI();
283-
addNotify(); // BH added; applet will not do this automatically
284-
rootPane.addNotify(); // builds a peer for the root pane
285-
}
280+
updateUI();
281+
秘frameAddNodify(rootPane);
282+
}
286283

287284
public JFrame(Object object, Object object2, Object object3, Object object4) {
288285
// For SwingJS JInternalFrame constructor

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,4 +2095,10 @@ public void addNotify() {
20952095
((JComponent) parent).getTopLevelAncestor().秘setIsDesktop();
20962096
}
20972097

2098+
@Override
2099+
protected void 秘frameAddNodify(JRootPane rootPane) {
2100+
// actual JFrame only
2101+
}
2102+
2103+
20982104
}

0 commit comments

Comments
 (0)