Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f9d27c8
missing display:none in Frame and Dialog UI
Mar 12, 2019
5b5b1ea
z-index requires position:absolute
Mar 12, 2019
df9cd56
prefSize default to minimum only if w=0 and h=0
Mar 12, 2019
02f6de4
AWT TextField getMinimumSize loop
Mar 12, 2019
1caf5da
insignificant
Mar 12, 2019
c5bffcd
AWT isAWTContainer$ idea; not implemented
Mar 12, 2019
2673b6d
wrong project
Mar 12, 2019
6e742ca
insignificant
Mar 12, 2019
3e760b4
AWT Canvas preferred size to Component, not Container
Mar 12, 2019
d81eb48
updated SwingJS-site.zip
Mar 12, 2019
3d820fa
JSButtonUI.domNode needs position:absolute for y-translation
Mar 12, 2019
3e7b5c0
java.awt.List/javax.swing.JList implemented
Mar 14, 2019
b64b2bf
slider/scrollbar upgrade AWT and Swing
Mar 14, 2019
3fec821
java.lang.Class adds getJ2SSuperclassFor
Mar 14, 2019
6126f4c
font metrics fix for missing descent and leading
Mar 14, 2019
459b4ef
corrects return void addImpl in Java8
Mar 14, 2019
f348d5e
missing Window-like methods in JSApplet
Mar 14, 2019
ca105b5
tests
Mar 14, 2019
6a5776d
peer color fix (?)
Mar 14, 2019
307903d
tests
Mar 14, 2019
e43ef7b
Adds Java 7 JLayer
Mar 14, 2019
4488a35
Window dispose better
Mar 14, 2019
2e48a03
double resizers?
Mar 14, 2019
729da9e
adds javax.swing.SwingUtiliteis.getUnwrappedParent
Mar 14, 2019
be5d09f
minor
Mar 14, 2019
e6ded00
new SwingJS-site.zip
Mar 14, 2019
8e8c636
AWT Frame default close operation; JFrame setVisible(true)
Mar 15, 2019
47115c3
removing "keep menu open" feature on checkbox clicking
Mar 15, 2019
fcc8d44
AWT MenuBar default background "control" EEEEEE
Mar 15, 2019
d17b982
AWT button insets 5,6,5,6
Mar 15, 2019
e630fae
debug comments out
Mar 15, 2019
0d22879
AWT rootpane insets
Mar 15, 2019
ca0130f
JFrame proper background color
Mar 15, 2019
921bf09
AWT List proper border
Mar 15, 2019
d02be04
AWT menubar insets default
Mar 15, 2019
2d3aa2c
publicize Component.parent for AWT
Mar 15, 2019
59c9ccf
not significant
Mar 15, 2019
a030f59
AWT TextField margins
Mar 15, 2019
62d903d
vertical and left alignments in menu items
Mar 15, 2019
60d4f08
JalviewJSTest update
Mar 15, 2019
9c7409b
SwingJS-site update
Mar 15, 2019
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 @@
20190307200127
20190315122942
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 @@
20190307200127
20190315122942
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
16 changes: 14 additions & 2 deletions sources/net.sf.j2s.java.core/src/java/applet/JSApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.JSPanel;
import java.awt.Window;
import java.awt.event.WindowListener;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;
Expand Down Expand Up @@ -94,15 +96,25 @@ public JSApplet() {
* @return true
*/
public boolean isFocusableWindow() {
// mascarading as Window here
// masquerading as Window here
return true;
}

public Dialog getModalBlocker() {
// mascarading as Window here
// masquerading as Window here
return null; //??
}


public void addWindowListener(WindowListener w) {
// from popup
}
public void addOwnedWindow(Window w) {
// from popup
}

void removeOwnedWindow(Window weakWindow) {
}

/**
* Holds the reference to the component which last had focus in this window
Expand Down
7 changes: 5 additions & 2 deletions sources/net.sf.j2s.java.core/src/java/awt/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public abstract class Component implements ImageObserver/*
*
* @see #getParent
*/
protected transient Container parent;
public transient Container parent;

/**
* The <code>AppContext</code> of the component. Applets/Plugin may change the
Expand Down Expand Up @@ -2385,10 +2385,13 @@ protected Dimension prefSizeComp() {
Dimension dim = prefSize;
if (dim == null || !(isPreferredSizeSet() || isValid())) {
// synchronized (getTreeLock()) {

// SwingJS TODO: it is not clear that we should deliver getMinimumSize here.
//
prefSize = // (
// peer != null) ?
// peer.preferredSize() :
getMinimumSize();
(width == 0 && height == 0 ? getMinimumSize() : new Dimension(width, height));
dim = prefSize;
}
// }
Expand Down
161 changes: 79 additions & 82 deletions sources/net.sf.j2s.java.core/src/java/awt/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ public Insets insets() {
*
*/
public Component add(Component comp) {
return addImpl(comp, null, -1);
addImpl(comp, null, -1);
return comp;
}

/**
Expand All @@ -406,7 +407,8 @@ public Component add(Component comp) {
*
*/
public Component add(String name, Component comp) {
return addImpl(comp, name, -1);
addImpl(comp, name, -1);
return comp;
}

/**
Expand Down Expand Up @@ -435,7 +437,8 @@ public Component add(String name, Component comp) {
*
*/
public Component add(Component comp, int index) {
return addImpl(comp, null, index);
addImpl(comp, null, index);
return comp;
}

/**
Expand Down Expand Up @@ -998,7 +1001,8 @@ public void add(Component comp, Object constraints) {
*/

public Component add(Component comp, Object constraints, int index) {
return addImpl(comp, constraints, index);
addImpl(comp, constraints, index);
return comp;
}

/**
Expand Down Expand Up @@ -1062,93 +1066,86 @@ public Component add(Component comp, Object constraints, int index) {
* @see LayoutManager2
* @since JDK1.1
*/
protected Component addImpl(Component comp, Object constraints, int index) {
return addImplCont(comp, constraints, index);
protected void addImpl(Component comp, Object constraints, int index) {
addImplCont(comp, constraints, index);
}

protected Component addImplCont(Component comp, Object constraints, int index) {
synchronized (getTreeLock()) {

//SwingJS used for all add methods

/* Check for correct arguments: index in bounds,
* comp cannot be one of this container's parents,
* and comp cannot be a window.
* comp and container must be on the same GraphicsDevice.
* if comp is container, all sub-components must be on
* same GraphicsDevice.
*/
protected void addImplCont(Component comp, Object constraints, int index) {
synchronized (getTreeLock()) {

// SwingJS used for all add methods

/*
* Check for correct arguments: index in bounds, comp cannot be one of this
* container's parents, and comp cannot be a window. comp and container must be
* on the same GraphicsDevice. if comp is container, all sub-components must be
* on same GraphicsDevice.
*/
// GraphicsConfiguration thisGC = this.getGraphicsConfiguration();

if (index > component.size() || (index < 0 && index != -1)) {
throw new IllegalArgumentException(
"illegal component position");
}
checkAddToSelf(comp);
// Here we do not allow JSApplet, but we do allow JInternalFrame, which is a JFrame now
if (comp.isJ2SWindowButNotJInternalFrame()) {
throw new IllegalArgumentException("adding a window to a container");
}
if (index > component.size() || (index < 0 && index != -1)) {
throw new IllegalArgumentException("illegal component position");
}
checkAddToSelf(comp);
// Here we do not allow JSApplet, but we do allow JInternalFrame, which is a
// JFrame now
if (comp.isJ2SWindowButNotJInternalFrame()) {
throw new IllegalArgumentException("adding a window to a container");
}

// checkNotAWindow(comp);
// if (thisGC != null) {
// comp.checkGD(thisGC.getDevice().getIDstring());
// }

/* Reparent the component and tidy up the tree's state. */
if (comp.parent != null) {
comp.parent.remove(comp);
if (index > component.size()) {
throw new IllegalArgumentException("illegal component position");
}
}

//index == -1 means add to the end.
if (index == -1) {
component.add(comp);
} else {
component.add(index, comp);
}
_childTainted = true;
comp.parent = this;

adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK,
comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK));
adjustListeningChildren(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
comp.numListening(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK));
adjustDescendants(comp.countHierarchyMembers());

invalidateIfValid();
if (peer != null) {
comp.addNotify();
}

/* Notify the layout manager of the added component. */
if (layoutMgr != null) {
if (layoutMgr instanceof LayoutManager2) {
((LayoutManager2)layoutMgr).addLayoutComponent(comp, constraints);
} else if (constraints instanceof String) {
layoutMgr.addLayoutComponent((String)constraints, comp);
}
}
if (containerListener != null ||
(eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ||
Toolkit.enabledOnToolkit(AWTEvent.CONTAINER_EVENT_MASK)) {
ContainerEvent e = new ContainerEvent(this,
ContainerEvent.COMPONENT_ADDED,
comp);
dispatchEvent(e);
}

comp.createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED, comp,
this, HierarchyEvent.PARENT_CHANGED,
Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK));
if (peer != null && layoutMgr == null && isVisible()) {
updateCursorImmediately();
}
}
return comp;
/* Reparent the component and tidy up the tree's state. */
if (comp.parent != null) {
comp.parent.remove(comp);
if (index > component.size()) {
throw new IllegalArgumentException("illegal component position");
}
}

// index == -1 means add to the end.
if (index == -1) {
component.add(comp);
} else {
component.add(index, comp);
}
_childTainted = true;
comp.parent = this;

adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK, comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK));
adjustListeningChildren(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
comp.numListening(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK));
adjustDescendants(comp.countHierarchyMembers());

