Skip to content

Commit 021d71f

Browse files
authored
Merge pull request #95 from BobHanson/master
adds fix for JSGraphics2D.drawDirect table work fixed use of save/restore of ui nodes in tables default background white inadvertent resetting of table background via JPopupMenu
2 parents 29e498d + 840fdf9 commit 021d71f

36 files changed

+21089
-21085
lines changed
-59.7 KB
Binary file not shown.
-11 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20181213165944
1+
20181217223342
-59.7 KB
Binary file not shown.
-11 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20181213165944
1+
20181217223342
9.1 KB
Binary file not shown.

sources/net.sf.j2s.java.core/src/components/TableDemo.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import javax.swing.JPanel;
4141
import javax.swing.JScrollPane;
4242
import javax.swing.JTable;
43+
import javax.swing.SwingConstants;
4344
import javax.swing.border.LineBorder;
4445
import javax.swing.table.AbstractTableModel;
4546
import javax.swing.table.TableCellRenderer;
@@ -65,7 +66,8 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
6566
int row, int column) {
6667
setOpaque(true);
6768
setBackground(colors[row % 3]);
68-
setText(" " + row);
69+
setText("" + row);
70+
setHorizontalAlignment(SwingConstants.CENTER);
6971
setBorder(new LineBorder(Color.white, 3));
7072
return this;
7173
}

sources/net.sf.j2s.java.core/src/javax/swing/JPopupMenu.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -847,9 +847,10 @@ public Component getInvoker() {
847847
public void setInvoker(Component invoker) {
848848
Component oldInvoker = this.invoker;
849849
this.invoker = invoker;
850-
if ((oldInvoker != this.invoker) && (ui != null)) {
851-
((JSComponentUI) ui).reinstallUI(this, (JComponent) invoker);
852-
}
850+
// SwingJS does not do this
851+
// if ((oldInvoker != this.invoker) && (ui != null)) {
852+
// ((JSComponentUI) ui).reinstallUI(this, (JComponent) invoker);
853+
// }
853854
invalidate();
854855
}
855856

sources/net.sf.j2s.java.core/src/javax/swing/SwingUtilities.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -970,9 +970,6 @@ private static String layoutCompoundLabelImpl(
970970
/* Initialize the icon bounds rectangle iconR.
971971
*/
972972

973-
System.out.println("SwingUtil tiv0 " + text + "\n" + textR + "\n" + iconR + "\n" + viewR + "\n"
974-
+ fm.getDescent() + " " + fm.getAscent() + " " + fm.getHeight() + " " + fm.getMaxAscent());
975-
976973
if (icon != null) {
977974
iconR.width = icon.getIconWidth();
978975
iconR.height = icon.getIconHeight();
@@ -1017,11 +1014,15 @@ private static String layoutCompoundLabelImpl(
10171014
(int) v.getPreferredSpan(View.X_AXIS));
10181015
textR.height = (int) v.getPreferredSpan(View.Y_AXIS);
10191016
} else {
1020-
Dimension d = ui.getHTMLSize(ui.textNode);
1021-
textR.width = d.width;
1022-
textR.height = d.height;
1023-
System.out.println("swingutil " + text + " " + d + " " + fm.getHeight());
1024-
// Take into account the left and right side bearings.
1017+
if (ui.textNode == null) {
1018+
textR.width = fm.stringWidth(text);
1019+
textR.height = fm.getHeight();
1020+
} else {
1021+
Dimension d = ui.getHTMLSize(ui.textNode);
1022+
textR.width = d.width;
1023+
textR.height = d.height;
1024+
}
1025+
// Take into account the left and right side bearings.
10251026
// This gives more space than it is actually needed,
10261027
// but there are two reasons:
10271028
// 1. If we set the width to the actual bounds,
@@ -1148,9 +1149,7 @@ else if (horizontalAlignment == RIGHT) {
11481149
// SwingJS, for JSGraphicsUtil setting preferred button size;
11491150
viewR.width = labelR_width;
11501151
viewR.height = labelR_height;
1151-
}
1152-
1153-
System.out.println("SwingUtil tiv " + text + "\n" + textR + "\n" + iconR + "\n" + viewR + "\n");
1152+
}
11541153
return text;
11551154
}
11561155

0 commit comments

Comments
 (0)