Skip to content

Commit d7f830d

Browse files
hansonrhansonr
authored andcommitted
AsyncFileChooser save should clear ok,cancel
- in case this is a static chooser being reused.
1 parent 543633f commit d7f830d

File tree

6 files changed

+16
-8
lines changed

6 files changed

+16
-8
lines changed
-17 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200714124718
1+
20200715193703
-17 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200714124718
1+
20200715193703

sources/net.sf.j2s.java.core/src/javajs/async/AsyncFileChooser.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public int showOpenDialog(Component frame) {
6666
@Override
6767
public int showSaveDialog(Component frame) {
6868
isAsyncSave = false;
69+
ok = cancel = null;
6970
return super.showSaveDialog(frame);
7071
}
7172

@@ -187,6 +188,7 @@ public void propertyChange(PropertyChangeEvent evt) {
187188
switch (evt.getPropertyName()) {
188189
case "SelectedFile":
189190
case "SelectedFiles":
191+
190192
process(optionSelected = (evt.getNewValue() == null ? CANCEL_OPTION : APPROVE_OPTION));
191193
break;
192194
}

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,9 @@ public void setSelectedFile(File file) {
521521
if (file.isAbsolute() && !isParent(getCurrentDirectory(), selectedFile)) {
522522
setCurrentDirectory(selectedFile.getParentFile());
523523
}
524-
if (!isMultiSelectionEnabled() || selectedFiles == null || selectedFiles.length == 1) {
525-
ensureFileIsVisible(selectedFile);
526-
}
524+
// if (!isMultiSelectionEnabled() || selectedFiles == null || selectedFiles.length == 1) {
525+
// ensureFileIsVisible(selectedFile);
526+
// }
527527
}
528528
firePropertyChange(SELECTED_FILE_CHANGED_PROPERTY, oldValue, selectedFile);
529529
}
@@ -789,14 +789,18 @@ public int showDialog(Component parent, String approveButtonText) {
789789

790790
@Override
791791
public void run() {
792+
File[] files = null;
793+
File file = null;
792794
/**
793795
* @j2sNative
794796
*
795-
* this.b$['javax.swing.JFileChooser'].selectedFiles = arguments[0] || null;
796-
* this.b$['javax.swing.JFileChooser'].selectedFile = arguments[0][0] || null;
797+
* files = arguments[0] || null;
798+
* file = arguments[0][0] || null;
797799
*
798800
*
799801
*/
802+
selectedFiles = files;
803+
selectedFile = file;
800804
firePropertyChange("SelectedFiles", null, selectedFiles);
801805
}
802806

@@ -808,13 +812,15 @@ public void run() {
808812

809813
@Override
810814
public void run() {
815+
File file = null;
811816
/**
812817
* @j2sNative
813818
*
814-
* this.b$['javax.swing.JFileChooser'].selectedFile = arguments[0] || null;
819+
* file = arguments[0] || null;
815820
*
816821
*
817822
*/
823+
selectedFile = file;
818824
firePropertyChange("SelectedFile", null, selectedFile);
819825
}
820826

0 commit comments

Comments
 (0)