Skip to content

Commit e308400

Browse files
committed
JViewport fix for painted background
1 parent dd471a0 commit e308400

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

sources/net.sf.j2s.java.core/src/java/awt/GraphicsCallback.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ private PaintHeavyweightComponentsCallback() {}
121121
@Override
122122
public void run(Component comp, Graphics cg) {
123123
if (comp.isLightweight()) {
124+
// never true in SwingJS
124125
// if (comp.peer instanceof LightweightPeer) {
125126
comp.paintHeavyweightComponents(cg);
126127
} else {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,11 @@ public Rectangle getViewRect() {
11531153
* @param blitPaint the area to blit
11541154
* @return true if the parameters are modified and we're ready to blit;
11551155
* false otherwise
1156+
*
1157+
* SwingJS cannot blit, as there is only one canvas for the entire JFrame or JApplet.
1158+
*
1159+
* @j2sNative
1160+
* return false;
11561161
*/
11571162
protected boolean computeBlit(
11581163
int dx,
@@ -1162,6 +1167,7 @@ protected boolean computeBlit(
11621167
Dimension blitSize,
11631168
Rectangle blitPaint)
11641169
{
1170+
11651171
int dxAbs = Math.abs(dx);
11661172
int dyAbs = Math.abs(dy);
11671173
Dimension extentSize = getExtentSize();

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public class JSSliderUI extends JSLightweightUI implements PropertyChangeListene
2727

2828
static {
2929
Object jqueryui = JQueryUI.class; // loads jQuery.ui
30+
// this static call allows for the CSS to be loaded only once and only when needed
31+
JSUtil.loadStaticResource("swingjs/jquery/jquery-ui-j2sslider.css");
32+
JSUtil.loadStaticResource("swingjs/jquery/jquery-ui-j2sslider.js");
3033
}
3134

3235
JSlider jSlider;
@@ -55,16 +58,7 @@ public class JSSliderUI extends JSLightweightUI implements PropertyChangeListene
5558
private boolean isVerticalScrollBar;
5659
private boolean isInverted;
5760

58-
private static boolean cssLoaded = false;
59-
60-
public JSSliderUI() {
61-
62-
if (!cssLoaded) {
63-
// this static call allows for the CSS to be loaded only once and only when needed
64-
JSUtil.loadStaticResource("swingjs/jquery/jquery-ui-j2sslider.css");
65-
JSUtil.loadStaticResource("swingjs/jquery/jquery-ui-j2sslider.js");
66-
cssLoaded = true;
67-
}
61+
public JSSliderUI() {
6862
needPreferred = true;
6963
setDoc();
7064
}

0 commit comments

Comments
 (0)