|
4 | 4 | import java.awt.Color; |
5 | 5 | import java.awt.Component; |
6 | 6 | import java.awt.Container; |
| 7 | +import java.awt.Cursor; |
7 | 8 | import java.awt.Dimension; |
8 | 9 | import java.awt.Font; |
9 | 10 | import java.awt.FontMetrics; |
@@ -1387,12 +1388,10 @@ protected boolean setUIDisabled(boolean b) { |
1387 | 1388 | * can be set false to never draw a background, primarily because Mac OS will |
1388 | 1389 | * paint a non-rectangular object. |
1389 | 1390 | * |
1390 | | - * (textfield, textarea, button, combobox, menuitem, scrollbar) |
| 1391 | + * (InternalFrame, Button, ComboBox, MenuBar, MenuItem, ScrollBar, TextField, TextArea, EditorPane) |
1391 | 1392 | */ |
1392 | 1393 | protected boolean allowPaintedBackground = true; |
1393 | 1394 |
|
1394 | | - //private boolean backgroundPainted; |
1395 | | - |
1396 | 1395 | /** |
1397 | 1396 | * Label will render its image, drawing to the canvas; Button will not |
1398 | 1397 | * (as of this writing), so we need a flag to know when to not hide it. |
@@ -1456,9 +1455,47 @@ public DOMNode updateDOMNode() { |
1456 | 1455 | protected DOMNode updateDOMNodeCUI() { |
1457 | 1456 | if (cellComponent != null) |
1458 | 1457 | updateCellNode(); |
| 1458 | + if (myCursor != getCursor()) |
| 1459 | + setCursor(); |
1459 | 1460 | return domNode; |
1460 | 1461 | } |
1461 | 1462 |
|
| 1463 | + |
| 1464 | + @Override |
| 1465 | + public void updateCursorImmediately() { |
| 1466 | + if (isUIDisabled) |
| 1467 | + return; |
| 1468 | + setHTMLElement(); // for a frame, this is the call that connects it to BODY |
| 1469 | + setCursor(); |
| 1470 | + } |
| 1471 | + |
| 1472 | + private void setCursor() { |
| 1473 | + myCursor = getCursor(); |
| 1474 | + String curs = JSToolkit.getCursorName(myCursor); |
| 1475 | + DOMNode.setStyles(outerNode, "cursor", curs); |
| 1476 | + DOMNode.setStyles(domNode, "cursor", curs); |
| 1477 | + setWaitImage(curs == "wait"); |
| 1478 | + } |
| 1479 | + |
| 1480 | + |
| 1481 | + private Cursor getCursor() { |
| 1482 | + Cursor cur = c.getCursor(); |
| 1483 | + return (cur == Cursor.getDefaultCursor() ? null : cur); |
| 1484 | + } |
| 1485 | + |
| 1486 | + |
| 1487 | + protected void setWaitImage(boolean doShow) { |
| 1488 | + if (waitImage == null) { |
| 1489 | + if (!doShow) |
| 1490 | + return; |
| 1491 | + String path = (/** @j2sNative this.applet._j2sPath || */null) + "/img/cursor_wait.gif"; |
| 1492 | + waitImage = newDOMObject("image", id + "_waitImage", "src", path); |
| 1493 | + } |
| 1494 | + if (doShow) |
| 1495 | + $(waitImage).show(); |
| 1496 | + else |
| 1497 | + $(waitImage).hide(); |
| 1498 | + } |
1462 | 1499 | protected DOMNode setCssFont(DOMNode obj, Font font) { |
1463 | 1500 | if (font != null) { |
1464 | 1501 | int istyle = font.getStyle(); |
@@ -1817,23 +1854,6 @@ public void update(Graphics g, JComponent c) { |
1817 | 1854 | paint(g, c); |
1818 | 1855 | } |
1819 | 1856 |
|
1820 | | - |
1821 | | -// /** |
1822 | | -// * This flag is set by border painting and background painting detection to |
1823 | | -// * indicate that a cell renderer must do that painting. |
1824 | | -// */ |
1825 | | -// public void setPainted(Object g) { |
1826 | | -// if (g == null) { |
1827 | | -// // reset |
1828 | | -// backgroundPainted = false; |
1829 | | -// if (allowPaintedBackground) |
1830 | | -// DOMNode.setStyles(domNode, "background", null); |
1831 | | -// } else { |
1832 | | -// backgroundPainted = true; |
1833 | | -// setTransparent(domNode); |
1834 | | -// } |
1835 | | -// } |
1836 | | - |
1837 | 1857 | /** |
1838 | 1858 | * from ComponentPeer; not implemented in SwingJS |
1839 | 1859 | */ |
@@ -2335,6 +2355,8 @@ protected int getDefaultIconTextGap() { |
2335 | 2355 | */ |
2336 | 2356 | private boolean isFullyCentered; |
2337 | 2357 |
|
| 2358 | + private Cursor myCursor; |
| 2359 | + |
2338 | 2360 | protected static Insets zeroInsets = new Insets(0, 0, 0, 0); |
2339 | 2361 |
|
2340 | 2362 | protected void getJSInsets() { |
@@ -2879,41 +2901,6 @@ public void setFont(Font f) { |
2879 | 2901 | setCssFont((textNode == null ? domNode : textNode), f); |
2880 | 2902 | } |
2881 | 2903 |
|
2882 | | - @Override |
2883 | | - public void updateCursorImmediately() { |
2884 | | - if (isUIDisabled) |
2885 | | - return; |
2886 | | - setHTMLElement(); |
2887 | | - String curs = JSToolkit.getCursorName(c.getCursor()); |
2888 | | - DOMNode.setStyles(outerNode, "cursor", curs); |
2889 | | - DOMNode.setStyles(domNode, "cursor", curs); |
2890 | | - setWaitImage(curs == "wait"); |
2891 | | - } |
2892 | | - |
2893 | | - protected void setWaitImage(boolean doShow) { |
2894 | | - if (waitImage != null) { |
2895 | | - if (!doShow) |
2896 | | - return; |
2897 | | - String path = ""; |
2898 | | - /** |
2899 | | - * @j2sNative |
2900 | | - * |
2901 | | - * path = this.applet._j2sPath; |
2902 | | - * |
2903 | | - */ |
2904 | | - { |
2905 | | - } |
2906 | | - path += "/img/cursor_wait.gif"; |
2907 | | - if (debugging) |
2908 | | - System.out.println("loading wait cursor " + path); |
2909 | | - waitImage = newDOMObject("image", id + "_waitImage", "src", path); |
2910 | | - } |
2911 | | - if (doShow) |
2912 | | - $(waitImage).show(); |
2913 | | - else |
2914 | | - $(waitImage).hide(); |
2915 | | - } |
2916 | | - |
2917 | 2904 | @Override |
2918 | 2905 | public Image createImage(ImageProducer producer) { |
2919 | 2906 | JSUtil.notImplemented(""); |
@@ -3221,7 +3208,6 @@ public void setRenderer(JSComponent rendererComponent, int width, int height, DO |
3221 | 3208 | return; |
3222 | 3209 | } |
3223 | 3210 | cellComponent = (JComponent) rendererComponent; |
3224 | | - //backgroundPainted = false; |
3225 | 3211 | if (width == 0) |
3226 | 3212 | return; |
3227 | 3213 | cellWidth = width; |
|
0 commit comments