invalidateIfValid();
if (peer != null) {
comp.addNotify();
}

/* Notify the layout manager of the added component. */
if (layoutMgr != null) {
if (layoutMgr instanceof LayoutManager2) {
((LayoutManager2) layoutMgr).addLayoutComponent(comp, constraints);
} else if (constraints instanceof String) {
layoutMgr.addLayoutComponent((String) constraints, comp);
}
}
if (containerListener != null || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0
|| Toolkit.enabledOnToolkit(AWTEvent.CONTAINER_EVENT_MASK)) {
ContainerEvent e = new ContainerEvent(this, ContainerEvent.COMPONENT_ADDED, comp);
dispatchEvent(e);
}

comp.createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED, comp, this, HierarchyEvent.PARENT_CHANGED,
Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK));
if (peer != null && layoutMgr == null && isVisible()) {
updateCursorImmediately();
}
}
}



Expand Down Expand Up @@ -1716,9 +1713,9 @@ protected Dimension preferredSizeContainer() {
Dimension dim = prefSize;
if (dim == null || !(isPreferredSizeSet() || isValid())) {
synchronized (getTreeLock()) {
prefSize = (layoutMgr != null) ?
prefSize = (layoutMgr != null ?
layoutMgr.preferredLayoutSize(this) :
prefSizeComp();
prefSizeComp());
dim = prefSize;
}
}
Expand Down
4 changes: 3 additions & 1 deletion sources/net.sf.j2s.java.core/src/java/awt/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ public class Menu extends swingjs.a2s.Menu {//MenuItem implements MenuContainer,
// */
// private static final long serialVersionUID = -8809584163345499784L;

/**
public boolean isHelpMenu;

/**
* Constructs a new menu with an empty label. This menu is not
* a tear-off menu.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
Expand Down
21 changes: 12 additions & 9 deletions sources/net.sf.j2s.java.core/src/java/awt/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -1022,18 +1022,25 @@ public void dispose() {
*/
void disposeImpl() {
dispose();
// if (getPeer() != null) {
// doDispose();
// }
if (!_disposed && getPeer() != null) {
doDispose();
}
}

private boolean _disposed;

void doDispose() {
final JComponent me = this;
_disposed = true;
final Window me = this;

Runnable action = new Runnable() {
@Override
public void run() {

Window parent = getOwner();
if (parent != null) {
parent.removeOwnedWindow(me);
}
JSComponentUI ui = (JSComponentUI) me.getUI();
if (ui != null) {
ui.reinstallUI(me, null);
Expand Down Expand Up @@ -2588,8 +2595,6 @@ public void applyResourceBundle(String rbName) {
void addOwnedWindow(Window weakWindow) {
if (weakWindow != null) {
synchronized(ownedWindowList) {
// this if statement should really be an assert, but we don't
// have asserts...
if (!ownedWindowList.contains(weakWindow)) {
ownedWindowList.addElement(weakWindow);
}
Expand Down Expand Up @@ -3425,14 +3430,12 @@ public void setOpaque(boolean opaque) {
private static final Color TRANSPARENT_BACKGROUND_COLOR = new Color(0, 0, 0, 0);

private static void setLayersOpaque(Component component, boolean isOpaque) {
// Shouldn't use instanceof to avoid loading Swing classes
// if it's a pure AWT application.
if (component instanceof RootPaneContainer) {
RootPaneContainer rpc = (RootPaneContainer) component;
JRootPane root = rpc.getRootPane();
JLayeredPane lp = root.getLayeredPane();
Container c = root.getContentPane();
JComponent content = (c instanceof JComponent) ? (JComponent) c : null;
JComponent content = (c instanceof JComponent ? (JComponent) c : null);
// JComponent gp = (rpc.getGlassPane() instanceof JComponent) ? (JComponent) rpc
// .getGlassPane() : null;
// if (gp != null) {
Expand Down
17 changes: 17 additions & 0 deletions sources/net.sf.j2s.java.core/src/java/lang/Class.java
Original file line number Diff line number Diff line change
Expand Up @@ -3570,4 +3570,21 @@ public XmlRootElement getAnnotation(Class<XmlRootElement> c) {
return null;
}

public static Class<?> getJ2SSuperclassFor(Class<?> cl) {
Class<?> c = null;
/**
*
* @j2sNative
*
* c = cl.getSuperclass$ && cl.getSuperclass$();
*/
{
cl.getSuperclass();
}
if (c == null && cl != Object.class) {
c = Object.class;
}
return c;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1760,8 +1760,11 @@ public void setModel(ButtonModel newModel) {
}

model = newModel;

if (newModel != null) {
/** @j2sNative
* this.model.isAWT$ = !!this.isAWT$
*/

changeListener = createChangeListener();
actionListener = createActionListener();
itemListener = createItemListener();
Expand Down Expand Up @@ -1841,11 +1844,11 @@ public void setUI(ButtonUI ui) {
* @since 1.5
*/
@Override
protected Component addImpl(Component comp, Object constraints, int index) {
protected void addImpl(Component comp, Object constraints, int index) {
if (!setLayout) {
setLayout(new OverlayLayout(this));
}
return addImplCont(comp, constraints, index);
addImplCont(comp, constraints, index);
}

/**
Expand Down
Loading