Skip to content

Commit 29b13ec

Browse files
committed
UI issues with title borders on sliders, j2sComboBox trailing comma
1 parent 15e5a81 commit 29b13ec

File tree

6 files changed

+538
-48
lines changed

6 files changed

+538
-48
lines changed

sources/net.sf.j2s.java.core/src/javax/swing/border/TitledBorder.java

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -230,24 +230,24 @@ public TitledBorder(Border border,
230230
* @param height the height of the painted border
231231
*/
232232
@Override
233-
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
233+
public void paintBorder(Component c, Graphics g0, int x, int y, int width, int height) {
234234

235-
Border border = getBorder();
235+
Border border = getBorder();
236236

237237
if (getTitle() == null || getTitle().equals("")) {
238238
if (border != null) {
239-
border.paintBorder(c, g, x, y, width, height);
239+
border.paintBorder(c, g0, x, y, width, height);
240240
}
241241
return;
242242
}
243243

244244
Rectangle grooveRect = new Rectangle(x + EDGE_SPACING, y + EDGE_SPACING,
245245
width - (EDGE_SPACING * 2),
246246
height - (EDGE_SPACING * 2));
247-
Font font = g.getFont();
248-
Color color = g.getColor();
247+
Font font = g0.getFont();
248+
Color color = g0.getColor();
249249

250-
g.setFont(getFont(c));
250+
g0.setFont(getFont(c));
251251

252252
//JComponent jc = (JComponent)c;
253253
FontMetrics fm = getFont(c).getFontMetrics();
@@ -340,6 +340,8 @@ else if(justification==TRAILING) {
340340
// to show through the title.
341341
//
342342
if (border != null) {
343+
Rectangle clip0 = g0.getClipBounds();
344+
343345
if (((titlePos == TOP || titlePos == DEFAULT_POSITION) &&
344346
(grooveRect.y > textLoc.y - ascent)) ||
345347
(titlePos == BOTTOM &&
@@ -348,72 +350,71 @@ else if(justification==TRAILING) {
348350
Rectangle clipRect = new Rectangle();
349351

350352
// save original clip
351-
Rectangle saveClip = g.getClipBounds();
353+
//Rectangle saveClip = g.getClipBounds();
354+
355+
//JSGraphics2D cg = (JSGraphics2D) (Object) g;
356+
//int pt = cg.mark();
352357

353-
JSGraphics2D cg = (JSGraphics2D) (Object) g;
354-
int pt = cg.mark();
355358
// paint strip left of text
356-
clipRect.setBounds(saveClip);
359+
clipRect.setBounds(clip0);
357360
if (computeIntersection(clipRect, x, y, textLoc.x-1-x, height)) {
361+
Graphics g = g0.create();
358362
g.setClip(clipRect);
359363
border.paintBorder(c, g, grooveRect.x, grooveRect.y,
360364
grooveRect.width, grooveRect.height);
361-
cg.reset(pt);
362-
cg.mark();
365+
g.dispose();
363366
}
364367

365368
// paint strip right of text
366-
clipRect.setBounds(saveClip);
369+
clipRect.setBounds(clip0);
367370
if (computeIntersection(clipRect, textLoc.x+stringWidth+1, y,
368371
x+width-(textLoc.x+stringWidth+1), height)) {
372+
Graphics g = g0.create();
369373
g.setClip(clipRect);
370374
border.paintBorder(c, g, grooveRect.x, grooveRect.y,
371375
grooveRect.width, grooveRect.height);
372-
cg.reset(pt);
373-
cg.mark();
376+
g.dispose();
374377
}
375378

376379
if (titlePos == TOP || titlePos == DEFAULT_POSITION) {
377380
// paint strip below text
378-
clipRect.setBounds(saveClip);
381+
clipRect.setBounds(clip0);
379382
if (computeIntersection(clipRect, textLoc.x-1, textLoc.y+descent,
380383
stringWidth+2, y+height-textLoc.y-descent)) {
384+
Graphics g = g0.create();
381385
g.setClip(clipRect);
382386
border.paintBorder(c, g, grooveRect.x, grooveRect.y,
383387
grooveRect.width, grooveRect.height);
384-
cg.reset(pt);
385-
cg.mark();
388+
g.dispose();
386389
}
387390

388391
} else { // titlePos == BOTTOM
389392
// paint strip above text
390-
clipRect.setBounds(saveClip);
393+
clipRect.setBounds(clip0);
391394
if (computeIntersection(clipRect, textLoc.x-1, y,
392395
stringWidth+2, textLoc.y - ascent - y)) {
396+
Graphics g = g0.create();
393397
g.setClip(clipRect);
394398
border.paintBorder(c, g, grooveRect.x, grooveRect.y,
395399
grooveRect.width, grooveRect.height);
396-
cg.reset(pt);
397-
cg.mark();
400+
g.dispose();
398401
}
399402
}
400403

401404
// restore clip
402-
g.setClip(saveClip);
403-
cg.reset(pt);
405+
// g.setClip(saveClip);
404406

405407
} else {
406-
border.paintBorder(c, g, grooveRect.x, grooveRect.y,
408+
border.paintBorder(c, g0, grooveRect.x, grooveRect.y,
407409
grooveRect.width, grooveRect.height);
408410
}
409411
}
410412

411-
g.setColor(getTitleColor());
413+
g0.setColor(getTitleColor());
412414
//SwingUtilities2.drawString(jc, g, getTitle(), textLoc.x, textLoc.y);
413-
g.drawString(getTitle(), textLoc.x, textLoc.y);
414-
415-
g.setFont(font);
416-
g.setColor(color);
415+
g0.drawString(getTitle(), textLoc.x, textLoc.y);
416+
g0.setFont(font);
417+
g0.setColor(color);
417418
}
418419

419420
/**

sources/net.sf.j2s.java.core/src/swingjs/jquery/j2sComboBox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ J2S.__makeComboBox = function() {
8787
this.btn.addClass("swingjs-ui");
8888
this.popup = $( '<div>', {'class': 'j2scbpopup', 'id':id+'_popup' });
8989
this.popup.css({
90-
display:'none',
90+
display:'none'
9191
});
9292
this.list = $( '<ul>', {'class': 'j2scblist', 'id':id+'_list' });
9393
this.on2(this.list, 'click mousedown touchstart mousemove touchmove mouseup touchend mousewheel mouseover mouseout mouseenter mouseexit'.split(' '), '_mouse');

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,7 @@ public Object createValue(UIDefaults table) {
15491549
new Dimension(36, 21),
15501550
"Slider.minimumVerticalSize",
15511551
new Dimension(21, 36),
1552-
// "Slider.focusInsets", sliderFocusInsets,
1552+
"Slider.focusInsets", twoInsets,//sliderFocusInsets,
15531553
"Slider.focusInputMap",
15541554
new UIDefaults.LazyInputMap(new Object[] {
15551555
"RIGHT", "positiveUnitIncrement",

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.awt.dnd.peer.DropTargetPeer;
2222
import java.awt.event.KeyEvent;
2323
import java.awt.event.PaintEvent;
24+
import java.awt.image.BufferedImage;
2425
import java.awt.image.ColorModel;
2526
import java.awt.image.ImageObserver;
2627
import java.awt.image.ImageProducer;
@@ -1335,6 +1336,10 @@ protected void propertyChangedCUI(PropertyChangeEvent e, String prop) {
13351336

13361337

13371338
switch (prop) {
1339+
case "border":
1340+
jc.秘setPaintsSelf(JSComponent.PAINTS_SELF_UNKNOWN);
1341+
setTainted();
1342+
break;
13381343
case "preferredSize":
13391344
// size has been set by JComponent layout
13401345
preferredSize = (Dimension) e.getNewValue();
@@ -2386,7 +2391,7 @@ protected void setIconAndText(String prop, Icon icon, int gap, String text) {
23862391
icon = currentIcon = getIcon(jc, icon);
23872392
$(iconNode).empty();
23882393
if (currentIcon != null) {
2389-
imageNode = DOMNode.getImageNode(currentIcon.getImage());
2394+
imageNode = ((BufferedImage)currentIcon.getImage()).秘getImageNode();
23902395
iconNode.appendChild(imageNode);
23912396
iconHeight = icon.getIconHeight();
23922397
DOMNode.setStyles(imageNode, "visibility", (isLabel ? "hidden" : null));

0 commit comments

Comments
 (0)