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 @@
20190205030857
20190205134840
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 @@
20190205030857
20190205134840
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.java.core/src/swingjs/a2s/Button.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public Button(String text) {
super(text);
}

private static Insets awtInsets = new Insets(0, 6, 0, 6);
private static Insets awtInsets = new Insets(3, 6, 3, 6);
// awt.Button has an unadjustable horizontal inset of what appears to be about 6 pixels
@Override
public Insets getMargin() {
Expand Down
18 changes: 18 additions & 0 deletions sources/net.sf.j2s.java.core/src/swingjs/a2s/Label.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package swingjs.a2s;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Insets;

import javax.swing.JLabel;
import javax.swing.SwingConstants;
Expand Down Expand Up @@ -39,6 +41,22 @@ public void setBackground(Color c) {
setOpaque(c != null);
}

private static Insets awtInsets = new Insets(3, 6, 2, 6);
// awt.Label has an unadjustable horizontal inset of what appears to be about 6 pixels
@Override
public Insets getInsets() {
return awtInsets;
}

@Override
public Insets getInsets(Insets s) {
s.top = awtInsets.top;
s.left = awtInsets.left;
s.bottom = awtInsets.bottom;
s.right = awtInsets.right;
return s;
}

public void setAlignment(int alignment) {
float xAlignment = 0f;
float yAlignment = 0.5f;
Expand Down
15 changes: 6 additions & 9 deletions sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,6 @@ protected void ignoreAllMouseEvents(DOMNode node) {

@SuppressWarnings("unused")
protected static void hideAllMenus() {
//System.out.println("JSCUI hideAllMenus" + JSUtil.getStackTrace(-3));
JSUtil.jQuery.$(".ui-j2smenu").hide();
if (/** @j2sNative javax.swing.ToolTipManager ||*/false)
ToolTipManager.j2sHideToolTip();
Expand Down Expand Up @@ -1542,8 +1541,6 @@ protected Dimension setHTMLSize1(DOMNode node, boolean addCSS, boolean usePrefer
$(body).after(div);
Rectangle r = div.getBoundingClientRect();

//System.out.println("JSCUI " + (int) (r.width + 0.) + " " + (/** @j2sNative div.innerHTML ||*/""));

// From the DOM; Will be Rectangle2D.double, actually.
// This is preferable to $(text).width() because that is rounded
// DOWN.
Expand All @@ -1556,9 +1553,6 @@ protected Dimension setHTMLSize1(DOMNode node, boolean addCSS, boolean usePrefer
actualWidth = w;
actualHeight = h;
}
// h = preferredHeight;// (iconHeight > 0 ? iconHeight :
// centerHeight);
// TODO what if centerHeight is > prefHeight?
$(div).detach();
}
// allow a UI to slightly adjust its dimension
Expand Down Expand Up @@ -2307,7 +2301,7 @@ protected void setAlignments(AbstractButton b, boolean justGetPreferred) {
int gap = (wText == 0 || wIcon == 0 ? 0 : b.getIconTextGap());
int w = cellComponent != null ? cellWidth : $(domNode).width();
boolean alignVCenter = (vAlign == SwingConstants.CENTER);
Insets margins = (isLabel ? insets : b.getMargin());
Insets margins = (isAWT ? b.getInsets() : isLabel ? insets : b.getMargin());
if (margins == null)
margins = zeroInsets;
int h = (dimText == null ? 0 : dimText.height);
Expand Down Expand Up @@ -2416,7 +2410,7 @@ protected void setAlignments(AbstractButton b, boolean justGetPreferred) {
}
preferredDim = null;
// fix for button vertical alignment -- should offset just by the ascent
String yoff = (wIcon == 0 ? "-" + (jc.getFont().getFontMetrics().getAscent()>>1) + "px" : "-50%");
String yoff = "-50%";
DOMNode.setStyles(centeringNode, "position", "absolute", "top", null, "left", null, "transform", null);
if (alignHCenter && alignVCenter && wIcon == 0
|| wText == 0 && margins.left == margins.right && margins.top == margins.bottom) {
Expand Down Expand Up @@ -2514,6 +2508,7 @@ protected void setAlignments(AbstractButton b, boolean justGetPreferred) {
switch (vTextPos) {
case SwingConstants.TOP:
top = itop = 0;
yoff = null;
break;
default:
case SwingConstants.CENTER:
Expand All @@ -2522,12 +2517,14 @@ protected void setAlignments(AbstractButton b, boolean justGetPreferred) {
itop = 70;
iscale = "scale(0.6,0.6)";
}
yoff = (wIcon == 0 ? "-" + ((jc.getFont().getFontMetrics().getAscent()>>1)+1) + "px" : "-50%");
break;
case SwingConstants.BOTTOM:
top = itop = 100;
yoff = null;
break;
}
DOMNode.setStyles(textNode, "top", top + "%", "transform", "translateY(-" + top + "%)");
DOMNode.setStyles(textNode, "top", top + "%", "transform", "translateY(" + (yoff == null ? "-" + top + "%" : yoff + ")"));
DOMNode.setStyles(iconNode, "top", top + "%", "transform",
"translateY(-" + itop + "%)" + (iscale == null ? "" : iscale));
} else {
Expand Down