set a icon for JRadioButton

liaomingxue 2003-10-04 10:42:14
Sorry,Chinese Input failed!!!!!!!!!!!

Set a icon for a JRadioButton component meeting the following:
1: a icon including
2: text excluded
and keeing radiobutton's original round check box to indicate whether checked or not.

High score is available for good answer
...全文
131 9 打赏 收藏 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
liad 2003-10-07
  • 打赏
  • 举报
回复
JToolBar toolBar = new JToolBar();
toolBar.setLayout(new FlowLayout(FlowLayout.LEFT));
// toolBar.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 0));
liaomingxue 2003-10-06
  • 打赏
  • 举报
回复
提前
raysand 2003-10-06
  • 打赏
  • 举报
回复
<![CDATA[
Sorry,Chinese Input failed!!!!!!!!!!!

Set a icon for a JRadioButton component meeting the following:
1: a icon including
2: text excluded
and keeing radiobutton's original round check box to indicate whether checked or not.

High score is available for good answer
]]>
liaomingxue 2003-10-06
  • 打赏
  • 举报
回复
问题是这样的:
radioButton.setText("<html><img src=a image file name>");
可以保留原来的圆形按钮,并将我们的图标放到后面,但是问题是:
我们的这个图标将尽可能地占据剩余空间.如果将这个按钮与其他普通按钮
加到一个工具栏中,我们再最大化窗口,就会发现这个按钮占据了庞大的空间
宽度!!!!!!这是为什么呢?这个按钮变得象glue一样!!!
newman0708 2003-10-05
  • 打赏
  • 举报
回复
对这个网页上有,看过了。
http://javaalmanac.com/egs/javax.swing/checkbox_CustIcon.html
liaomingxue 2003-10-05
  • 打赏
  • 举报
回复
输入法好了,我重新说一下:

按照liad,可以放置两个图标,一个是原来的,用来指示选择状态;
一个是我们配置的,用来显示按钮含义;但是我们定义的图标将占据
很宽的空间,不管怎样设置大小,都无法避免.

按照后面两者的说法,只能放一个图标.
liaomingxue 2003-10-04
  • 打赏
  • 举报
回复
according to liad, the icon we add will hold a very wide space
even if setting a width property for img,td,or tr html tag.
Also, I use img tag directly,but the same result.....

for YuLimin(阿敏当兵) :
the method tells us how to change icon ,not to set a new icon
together with default round icon.
YuLimin 2003-10-04
  • 打赏
  • 举报
回复
import java.awt.Container;
import java.awt.FlowLayout;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JRadioButton;

public class Test extends JApplet
{
public void init()
{
Container contentPane = getContentPane();
Icon icon = new ImageIcon(getImage(getCodeBase(),"bulb.gif"));
JRadioButton[] radioButtons = new JRadioButton[]
{
new JRadioButton(),
new JRadioButton(icon),
new JRadioButton(icon,true),
new JRadioButton("idea!"),
new JRadioButton("idea!",true),
new JRadioButton("idea!",icon),
new JRadioButton("idea!",icon,true)
};
contentPane.setLayout(new FlowLayout());

for(int i = 0;i < radioButtons.length;++i)
{
radioButtons[i].setBorderPainted(true);
contentPane.add(radioButtons[i]);

if(radioButtons[i].getIcon() != null)
{
System.out.println("setting selected icon");
radioButtons[i].setSelectedIcon(new ImageIcon(getImage(getCodeBase(),"bulb_bright.gif")));
}
}
}
}
liad 2003-10-04
  • 打赏
  • 举报
回复
this maybe help
http://javaalmanac.com/egs/javax.swing/pkg.html#JRadioButton
内容概要:本文针对不平衡电网条件下T型三电平并网逆变器面临的电能质量问题,提出了一种基于延时相消序分量分离的自适应调控策略,并通过Simulink平台进行了系统仿真验证。研究核心在于解决电网电压不平衡所引发的并网电流畸变、负序分量耦合以及中点电位波动等关键难题。通过引入延时相消法,实现了正序与负序电压、电流分量的精确、快速分离,克服了传统对称分量法在动态响应和滤波延迟方面的不足;结合自适应电流控制算法,优化了双闭环控制结构,有效抑制了不平衡工况下的谐波与负序电流,显著提升了并网电流的电能质量。同时,该策略集成了中点电位平衡控制,确保了直流侧电压的稳定。该方法具有响应迅速、控制精度高、鲁棒性强等优点,为复杂电网环境下的高性能并网提供了有效的技术方案。; 适合人群:具备扎实的电力电子技术、自动控制理论及新能源发电系统专业知识,从事逆变器控制算法开发、微电网电能质量治理、新能源并网技术研究等相关领域的科研人员与工程技术人员,尤其适合具有硕士及以上学历或拥有相关项目实践经验的研发人员。; 使用场景及目标:①应用于城市轨道交通、工业生产等存在显著电网不平衡的场合,提升T型三电平逆变器的并网性能与系统可靠性;②为解决因电压不平衡导致的设备过热、效率下降及保护误动等实际工程问题提供理论指导和技术支持;③作为高等院校和科研院所中电力电子与电力系统控制方向的高水平教学案例与科研仿真平台。; 阅读建议:读者应紧密结合所提供的Simulink仿真模型,深入剖析延时相消模块、自适应电流控制器及中点电位平衡单元的设计原理与实现细节。建议在学习过程中亲手搭建或修改仿真模型,通过调整电网不平衡度、负载变化等参数,观察系统在不同工况下的动态响应过程,以深刻理解该自适应调控机制的优越性与内在工作机理。

62,620

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