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
...全文
136 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
内容概要:本文围绕分布式电源接入对配电网的影响展开研究,利用Matlab进行仿真代码实现,系统探讨了风电、光伏等分布式电源接入后对配电网电压分布、潮流特性、电能质量和系统稳定性等方面的多维度影响。研究构建了典型的配电网模型,通过模拟不同渗透率与接入位置的运行场景,深入分析其引发的技术挑战,并提出了包括无功补偿、网络重构及储能协调控制在内的优化调控策略,以提升电网的接纳能力与运行可靠性。同时,结合智能优化算法(如粒子群、遗传算法等)开展多目标优化求解,兼顾经济性、低碳性与系统稳定性,形成一套完整的建模、仿真与优化技术体系。; 适合人群:具备电力系统基础知识,熟练掌握Matlab/Simulink仿真工具,从事新能源并网、配电网规划与运行、智能电网优化等相关领域的研究生、科研人员及工程技术人员。; 使用场景及目标:①掌握分布式电源接入对配电网影响的建模与仿真方法;②学习基于Matlab的配电网潮流计算、稳定性分析与优化调度实现技术;③应用于科研课题、学位论文或工程项目中关于新能源接入的系统评估、优化设计与决策支持;; 阅读建议:建议读者结合文中提供的Matlab代码实例,逐步复现仿真过程,重点关注模型构建、参数设置、约束条件处理与优化算法实现细节,同时参考相关文献深化对配电网运行机理与控制策略的理解,以实现理论与实践的深度融合。
很多怀旧爱好者、民俗查阅人群在查阅传统黄历时一直被纸质挂历的短板困扰,每年都需要购置新日历,存放占用空间,翻阅查找指定日期费时费力,普通电子日历大多样式单调,缺少传统黄历完整民俗信息。**电子手撕老黄历**就是针对这类需求打造的桌面万年历查阅工具,依托仿真纸质交互设计,完整复刻传统老黄历全套内容,无需年年更换,帮助用户沉浸式查阅历法民俗资料,兼顾情怀质感与查阅效率,零学习门槛,适配电脑桌面长期使用。 它的核心能力集中在**仿真纸张交互**与**万年历法检索**两大模块,搭配高清文档导出功能,每一项功能都围绕查阅留存需求设计。仿真纸张交互可以模拟真实挂历翻页、卷纸与手撕页面效果,纸张带有透视阴影,撕纸碎片动态飞出,还原手撕老黄历的怀旧手感。万年历法检索覆盖超大时间跨度,公历农历对照展示,完整收纳节气、宜忌、时辰吉凶、九星五行、冲煞方位等全套黄历信息;高清导出支持 300DPI 图片与多页 PDF 生成,方便资料保存与打印排版。 这款软件可以适配多种个人查阅与素材制作场景。民俗文化爱好者可以随时查询任意年代的历法信息,快速查看每日宜忌、胎神方位、潮汐时间与当日主题对联,用于传统文化内容研读。内容创作者可以借助导出功能,将黄历页面生成为高清图片或 PDF 文档,直接用于图文素材制作。日常居家用户放置在电脑桌面,随时查看节气节日,周末自动切换红色主题,工作日使用青绿纸本样式,区分阅读视觉,满足日常日期查看、民俗参考的轻量需求。

62,620

社区成员

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

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