自定义滑块UI Swing [英] Custom slider UI Swing

查看:187
本文介绍了自定义滑块UI Swing的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建BasicSliderUI的自定义扩展。我只是想让拇指圆圈(注意我在Windows L& F)。我创建了一个非常简单的实现,只需调用g.drawOval,但是每当拖动它时,它会留下一个跟踪。任何想法为什么是这样的?

I'm trying to create a custom extension of BasicSliderUI. I'm just trying to make the thumb a circle (note I'm in the Windows L&F). I've created a very simple implementation that just calls g.drawOval, but whenever I drag it, it leaves a "trail" behind. Any ideas why this is?

谢谢,

Jeff

推荐答案

你需要在整个事情上调用重绘,你不能在其上画椭圆形。 Swing默认情况下只会重绘需要重画的内容,这通常不是整个控件。你什么时候画圆?

You need to call repaint on the whole thing, you cant just draw the oval on top of it. Swing will by default only repaint what needs to be repainted, which usually isn't the whole control. When are you drawing the circle?

这篇关于自定义滑块UI Swing的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