Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20191103054350
20191103225630
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.4/SwingJS-site.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/ver/3.2.4/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20191103054350
20191103225630
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
37 changes: 18 additions & 19 deletions sources/net.sf.j2s.java.core/src/javax/swing/JComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -4354,25 +4354,24 @@ public void paintImmediately(int x, int y, int w, int h) {
return;
}

while (!isOpaque()) {//see TextAnalyzer2 -- doesn't erase canvas on hide && ((JSComponent)c).秘paintsSelf()) {
parent = c.getParent();
if (parent != null) {
x += c.getX();
y += c.getY();
c = parent;
} else {
break;
}

if (!(c instanceof JComponent)) {
break;
}
}
if (c instanceof JComponent) {
((JComponent) c)._paintImmediately(x, y, w, h);
} else {
c.repaint(x, y, w, h);
}
// Get back to first opaque self or parent so as to draw the background and all parts in between, in order.
while (!c.isOpaque() && (parent = c.getParent()) != null) {//see TextAnalyzer2 -- doesn't erase canvas on hide && ((JSComponent)c).秘paintsSelf()) {
x += c.getX();
y += c.getY();
c = parent;
}
((JComponent) c)._paintImmediately(x, y, w, h);

// SwingJS everything is a JComponent
// if (!(c instanceof JComponent)) {
// break;
// }
// }
// if (c instanceof JComponent) {
// ((JComponent) c)._paintImmediately(x, y, w, h);
// } else {
// c.repaint(x, y, w, h);
// }
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,8 @@ public void run() {
JSUtil.J2S.getFileFromDialog(/**@j2sNative function(file){r.run$(file)}||*/ null, "java.io.File");
return JDialog.ASYNCHRONOUS_INTEGER;
case SAVE_DIALOG:
if (selectedFile != null)
lastFileName = selectedFile.getName();
String name = JSUtil.prompt((dialogTitle == null ? "File to Save?" : dialogTitle), lastFileName);
if (name == null)
return CANCEL_OPTION;
Expand Down
5 changes: 4 additions & 1 deletion sources/net.sf.j2s.java.core/src/swingjs/plaf/JSTextUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ public boolean handleJSEvent(Object target, int eventType, Object jQueryEvent) {
* jQueryEvent.preventDefault(); jQueryEvent.stopPropagation();
*/
// fall through
case KeyEvent.VK_SHIFT:
//case KeyEvent.VK_SHIFT:
//BH note 2019.11.03
//Including VK_SHIFT here caused Firefox to ignore a first upper-case L in
//SequenceSearcher pattern JTextField
case KeyEvent.VK_CONTROL:
ret = HANDLED;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void handleJSTextEvent(JSTextUI ui, int eventType, Object jqevent) {
} else if (keyCode != KeyEvent.VK_BACK_SPACE){
setCaret = false;
}
if (lastKeyEvent != KeyEvent.KEY_TYPED)
if (lastKeyEvent != KeyEvent.KEY_TYPED);// could be lastKeyEvent == 0 ??
break;
// fall through if this is a continuation press
case KeyEvent.KEY_RELEASED:
Expand Down
50 changes: 36 additions & 14 deletions sources/net.sf.j2s.java.core/src/test/async/AsyncDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import javax.swing.JOptionPane;

/**
* A class to manage asynchronous input and confirmation dialogs.
* A class to manage asynchronous input, option, and confirmation dialogs.
*
* @author Bob Hanson hansonr
*
Expand All @@ -21,6 +21,7 @@ public class AsyncDialog extends Window implements PropertyChangeListener {

private ActionListener actionListener;
private Object choice;
private String[] options;

public AsyncDialog(ActionListener a) {
super(null);
Expand All @@ -35,51 +36,72 @@ public AsyncDialog(ActionListener a) {
public void propertyChange(PropertyChangeEvent evt) {
switch (evt.getPropertyName()) {
case "value":
process(evt.getNewValue());
Object val = evt.getNewValue();
if (options != null) {
int i;
for (i = 0; i < options.length; i++) {
if (options[i] == val)
break;
}
val = Integer.valueOf(i < options.length ? i : JOptionPane.CLOSED_OPTION);
}
process(val);
}
}

public void showInputDialog(Component frame, String message, String title, int type,
Icon icon, Integer[] choices, Integer initialChoice) {
if (frame != null) {
setBounds(frame.getBounds());
}
// These options can be supplemented as desired.

public void showInputDialog(Component frame, String message, String title, int type, Icon icon, Integer[] choices,
Integer initialChoice) {
setFrame(frame);
process(JOptionPane.showInputDialog(this, message, title, type, icon, choices, initialChoice));
}

public void showOptionDialog(Component frame, String message, String title, int optionType, int messageType,
Icon icon, String[] options, String initialValue) {
setFrame(frame);
this.options = options;
process(JOptionPane.showOptionDialog(this, message, title, optionType, messageType, icon, options,
initialValue));
}

public void showConfirmDialog(Component frame, String message, String title, int optionType) {
showConfirmDialog(frame, message, title, optionType, JOptionPane.QUESTION_MESSAGE);
}

public void showConfirmDialog(Component frame, String message, String title, int optionType, int messageType) {
setFrame(frame);
process(JOptionPane.showConfirmDialog(this, message, title, optionType, messageType));
}

private void setFrame(Component frame) {
if (frame != null) {
setBounds(frame.getBounds());
}
process(JOptionPane.showConfirmDialog(this, message, title, optionType, messageType));
}

private boolean processed;

/**
* Return for confirm dialog.
*
* @param ret may be JavaScript NaN, testable as ret != ret or ret != - -ret
* @param ret may be JavaScript NaN, testable as ret != ret or ret != - -ret
*/
private void process(int ret) {
if (ret != - -ret || processed)
return;
process(new Integer(ret));
}

private void process(Object ret) {
if (ret instanceof javax.swing.plaf.UIResource || processed)
return;
processed = true;
choice = ret;
choice = ret;
actionListener.actionPerformed(new ActionEvent(this, 0, "SelectedOption"));
dispose();
}

/**
* retrieve selection from the ActionEvent, for which "this" is getSource()
*
Expand All @@ -95,5 +117,5 @@ public int getOption() {
}
return ((Integer) choice).intValue();
}

}
42 changes: 38 additions & 4 deletions sources/net.sf.j2s.java.core/src/test/async/AsyncFileChooser.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* @author Bob Hanson
*/

@SuppressWarnings("serial")
public class AsyncFileChooser extends JFileChooser implements PropertyChangeListener {

private Runnable ok, cancel;
Expand All @@ -32,6 +31,41 @@ public AsyncFileChooser(File file, FileSystemView view) {
super(file, view);
}

@Deprecated
public int showDialog(Component frame) {
return err();
}

@Override
@Deprecated
public int showDialog(Component frame, String type) {

// this method will be called from super constructor(frame)

return (ok == null ? err() : super.showDialog(frame, type));
}

@Override
@Deprecated
public int showOpenDialog(Component frame) {
return err();
}

@Override
@Deprecated
public int showSaveDialog(Component frame) {
return err();
}

private int err() {
try {
throw new java.lang.IllegalAccessException("Warning! AsyncFileChooser interface bypassed!");
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return JFileChooser.CANCEL_OPTION;
}

/**
*
* @param frame
Expand All @@ -43,19 +77,19 @@ public AsyncFileChooser(File file, FileSystemView view) {
public int showDialog(Component frame, String type, Runnable ok, Runnable cancel) {
this.ok = ok;
this.cancel = cancel;
return process(showDialog(frame, type));
return process(super.showDialog(frame, type));
}

public void showOpenDialog(Component frame, Runnable ok, Runnable cancel) {
this.ok = ok;
this.cancel = cancel;
process(showOpenDialog(frame));
process(super.showOpenDialog(frame));
}

public void showSaveDialog(Component frame, Runnable ok, Runnable cancel) {
this.ok = ok;
this.cancel = cancel;
process(showSaveDialog(frame));
process(super.showSaveDialog(frame));
}

@Override
Expand Down