Skip to content

Commit 19adf25

Browse files
authored
Merge pull request #87 from BobHanson/hanson1
Hanson1 -- Frame/Dialog dispose()/"undispose()", better menu handling
2 parents 0d2c6b3 + 0defb2f commit 19adf25

26 files changed

+681
-550
lines changed
2.43 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190315122942
1+
20190316185356
2.43 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190315122942
1+
20190316185356
2.43 KB
Binary file not shown.

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,9 +1070,13 @@ protected void addImpl(Component comp, Object constraints, int index) {
10701070
addImplCont(comp, constraints, index);
10711071
}
10721072

1073+
@SuppressWarnings("unused")
10731074
protected void addImplCont(Component comp, Object constraints, int index) {
10741075
synchronized (getTreeLock()) {
1075-
1076+
1077+
if (/** @j2sNative comp.getWrap$ && !this.isWrapper$ || */ false) {
1078+
comp = ((A2SWrappedComponent) comp).getWrap$();
1079+
}
10761080
// SwingJS used for all add methods
10771081

10781082
/*
@@ -1246,8 +1250,15 @@ public void remove(int index) {
12461250
* @see #validate
12471251
* @see #remove(int)
12481252
*/
1249-
public void remove(Component comp) {
1253+
@SuppressWarnings("unused")
1254+
public void remove(Component comp) {
12501255
synchronized (getTreeLock()) {
1256+
1257+
if (/** @j2sNative comp.getWrap$ && !this.isWrapper$ || */ false) {
1258+
comp = ((A2SWrappedComponent) comp).getWrap$();
1259+
}
1260+
1261+
12511262
if (comp.parent == this) {
12521263
int index = component.indexOf(comp);
12531264
if (index >= 0) {

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

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

30-
import java.applet.JSApplet;
3130
import java.awt.event.KeyListener;
3231
import java.awt.peer.ComponentPeer;
3332
import java.beans.PropertyChangeListener;
@@ -67,6 +66,32 @@
6766
*/
6867
public abstract class JSComponent extends Component {
6968

69+
/**
70+
* A marker for the SwingJS version of JViewPort to indicate that it
71+
* can add an A2SWrappedComponent, not pass it back for wrapping.
72+
*
73+
* @author hansonr
74+
*
75+
*/
76+
public interface A2SComponentWrapper {
77+
78+
public void isWrapper$();
79+
}
80+
81+
/**
82+
* For JViewPort.
83+
*
84+
* Implementations of java.awt.List require a JScrollPane/JViewPort
85+
* wrapper.
86+
*
87+
* @author hansonr
88+
*
89+
*/
90+
public interface A2SWrappedComponent {
91+
92+
public Component getWrap$();
93+
94+
}
7095
/**
7196
* overridden in Applet
7297
*

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

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

30+
import java.awt.Dialog.ModalityType;
3031
import java.awt.event.ComponentEvent;
3132
import java.awt.event.HierarchyEvent;
3233
import java.awt.event.WindowEvent;
@@ -35,6 +36,8 @@
3536
import java.util.ArrayList;
3637
import java.util.Iterator;
3738

39+
import swingjs.plaf.JSDialogUI;
40+
3841
/**
3942
* A Dialog is a top-level window with a title and a border
4043
* that is typically used to take some form of input from the user.
@@ -839,10 +842,14 @@ private boolean conditionalShow(Component toFocus, Long time) {
839842

840843
closeSplashScreen();
841844

842-
// synchronized (getTreeLock()) {
845+
if (ui != null && ((JSDialogUI) ui).isDisposed)
846+
addNotify();
847+
// synchronized (getTreeLock()) {
843848
// if (peer == null) {
844849
// addNotify();
845850
// }
851+
852+
846853
validate();
847854
if (visible) {
848855
toFront();

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
//import java.util.logging.Logger;
5959
import swingjs.JSUtil;
6060
import swingjs.plaf.JSComponentUI;
61+
import swingjs.plaf.JSWindowUI;
6162

6263
/**
6364
*
@@ -842,7 +843,7 @@ public void printAll(Graphics g) {
842843

843844
@Override
844845
public Dimension getPreferredSize() {
845-
return preferredSizeContainer();
846+
return preferredSize();// for AWT classes
846847
}
847848

848849

@@ -890,6 +891,9 @@ public void setVisible(boolean b) {
890891
@Override
891892
@Deprecated
892893
public void show() {
894+
895+
if (ui != null && ((JSWindowUI) ui).isDisposed)
896+
addNotify();
893897
// if (peer == null) {
894898
// addNotify();
895899
// }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,7 @@ public Dimension getPreferredSize() {
14701470
public Dimension getPrefSizeJComp() {
14711471
Dimension size = (!isPreferredSizeSet() && ui != null ? ui
14721472
.getPreferredSize(this) : null);
1473-
return (size == null ? super.preferredSize() : size);
1473+
return (size == null ? preferredSize() : size);
14741474
}
14751475

14761476
/**

0 commit comments

Comments
 (0)