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
...全文
87 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
代码下载链接: https://pan.quark.cn/s/cf0000dae7ac 在.NET Framework平台中,`TreeView`组件是一种普遍应用的数据展示工具,主要功能是呈现层级化数据,例如文件系统布局、组织架构图等。本文将深入阐述在C#环境下如何运用递归方法为`TreeView`组件配置子节点,尤其是在管理文件夹层次结构的应用场景中。递归是一种高效的编程策略,其特点在于函数能够自我调用以完成特定任务,这种技术特别适用于处理具有层级关联的数据集合。为了有效运用`TreeView`组件,我们首先需要明确其核心构成单元:`TreeNode`。`TreeNode`是`TreeView`中的一个基本单元,它可以承载子节点,从而构建出树状结构。为了在`TreeView`中准确反映文件夹结构,每一个`TreeNode`通常映射为一个文件夹,而其下属的子节点则对应该文件夹内的子文件夹或文件。现在我们聚焦于核心内容,探讨如何通过递归方式实现子节点的添加。1. **构建基础框架** 我们需要设计一个类来描述文件或文件夹,该类应包含名称、路径等基本属性。例如: ```csharp public class FileSystemItem { public string Name { get; set; } public string Path { get; set; } // 其他属性如IsDirectory等 } ```2. **采集文件系统数据** 借助`System.IO`命名空间中的`DirectoryInfo`和`FileInfo`类,对目标目录进行遍历,以获取所有文件和子文件夹的信息。这里可以利用`GetDirectories()`和`GetFiles...
内容概要:本文系统阐述了Java微服务架构与TypeScript全栈工程化的实战方法,涵盖从单体应用拆分到分布式系统治理的完整技术链条。在Java微服务部分,基于Spring Boot与Spring Cloud生态,深入讲解领域驱动设计(DDD)、服务注册与发现(如Nacos、Eureka)、配置中心、API网关(Spring Cloud Gateway)、声明式调用(Feign)、负载均衡、服务熔断降级(Resilience4j/Hystrix)、消息队列异步解耦(Kafka/RabbitMQ)以及分布式事务(如Seata)等核心技术。数据层强调数据库自治原则,并结合Redis提升性能。前端部分聚焦TypeScript类型系统,通过静态类型检查增强代码可靠性,支持泛型、联合类型、映射类型等高级特性,实现前后端接口模型统一。全栈协作采用React/Vue/Angular框架,结合Axios通信与Swagger接口文档标准化。工程化层面引入Docker、Kubernetes实现容器化部署,配合Jenkins或GitHub Actions完成CI/CD自动化流程,并通过ELK实现日志追踪。典型应用场景包括电商、订单管理等系统,实现高内聚、低耦合、可扩展的分布式架构。; 适合人群:具备一定Java与前端基础,从事中高级后端开发、全栈开发或系统架构工作的技术人员,尤其适合1-5年经验并希望掌握微服务与全栈工程化实践的研发人员。; 使用场景及目标:①掌握微服务拆分与Spring Cloud微服务体系建设;②理解服务治理、异步通信、分布式事务等关键问题的解决方案;③构建类型安全的全栈项目,提升前后端协作效率与系统稳定性;④实现微服务的容器化部署与持续交付。; 阅读建议:建议结合实际项目边学边练,重点关注架构设计思想与技术选型背后的权衡,同时动手搭建完整微服务链路与前端类型系统,深入理解各组件集成方式与最佳实践。

62,622

社区成员

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

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