改变JProgressBar的形状 [英] Change shape of JProgressBar

查看:135
本文介绍了改变JProgressBar的形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Java的新手,但需要知道,如果开发人员可以这样做,他/她可以改变 JProgressBar 的形状。我的意思是假设在我的情况下我想改变形状,使它看起来像一个圆圈或其他东西?

I am new to Java but needs to know that if it is possible for a developer so that he/she can change the shape of the JProgressBar. I mean suppose in my case I want to change the shape so that it looks like a circle or something else?

虽然我只是想让它从条形改变弧形,或者你可以说我想把条形改成任何其他形状。我的进度条可能看起来像条形以外的曲线。我想在其中添加曲线。

Though I just want it to be changed from a bar shape to an arc shape or you can say i want to change the bar shape into any other shape. My progress bar may look like a curve other than a bar shape. I want to add a curve in it.

推荐答案

JProgressBar 由组件的UI委托控制,通常派生自 BasicProgressBarUI 。您可以提供自己的代理,如此处所示,并覆盖所需的绘制方法。

The appearance of a JProgressBar is controlled by the component's UI delegate, typically derived from BasicProgressBarUI. You can supply your own delegate, as shown here, and override the desired paint method.

附录:对于半圆形展示,您可以利用 DialPlot / info> JFreeChart 库。 此处讨论了一个完整的示例。您可以直接使用它或在UI委托中呈现图表。

Addendum: For a semi-circular display, you may be able to leverage DialPlot from the JFreeChart library. A complete example is discussed here. You can use it directly or render the chart in your UI delegate.

这篇关于改变JProgressBar的形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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