Skip to content

Commit 2d99ba4

Browse files
committed
Adds JInternalFrame/JDesktop
- preliminary only - no minimization/maximization - no checks for events, but seems to be working
1 parent 354999f commit 2d99ba4

File tree

96 files changed

+25715
-538
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+25715
-538
lines changed
69.2 KB
Binary file not shown.
2.73 MB
Binary file not shown.

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

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
import java.util.Map;
6666
import java.util.Vector;
6767

68+
import javax.swing.JInternalFrame;
69+
6870
import sun.awt.AppContext;
6971
import sun.awt.SunToolkit;
7072
import swingjs.JSToolkit;
@@ -174,7 +176,7 @@ public abstract class Component
174176
*
175177
* @see #getParent
176178
*/
177-
transient Container parent;
179+
protected transient Container parent;
178180

179181
/**
180182
* The <code>AppContext</code> of the component. Applets/Plugin may change
@@ -208,15 +210,15 @@ public AppContext getAppContext() {
208210
* @serial
209211
* @see #getSize
210212
*/
211-
int width;
213+
protected int width;
212214

213215
/**
214216
* The height of the component.
215217
*
216218
* @serial
217219
* @see #getSize
218220
*/
219-
int height;
221+
protected int height;
220222

221223
/**
222224
* The foreground color for this component. <code>foreground</code> can be
@@ -262,7 +264,7 @@ public AppContext getAppContext() {
262264
* @see #getCursor
263265
* @see #setCursor
264266
*/
265-
Cursor cursor;
267+
protected Cursor cursor;
266268

267269
/**
268270
* The locale for the component.
@@ -271,7 +273,7 @@ public AppContext getAppContext() {
271273
* @see #getLocale
272274
* @see #setLocale
273275
*/
274-
Locale locale;
276+
protected Locale locale;
275277

