Skip to content

Commit 0d779f9

Browse files
authored
Merge pull request #139 from BobHanson/master
minor fixes
2 parents 482243b + 44689c4 commit 0d779f9

File tree

11 files changed

+101
-41
lines changed

11 files changed

+101
-41
lines changed
99 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20191103054350
1+
20191103225630
99 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20191103054350
1+
20191103225630
99 Bytes
Binary file not shown.

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

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4354,25 +4354,24 @@ public void paintImmediately(int x, int y, int w, int h) {
43544354
return;
43554355
}
43564356

4357-
while (!isOpaque()) {//see TextAnalyzer2 -- doesn't erase canvas on hide && ((JSComponent)c).秘paintsSelf()) {
4358-
parent = c.getParent();
4359-
if (parent != null) {
4360-
x += c.getX();
4361-
y += c.getY();
4362-
c = parent;
4363-
} else {
4364-
break;
4365-
}
4366-
4367-
if (!(c instanceof JComponent)) {
4368-
break;
4369-
}
4370-
}
4371-
if (c instanceof JComponent) {
4372-
((JComponent) c)._paintImmediately(x, y, w, h);
4373-
} else {
4374-
c.repaint(x, y, w, h);
4375-
}
4357+
// Get back to first opaque self or parent so as to draw the background and all parts in between, in order.
4358+
while (!c.isOpaque() && (parent = c.getParent()) != null) {//see TextAnalyzer2 -- doesn't erase canvas on hide && ((JSComponent)c).秘paintsSelf()) {
4359+
x += c.getX();
4360+
y += c.getY();
4361+
c = parent;
4362+
}
4363+
((JComponent) c)._paintImmediately(x, y, w, h);
4364+
4365+
// SwingJS everything is a JComponent
4366+
// if (!(c instanceof JComponent)) {
4367+
// break;
4368+
// }
4369+
// }
4370+
// if (c instanceof JComponent) {
4371+
// ((JComponent) c)._paintImmediately(x, y, w, h);
4372+
// } else {
4373+
// c.repaint(x, y, w, h);
4374+
// }
43764375
}
43774376

43784377
/**

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,8 @@ public void run() {
798798
JSUtil.J2S.getFileFromDialog(/**@j2sNative function(file){r.run$(file)}||*/ null, "java.io.File");
799799
return JDialog.ASYNCHRONOUS_INTEGER;
800800
case SAVE_DIALOG:
801+
if (selectedFile != null)
802+
lastFileName = selectedFile.getName();
801803
String name = JSUtil.prompt((dialogTitle == null ? "File to Save?" : dialogTitle), lastFileName);
802804
if (name == null)
803805
return CANCEL_OPTION;

