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.
4 changes: 4 additions & 0 deletions sources/net.sf.j2s.core/dist/swingjs/_j2sclasslist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ java/awt/Color.js
java/awt/color/ColorSpace.js
java/awt/Component.js
java/awt/ComponentOrientation.js
java/awt/ContainerOrderFocusTraversalPolicy.js
java/awt/Container.js
java/awt/Cursor.js
java/awt/DefaultFocusTraversalPolicy.js
java/awt/DefaultKeyboardFocusManager.js
java/awt/Dialog.js
java/awt/Dimension.js
Expand Down Expand Up @@ -139,6 +141,7 @@ java/util/ArrayList.js
java/util/Arrays.js
java/util/Collection.js
java/util/Collections.js
java/util/Comparator.js
java/util/Deque.js
java/util/Dictionary.js
java/util/Enumeration.js
Expand All @@ -161,6 +164,7 @@ java/util/Random.js
java/util/RandomAccess.js
java/util/ResourceBundle.js
java/util/Set.js
java/util/TimSort.js
java/util/Vector.js
javajs/api/JSFunction.js
javajs/util/AjaxURLConnection.js
Expand Down
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 @@
20190627231814
20190702213116
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.4/SwingJS-site.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ java/awt/Color.js
java/awt/color/ColorSpace.js
java/awt/Component.js
java/awt/ComponentOrientation.js
java/awt/ContainerOrderFocusTraversalPolicy.js
java/awt/Container.js
java/awt/Cursor.js
java/awt/DefaultFocusTraversalPolicy.js
java/awt/DefaultKeyboardFocusManager.js
java/awt/Dialog.js
java/awt/Dimension.js
Expand Down Expand Up @@ -139,6 +141,7 @@ java/util/ArrayList.js
java/util/Arrays.js
java/util/Collection.js
java/util/Collections.js
java/util/Comparator.js
java/util/Deque.js
java/util/Dictionary.js
java/util/Enumeration.js
Expand All @@ -161,6 +164,7 @@ java/util/Random.js
java/util/RandomAccess.js
java/util/ResourceBundle.js
java/util/Set.js
java/util/TimSort.js
java/util/Vector.js
javajs/api/JSFunction.js
javajs/util/AjaxURLConnection.js
Expand Down
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 @@
20190627231814
20190702213116
3 changes: 3 additions & 0 deletions sources/net.sf.j2s.java.core/TODO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
2019.07.01 working on JSEditorPaneUI tab business
2019.07.01 AppContext.getApplet(name) initial work
2019.07.01 working on JTable key navigation events
4 changes: 4 additions & 0 deletions sources/net.sf.j2s.java.core/_j2sclasslist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ java/awt/Color.js
java/awt/color/ColorSpace.js
java/awt/Component.js
java/awt/ComponentOrientation.js
java/awt/ContainerOrderFocusTraversalPolicy.js
java/awt/Container.js
java/awt/Cursor.js
java/awt/DefaultFocusTraversalPolicy.js
java/awt/DefaultKeyboardFocusManager.js
java/awt/Dialog.js
java/awt/Dimension.js
Expand Down Expand Up @@ -139,6 +141,7 @@ java/util/ArrayList.js
java/util/Arrays.js
java/util/Collection.js
java/util/Collections.js
java/util/Comparator.js
java/util/Deque.js
java/util/Dictionary.js
java/util/Enumeration.js
Expand All @@ -161,6 +164,7 @@ java/util/Random.js
java/util/RandomAccess.js
java/util/ResourceBundle.js
java/util/Set.js
java/util/TimSort.js
java/util/Vector.js
javajs/api/JSFunction.js
javajs/util/AjaxURLConnection.js
Expand Down
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
4 changes: 4 additions & 0 deletions sources/net.sf.j2s.java.core/dist/_j2sclasslist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ java/awt/Color.js
java/awt/color/ColorSpace.js
java/awt/Component.js
java/awt/ComponentOrientation.js
java/awt/ContainerOrderFocusTraversalPolicy.js
java/awt/Container.js
java/awt/Cursor.js
java/awt/DefaultFocusTraversalPolicy.js
java/awt/DefaultKeyboardFocusManager.js
java/awt/Dialog.js
java/awt/Dimension.js
Expand Down Expand Up @@ -139,6 +141,7 @@ java/util/ArrayList.js
java/util/Arrays.js
java/util/Collection.js
java/util/Collections.js
java/util/Comparator.js
java/util/Deque.js
java/util/Dictionary.js
java/util/Enumeration.js
Expand All @@ -161,6 +164,7 @@ java/util/Random.js
java/util/RandomAccess.js
java/util/ResourceBundle.js
java/util/Set.js
java/util/TimSort.js
java/util/Vector.js
javajs/api/JSFunction.js
javajs/util/AjaxURLConnection.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ public synchronized FocusTraversalPolicy getDefaultFocusTraversalPolicy() {
}