276278
/**
277279
* True when the object is visible. An object that is not visible is not
@@ -450,8 +452,8 @@ static class AWTTreeLock {
450452
* @serial
451453
* @see #dispatchEvent
452454
*/
453-
boolean newEventsOnly = false;
454-
transient ComponentListener componentListener;
455+
protected boolean newEventsOnly = false;
456+
protected transient ComponentListener componentListener;
455457
transient FocusListener focusListener;
456458
transient HierarchyListener hierarchyListener;
457459
transient HierarchyBoundsListener hierarchyBoundsListener;
@@ -461,7 +463,7 @@ static class AWTTreeLock {
461463
transient MouseWheelListener mouseWheelListener;
462464
transient InputMethodListener inputMethodListener;
463465

464-
transient RuntimeException windowClosingException = null;
466+
protected transient RuntimeException windowClosingException = null;
465467

466468
/** Internal, constants for serialization */
467469
final static String actionListenerK = "actionL";
@@ -495,7 +497,7 @@ static class AWTTreeLock {
495497
* @see #enableInputMethods
496498
* @see AWTEvent
497499
*/
498-
long eventMask = AWTEvent.INPUT_METHODS_ENABLED_MASK;
500+
protected long eventMask = AWTEvent.INPUT_METHODS_ENABLED_MASK;
499501

500502
/**
501503
* Static properties for incremental drawing.
@@ -581,7 +583,7 @@ private Object getChangeSupportLock() {
581583
// return acc;
582584
// }
583585
//
584-
boolean isPacked = false;
586+
protected boolean isPacked = false;
585587

586588
/**
587589
* Pseudoparameter for direct Geometry API (setLocation, setBounds setSize
@@ -1134,7 +1136,7 @@ public boolean isVisible() {
11341136
return isVisible_NoClientCode();
11351137
}
11361138

1137-
final boolean isVisible_NoClientCode() {
1139+
protected final boolean isVisible_NoClientCode() {
11381140
return visible;
11391141
}
11401142

@@ -2117,7 +2119,7 @@ public void reshape(int x, int y, int width, int height) {
21172119
// windows here as it is done from peer or native code when
21182120
// the window is really resized or moved, otherwise some
21192121
// events may be sent twice
2120-
if (this instanceof Window) {
2122+
if (this instanceof Window && !(this instanceof JInternalFrame)) {
21212123
needNotify = false;
21222124
}
21232125
// }
@@ -2744,7 +2746,7 @@ protected void invalidateComp() {
27442746
/**
27452747
* Invalidates the component unless it is already invalid.
27462748
*/
2747-
final void invalidateIfValid() {
2749+
protected final void invalidateIfValid() {
27482750
if (isValid()) {
27492751
invalidate();
27502752
}
@@ -2859,6 +2861,8 @@ public void setCursor(Cursor cursor) {
28592861
* Updates the cursor. May not be invoked from the native message pump.
28602862
*/
28612863
final void updateCursorImmediately() {
2864+
// this is the key method that updates a JComponent if there is
2865+
// no layout manager -- for example, for a JDesktop.
28622866
JSToolkit.setCursor(cursor);
28632867
// TODO
28642868
// if (peer instanceof LightweightPeer) {
@@ -2871,7 +2875,7 @@ final void updateCursorImmediately() {
28712875
// cPeer.updateCursorImmediately();
28722876
// }
28732877
// } else if (peer != null) {
2874-
// peer.updateCursorImmediately();
2878+
peer.updateCursorImmediately();
28752879
// }
28762880
}
28772881

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ private boolean removeDelicately(Component comp, Container newParent, int newInd
537537
* its FTP allows component to be focus owner
538538
* @since 1.5
539539
*/
540-
boolean canContainFocusOwner(Component focusOwnerCandidate) {
540+
protected boolean canContainFocusOwner(Component focusOwnerCandidate) {
541541
if (!(isEnabled() && isDisplayable()
542542
&& isVisible() && isFocusable()))
543543
{
@@ -1373,6 +1373,7 @@ private int getListenersCount(int id, boolean enabledOnToolkit) {
13731373
}
13741374

13751375
@Override
1376+
protected
13761377
final int createHierarchyEvents(int id, Component changed,
13771378
Container changedParent, long changeFlags, boolean enabledOnToolkit)
13781379
{
@@ -1810,7 +1811,16 @@ public float getAlignmentY() {
18101811
*
18111812
*/
18121813
@Override
1813-
public void paint(Graphics g) {
1814+
public void paint(Graphics g) {
1815+
paintContainer(g);
1816+
}
1817+
1818+
public void paintContainer(Graphics g) {
1819+
// SwingJS: split off here so that
1820+
// the new JComponent-subclassed Window can
1821+
// hit this one directly instead of JComponent.paint()
1822+
1823+
18141824
// SwingJS : The developer should override paint() to draw;
18151825
//this method will take care of all buttons, in case the
18161826
//paintComponent(g) method for them has been overridden.
@@ -1833,7 +1843,7 @@ public void paint(Graphics g) {
18331843
GraphicsCallback.PaintCallback.getInstance().
18341844
runComponents(children.toArray(EMPTY_ARRAY), g, SunGraphicsCallback.LIGHTWEIGHTS);
18351845
// }
1836-
}
1846+
}
18371847

18381848
/**
18391849
* Updates the container. This forwards the update to any lightweight
@@ -2066,6 +2076,7 @@ public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
20662076

20672077
// REMIND: remove when filtering is done at lower level
20682078
@Override
2079+
protected
20692080
boolean eventEnabled(AWTEvent e) {
20702081
int id = e.getID();
20712082

@@ -2145,6 +2156,7 @@ protected void processContainerEvent(ContainerEvent e) {
21452156
* @param e the event
21462157
*/
21472158
@Override
2159+
protected
21482160
void dispatchEventImpl(AWTEvent e) {
21492161
if ((dispatcher != null) && dispatcher.dispatchEvent(e)) {
21502162
// event was sent to a lightweight component. The
@@ -3198,7 +3210,7 @@ void clearMostRecentFocusOwnerOnHide() {
31983210
}
31993211

32003212
@Override
3201-
void clearCurrentFocusCycleRootOnHide() {
3213+
protected void clearCurrentFocusCycleRootOnHide() {
32023214
// KeyboardFocusManager kfm =
32033215
// KeyboardFocusManager.getCurrentKeyboardFocusManager();
32043216
// Container cont = kfm.getCurrentFocusCycleRoot();

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

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
* @since JDK1.0
148148
*/
149149
@SuppressWarnings({"unchecked", "deprecation"})
150-
public class Window extends Container {
150+
public class Window extends JComponent {
151151

152152
/**
153153
* This represents the warning message that is
@@ -667,6 +667,7 @@ public void addNotify() {
667667
parent.addNotify();
668668
getOrCreatePeer();
669669
JSUtil.getAppletViewer().addWindow(this);
670+
// to JComponent now
670671
super.addNotify();
671672
}
672673

@@ -814,6 +815,14 @@ static final void closeSplashScreen() {
814815
// }
815816
}
816817

818+
@Override
819+
public void paint(Graphics g) {
820+
// SwingJS added when Window was moved to
821+
// subclass JComponent.
822+
823+
paintContainer(g);
824+
}
825+
817826
/**
818827
* Shows or hides this {@code Window} depending on the value of parameter
819828
* {@code b}.
@@ -835,9 +844,13 @@ static final void closeSplashScreen() {
835844
*/
836845
@Override
837846
public void setVisible(boolean b) {
838-
super.setVisible(b);
839-
if (b)
847+
// this is Component's not JComponent's
848+
if (b) {
849+
show();
840850
repaint(); // BH SwingJS needs this, because there is no system event set to do this.
851+
} else {
852+
hide();
853+
}
841854
}
842855

843856
/**
@@ -1783,7 +1796,7 @@ public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
17831796

17841797
// REMIND: remove when filtering is handled at lower level
17851798
@Override
1786-
boolean eventEnabled(AWTEvent e) {
1799+
protected boolean eventEnabled(AWTEvent e) {
17871800
switch(e.id) {
17881801
case WindowEvent.WINDOW_OPENED:
17891802
case WindowEvent.WINDOW_CLOSING:
@@ -2494,7 +2507,7 @@ public void addPropertyChangeListener(String propertyName,
24942507
* @param e the event
24952508
*/
24962509
@Override
2497-
void dispatchEventImpl(AWTEvent e) {
2510+
protected void dispatchEventImpl(AWTEvent e) {
24982511
if (e.getID() == ComponentEvent.COMPONENT_RESIZED) {
24992512
invalidate();
25002513
validate();
@@ -3082,8 +3095,7 @@ Component setTemporaryLostComponent(Component component) {
30823095
* Verifies that it is focusable and as container it can container focus owner.
30833096
* @since 1.5
30843097
*/
3085-
@Override
3086-
boolean canContainFocusOwner(Component focusOwnerCandidate) {
3098+
protected boolean canContainFocusOwner(Component focusOwnerCandidate) {
30873099
return super.canContainFocusOwner(focusOwnerCandidate) && isFocusableWindow();
30883100
}
30893101

@@ -3344,7 +3356,7 @@ public void setBackground(Color bgColor) {
33443356
@SuppressWarnings("unused")
33453357
private transient boolean opaque = true;
33463358

3347-
void setOpaque(boolean opaque) {
3359+
public void setOpaque(boolean opaque) {
33483360
synchronized (getTreeLock()) {
33493361
//TODO ?
33503362
// GraphicsConfiguration gc = getGraphicsConfiguration();
@@ -3453,7 +3465,7 @@ private static void setLayersOpaque(Component component, boolean isOpaque) {
34533465

34543466
// A window has a parent, but it does NOT have a container
34553467
@Override
3456-
final Container getContainer() {
3468+
protected Container getContainer() {
34573469
return null;
34583470
}
34593471

0 commit comments

Comments
 (0)