Skip to content

Commit 96c7ee6

Browse files
committed
trying simple fullyCentered option for cssCtr in simple labels
1 parent 97a7e73 commit 96c7ee6

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,11 +1687,8 @@ protected Dimension setHTMLSize1(DOMNode node, boolean addCSS, boolean usePrefer
16871687
// setting here
16881688

16891689
if (!isMenuItem) {
1690-
@SuppressWarnings("unused")
16911690
boolean simpleButton = isSimpleButton;
1692-
@SuppressWarnings("unused")
16931691
DOMNode centerNode = centeringNode;
1694-
@SuppressWarnings("unused")
16951692
DOMNode dnode = domNode;
16961693
/**
16971694
* @j2sNative
@@ -2661,9 +2658,9 @@ protected void setAlignments(AbstractButton b, boolean justGetPreferred) {
26612658
if (isFullyCentered) {
26622659
// simple totally centered label or button
26632660
// can't have width or height here --- let the browser figure that out
2664-
fullyCenter(cssCtr);
2665-
fullyCenter(cssIcon);
2666-
fullyCenter(cssTxt);
2661+
fullyCenter(cssCtr, isSimpleButton || isLabel);
2662+
fullyCenter(cssIcon, isSimpleButton);
2663+
fullyCenter(cssTxt, isSimpleButton);
26672664
} else {
26682665

26692666
// horizontal
@@ -2795,8 +2792,8 @@ protected void setAlignments(AbstractButton b, boolean justGetPreferred) {
27952792
updateCellNode();
27962793
}
27972794

2798-
private void fullyCenter(Object css) {
2799-
if (isSimpleButton)
2795+
private void fullyCenter(Object css, boolean noOffsets) {
2796+
if (noOffsets)
28002797
addJSKeyVal(css, "width", null, "position", null, "padding", "0", "margin", "0 auto");
28012798
else
28022799
addJSKeyVal(css, "width", null, "top", "50%", "left", "50%", "transform",

sources/net.sf.j2s.java.core/src/test/TApp2_Swing.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ private void setLBBounds(Component b, Component l, int i, int j) {
8282
b.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10 + i * 3));
8383
l.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10 + i * 3));
8484
l.setBackground(Color.cyan);
85+
((JComponent) l).setOpaque(true);
8586
add(b);
8687
add(l);
8788
}

0 commit comments

Comments
 (0)