public synchronized FocusTraversalPolicy getDefaultAWTFocusTraversalPolicy() {
return (defaultPolicyAWT == null ? defaultPolicyAWT = new DefaultFocusTraversalPolicy() : defaultPolicy);
return (defaultPolicyAWT == null ? defaultPolicyAWT = new DefaultFocusTraversalPolicy() : defaultPolicyAWT);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion sources/net.sf.j2s.java.core/src/javax/swing/JComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -4253,7 +4253,9 @@ public void revalidate() {
}
if (SwingUtilities.isEventDispatchThread()) {
invalidate();
RepaintManager.currentManager(this).addInvalidComponent(this);
// problem here was that AWT labels were automatically resizing when painted
if (!秘isAWT())
RepaintManager.currentManager(this).addInvalidComponent(this);
} else {
// getFlag(REVALIDATE_RUNNABLE_SCHEDULED) + " " + this);
// To avoid a flood of Runnables when constructing GUIs off
Expand Down
5 changes: 3 additions & 2 deletions sources/net.sf.j2s.java.core/src/javax/swing/JLabel.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,9 @@ public void setText(String text) {
// oldAccessibleName,
// accessibleContext.getAccessibleName());
// }
if (text == null || oldValue == null || !text.equals(oldValue)) {
revalidate();
if (秘paintsSelf())
if (text == null || oldValue == null || !text.equals(oldValue)) {
revalidate();
秘repaint();
}
}
Expand Down
2 changes: 2 additions & 0 deletions sources/net.sf.j2s.java.core/src/javax/swing/JTextArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ public JTextArea(Document doc) {
* arguments are negative.
*/
public JTextArea(Document doc, String text, int rows, int columns) {

setFocusTraversalKeysEnabled(false); // can't handle CTRL-ENTER in JavaScript
this.rows = rows;
this.columns = columns;
if (doc == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.ListIterator;
import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.Container;
import java.awt.Window;
import java.io.Serializable;

Expand Down Expand Up @@ -120,7 +121,10 @@ public int compare(Object o1, Object o2) {

int ax = a.getX(), ay = a.getY(), bx = b.getX(), by = b.getY();

int zOrder = a.getParent().getComponentZOrder(a) - b.getParent().getComponentZOrder(b);
Container ap = a.getParent();
Container bp = b.getParent();
// desktop will have no parent
int zOrder = (ap == null ? 1 : bp == null ? -1 : ap.getComponentZOrder(a) - bp.getComponentZOrder(b));
if (horizontal) {
if (leftToRight) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ protected boolean accept(Component aComponent) {
} else if (aComponent instanceof javax.swing.JTable) {
// JTable only has ancestor focus bindings, we thus force it
// to be focusable by returning true here.
return true;
return false;// SwingJS NOT true, at least for now;
} else if (aComponent instanceof javax.swing.JComboBox) {
JComboBox box = (JComboBox)aComponent;
return ((ComboBoxUI) box.getUI()).isFocusTraversable(box);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import sun.awt.AWTAccessor;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
import swingjs.JSToolkit;

/**
* This class manages repaint requests, allowing the number of repaints to be
Expand Down Expand Up @@ -1419,6 +1420,14 @@ private void scheduleProcessingRunnable(Component c) {

private void scheduleProcessingRunnable(AppContext context) {
if (processingRunnable.markPending()) {
if (JSToolkit.checkJ2SFlag("_debugPaint"))
System.out.println("RepaintManager"
+ "\n invalid:" + invalidComponents
+ "\n dirty:" + dirtyComponents);

/**
* @j2sNative
*/
SunToolkit.getSystemEventQueueImplPP(context).postEvent(
new InvocationEvent(Toolkit.getDefaultToolkit(), InvocationEvent.INVOCATION_DEFAULT, processingRunnable, null, false));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import javax.swing.RowSorter;
import javax.swing.SortOrder;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.UIResource;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.JTableHeader;
Expand Down Expand Up @@ -117,14 +118,16 @@ public Component getTableCellRendererComponent(JTable table, Object value,
setIcon(sortIcon);
// sortArrow = sortIcon;

Border border = null;
if (hasFocus) {
border = DefaultLookup.getBorder(this, ui, "TableHeader.focusCellBorder");
}
if (border == null) {
border = DefaultLookup.getBorder(this, ui, "TableHeader.cellBorder");
}
setBorder(border);
// Border border = null;
// if (hasFocus) {
// border = DefaultLookup.getBorder(this, ui, "TableHeader.focusCellBorder");
// }
// if (border == null) {
// border = DefaultLookup.getBorder(this, ui, "TableHeader.cellBorder");
// }
// setBorder(border);

setBorder(new EmptyBorder(8, 5, 7, 5)); // BH SwingJS from com.sun.java.swing.plaf.windows.WindowsTableHeaderUI$XPDefaultRenderer

return this;
}
Expand Down
66 changes: 48 additions & 18 deletions sources/net.sf.j2s.java.core/src/swingjs/JSAppletViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.applet.AppletContext;
import java.applet.AppletStub;
import java.applet.AudioClip;
import java.applet.JSApplet;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
Expand All @@ -18,6 +19,7 @@
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.NoSuchElementException;

import javax.imageio.ImageIO;
import javax.swing.JApplet;
Expand Down Expand Up @@ -177,14 +179,13 @@ private void setDisplayParams(Hashtable<String, Object> params) {
String s = "" + params.get("isResizable");
isResizable = "true".equalsIgnoreCase(s);
haveResizable = (isResizable || "false".equalsIgnoreCase(s));

addFrame = "true".equalsIgnoreCase("" + params.get("addFrame"));

insets = new Insets(0, 0, 0, 0);

threadGroup = new JSThreadGroup(appletName);
myThread = new JSAppletThread(this, threadGroup, appletName);
// JSToolkit.J2S.setAppletThread(appletName, myThread);
java.lang.Thread.thisThread = (java.lang.Thread) ((Object) myThread);

appContext = JSToolkit.createNewAppContext();
Expand Down Expand Up @@ -318,22 +319,51 @@ public Image getImage(URL url) {
@Override
public java.applet.JSApplet getApplet(String name) {
JApplet applet = null;
name = name.toLowerCase();
/**
* @j2sNative
*
* applet = SwingJS._applets[name]; applet && (applet =
* applet._applet);
* var applets = J2S._applets;
* for (var a in applets) {
* if (a.toLowerCase() == "." + name) {
* return applets[a]._applet;
* }
* }
*/
{

}
return applet;
return null;
}

@SuppressWarnings("unused")
@Override
public Enumeration<java.applet.JSApplet> getApplets() {
// not supported for now
return null;
public Enumeration<JSApplet> getApplets() {
ArrayList<JSApplet> appletList = new ArrayList<>();
/**
* @j2sNative
*
* var applets = J2S._applets;
* for (var a in applets) {
* var app = applets[a]._applet;
* if (app && !appletList.contains$O(app))
* appletList.add$O(app);
* }
*/
return new Enumeration() {

private int i = 0;

@Override
public boolean hasMoreElements() {
return i < appletList.size();
}

@Override
public Object nextElement() {
if (i >= appletList.size())
throw new NoSuchElementException();
return appletList.get(i++);
}

};
}

@Override
Expand All @@ -356,9 +386,6 @@ public void showStatus(String status) {
*
* Clazz._LoaderProgressMonitor.showStatus(status, true);
*/
{
System.out.println(status);
}
}

private void showAppletStatus(String status) {
Expand All @@ -369,14 +396,11 @@ private void showAppletException(Throwable t) {
/**
* @j2sNative
*
* this.showAppletStatus$S("error " + (t.getMessage ?
* p$1.showAppletStatus$S("error " + (t.getMessage ?
* t.getMessage$() : t));
* if (t.printStackTrace$) t.printStackTrace$();
* else System.out.println(t.stack);
*/
{
}
// repaint();
}

/**
Expand Down Expand Up @@ -545,6 +569,12 @@ else if (code.indexOf(".") < 0)
JSUtil.alert(code + " is not a JApplet!?");
status = APPLET_ERROR;
}
String name = htmlName;
/**
* @j2sNative
*
* J2S._applets["." + name] = {_applet:this.applet};
*/
} catch (InstantiationException e) {
status = APPLET_ERROR;
showAppletException(e);
Expand Down
4 changes: 4 additions & 0 deletions sources/net.sf.j2s.java.core/src/swingjs/JSToolkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -996,4 +996,8 @@ public static boolean isOverWritten(JComponent jc, String method) {
return s.indexOf("java") != 0 && s.indexOf("swingjs") != 0;
}

public static boolean checkJ2SFlag(String flag) {
return (/** @j2sNative J2S[flag] || */ false);
}

}
Loading