sources/net.sf.j2s.java.core/src/swingjs/plaf/JSTextUI.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,10 @@ public boolean handleJSEvent(Object target, int eventType, Object jQueryEvent) {
196196
* jQueryEvent.preventDefault(); jQueryEvent.stopPropagation();
197197
*/
198198
// fall through
199-
case KeyEvent.VK_SHIFT:
199+
//case KeyEvent.VK_SHIFT:
200+
//BH note 2019.11.03
201+
//Including VK_SHIFT here caused Firefox to ignore a first upper-case L in
202+
//SequenceSearcher pattern JTextField
200203
case KeyEvent.VK_CONTROL:
201204
ret = HANDLED;
202205
break;

sources/net.sf.j2s.java.core/src/swingjs/plaf/TextListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void handleJSTextEvent(JSTextUI ui, int eventType, Object jqevent) {
142142
} else if (keyCode != KeyEvent.VK_BACK_SPACE){
143143
setCaret = false;
144144
}
145-
if (lastKeyEvent != KeyEvent.KEY_TYPED)
145+
if (lastKeyEvent != KeyEvent.KEY_TYPED);// could be lastKeyEvent == 0 ??
146146
break;
147147
// fall through if this is a continuation press
148148
case KeyEvent.KEY_RELEASED:

sources/net.sf.j2s.java.core/src/test/async/AsyncDialog.java

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import javax.swing.JOptionPane;
1212

1313
/**
14-
* A class to manage asynchronous input and confirmation dialogs.
14+
* A class to manage asynchronous input, option, and confirmation dialogs.
1515
*
1616
* @author Bob Hanson hansonr
1717
*
@@ -21,6 +21,7 @@ public class AsyncDialog extends Window implements PropertyChangeListener {
2121

2222
private ActionListener actionListener;
2323
private Object choice;
24+
private String[] options;
2425

2526
public AsyncDialog(ActionListener a) {
2627
super(null);
@@ -35,51 +36,72 @@ public AsyncDialog(ActionListener a) {
3536
public void propertyChange(PropertyChangeEvent evt) {
3637
switch (evt.getPropertyName()) {
3738
case "value":
38-
process(evt.getNewValue());
39+
Object val = evt.getNewValue();
40+
if (options != null) {
41+
int i;
42+
for (i = 0; i < options.length; i++) {
43+
if (options[i] == val)
44+
break;
45+
}
46+
val = Integer.valueOf(i < options.length ? i : JOptionPane.CLOSED_OPTION);
47+
}
48+
process(val);
3949
}
4050
}
4151

42-
public void showInputDialog(Component frame, String message, String title, int type,
43-
Icon icon, Integer[] choices, Integer initialChoice) {
44-
if (frame != null) {
45-
setBounds(frame.getBounds());
46-
}
52+
// These options can be supplemented as desired.
53+
54+
public void showInputDialog(Component frame, String message, String title, int type, Icon icon, Integer[] choices,
55+
Integer initialChoice) {
56+
setFrame(frame);
4757
process(JOptionPane.showInputDialog(this, message, title, type, icon, choices, initialChoice));
4858
}
4959

60+
public void showOptionDialog(Component frame, String message, String title, int optionType, int messageType,
61+
Icon icon, String[] options, String initialValue) {
62+
setFrame(frame);
63+
this.options = options;
64+
process(JOptionPane.showOptionDialog(this, message, title, optionType, messageType, icon, options,
65+
initialValue));
66+
}
67+
5068
public void showConfirmDialog(Component frame, String message, String title, int optionType) {
5169
showConfirmDialog(frame, message, title, optionType, JOptionPane.QUESTION_MESSAGE);
5270
}
5371

5472
public void showConfirmDialog(Component frame, String message, String title, int optionType, int messageType) {
73+
setFrame(frame);
74+
process(JOptionPane.showConfirmDialog(this, message, title, optionType, messageType));
75+
}
76+
77+
private void setFrame(Component frame) {
5578
if (frame != null) {
5679
setBounds(frame.getBounds());
5780
}
58-
process(JOptionPane.showConfirmDialog(this, message, title, optionType, messageType));
5981
}
6082

6183
private boolean processed;
62-
84+
6385
/**
6486
* Return for confirm dialog.
6587
*
66-
* @param ret may be JavaScript NaN, testable as ret != ret or ret != - -ret
88+
* @param ret may be JavaScript NaN, testable as ret != ret or ret != - -ret
6789
*/
6890
private void process(int ret) {
6991
if (ret != - -ret || processed)
7092
return;
7193
process(new Integer(ret));
7294
}
73-
95+
7496
private void process(Object ret) {
7597
if (ret instanceof javax.swing.plaf.UIResource || processed)
7698
return;
7799
processed = true;
78-
choice = ret;
100+
choice = ret;
79101
actionListener.actionPerformed(new ActionEvent(this, 0, "SelectedOption"));
80102
dispose();
81103
}
82-
104+
83105
/**
84106
* retrieve selection from the ActionEvent, for which "this" is getSource()
85107
*
@@ -95,5 +117,5 @@ public int getOption() {
95117
}
96118
return ((Integer) choice).intValue();
97119
}
98-
120+
99121
}

0 commit comments

Comments
 (0)