Skip to content

Commit 902c29b

Browse files
committed
adds JOptionPane.getConfirmDialog
1 parent 6ef2c0b commit 902c29b

49 files changed

Lines changed: 1992 additions & 429 deletions

Some content is hidden

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ private static VKCollection getVKCollection() {
593593
VKCollection vk = vks;
594594
/**
595595
* @j2sNative
596-
* var c = java.awt.event.KeyEvent;
596+
* var c = Clazz.load("java.awt.event.KeyEvent");
597597
* for (var k in c)
598598
* if (k.indexOf("VK_") == 0 && typeof c[k] == "number")
599599
* vk.put(k, Integer.$valueOf(c[k]));
@@ -621,7 +621,7 @@ public static int getVKValue(String key) {
621621
/**
622622
* @j2sNative
623623
*
624-
* keyCode = java.awt.event.KeyEvent[key];
624+
* keyCode = Clazz.load("java.awt.event.KeyEvent")[key];
625625
*/
626626
{
627627
keyCode = KeyEvent.class.getField(key).getInt(KeyEvent.class);

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6008,12 +6008,12 @@ protected void addNotifyComp() {
60086008
// if our parent is lightweight and we are not
60096009
// we should call restack on nearest heavyweight
60106010
// container.
6011-
if (parentContPeer instanceof LightweightPeer && !(peer instanceof LightweightPeer)) {
6012-
Container hwParent = getNativeContainer();
6013-
if (hwParent != null && hwParent.peer != null) {
6014-
parentContPeer = (ContainerPeer) hwParent.peer;
6015-
}
6016-
}
6011+
// if (parentContPeer instanceof LightweightPeer && !(peer instanceof LightweightPeer)) {
6012+
// Container hwParent = getNativeContainer();
6013+
// if (hwParent != null && hwParent.peer != null) {
6014+
// parentContPeer = (ContainerPeer) hwParent.peer;
6015+
// }
6016+
// }
60176017
// if (parentContPeer.isRestackSupported()) {
60186018
// parentContPeer.restack();
60196019
// }
@@ -6024,6 +6024,16 @@ protected void addNotifyComp() {
60246024
// }
60256025

60266026
isAddNotifyComplete = true;
6027+
if (visible && peer != null) {// BH added for SwingJS menu in Varna
6028+
boolean isDisposed = false;
6029+
/**
6030+
* @j2sNative
6031+
* isDisposed = peer.isDisposed;
6032+
*
6033+
*/
6034+
if (isDisposed)
6035+
peer.setVisible(true);
6036+
}
60276037

60286038
if (hierarchyListener != null || (eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0
60296039
|| Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK)) {

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

Lines changed: 220 additions & 207 deletions
Large diffs are not rendered by default.

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
*/
4949
public abstract class JSComponent extends Component {
5050

51+
public interface AsynchronousDialogCaller {
52+
public void onReturn(int value);
53+
}
54+
5155
/**
5256
*
5357
* used by SwingJS
@@ -155,7 +159,7 @@ public void setUI(ComponentUI ui) {
155159
if (ui != null) {
156160
// set up the ui as a PropertyChangeListener
157161
// and, if applicable, a ChangeListener
158-
ui.installUI(this);
162+
ui.installJS();
159163
}
160164
}
161165

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -875,13 +875,14 @@ public void show() {
875875
child.showWithParent = false;
876876
} // endif
877877
} // endfor
878-
if (!isModalBlocked()) {
879-
updateChildrenBlocking();
880-
} else {
881-
// fix for 6532736: after this window is shown, its blocker
882-
// should be raised to front
883-
modalBlocker.toFront_NoClientCode();
884-
}
878+
// if (!isModalBlocked()) {
879+
// updateChildrenBlocking();
880+
// } else
881+
// {
882+
// // fix for 6532736: after this window is shown, its blocker
883+
// // should be raised to front
884+
// modalBlocker.toFront_NoClientCode();
885+
// }
885886
if (this instanceof Frame || this instanceof Dialog) {
886887
updateChildFocusableWindowState(this);
887888
}
@@ -997,7 +998,9 @@ void doDispose() {
997998
@Override
998999
public void run() {
9991000

1001+
// Though Window is not a JComponent, we still treat it as such.
10001002
((JComponent) me).getUI().uninstallUI(null);
1003+
((JComponent) me).getUI().uninstallJS();
10011004

10021005
// Check if this window is the fullscreen window for the
10031006
// device. Exit the fullscreen mode prior to disposing
@@ -1540,7 +1543,7 @@ boolean isModalExcluded(Dialog.ModalExclusionType exclusionType) {
15401543
return (owner != null) && owner.isModalExcluded(exclusionType);
15411544
}
15421545

1543-
void updateChildrenBlocking() {
1546+
// void updateChildrenBlocking() {
15441547
// Vector<Window> childHierarchy = new Vector<Window>();
15451548
// Window[] ownedWindows = getOwnedWindows();
15461549
// for (int i = 0; i < ownedWindows.length; i++) {
@@ -1562,7 +1565,7 @@ void updateChildrenBlocking() {
15621565
// }
15631566
// k++;
15641567
// }
1565-
}
1568+
// }
15661569

15671570
/**
15681571
* Adds the specified window listener to receive window events from

sources/net.sf.j2s.java.core/src/java/io/OutputStreamWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public void flush() throws IOException {
274274
@Override
275275
public void close() throws IOException {
276276
flush();
277-
writer.close();
277+
stream.close();
278278
}
279279

280280
/** Added for SwingJS

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3456,7 +3456,7 @@ public void setUI(ComponentUI newUI) {
34563456
// ComponentUI oldUI = ui;
34573457
ui = newUI;
34583458
if (ui != null) {
3459-
ui.installUI(this);
3459+
ui.installJS(); // not ui.installUI(this), as that is done earlier
34603460
}
34613461
//
34623462
// firePropertyChange("UI", oldUI, newUI);
@@ -3471,6 +3471,7 @@ public void setUI(ComponentUI newUI) {
34713471
private void uninstallUIAndProperties() {
34723472
if (ui != null) {
34733473
ui.uninstallUI(this);
3474+
ui.uninstallJS();
34743475
// //clean UIClientPropertyKeys from client properties
34753476
// if (clientProperties != null) {
34763477
// synchronized(clientProperties) {

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ public class JDialog extends Dialog implements WindowConstants,
142142
*/
143143
private TransferHandler transferHandler;
144144

145+
public Object optionCaller;
146+
145147
/**
146148
* Creates a modeless dialog without a title and without a specified
147149
* <code>Frame</code> owner. A shared, hidden frame will be
@@ -1215,4 +1217,16 @@ protected String paramString() {
12151217
",rootPaneCheckingEnabled=" + rootPaneCheckingEnabledString;
12161218
}
12171219

1220+
public int notifyCaller(Object value) {
1221+
if (optionCaller != null) {
1222+
/**
1223+
* @j2sNative
1224+
*
1225+
* caller.onReturn$O(value);
1226+
*
1227+
*/
1228+
}
1229+
return 0;
1230+
}
1231+
12181232
}

0 commit comments

Comments
 (0)