JButton 在 Windows 上显示浅蓝色背景
我有以下代码来制作自定义的 JButton
ImageIcon icon = createImageIcon(
CommonUtils.class.getClassLoader().getResource("images/wright.png")
);
RightSlide.setIcon( icon );
ImageIcon icon2 = createImageIcon(
CommonUtils.class.getClassLoader().getResource("images/right_selected.png")
);
RightSlide.setPressedIcon( icon2);
RightSlide.setSelectedIcon(icon2);
RightSlide.setRolloverEnabled(true); // turn on before rollovers work
RightSlide.setRolloverIcon(icon2);
RightSlide.setBorderPainted(false);
RightSlide.setFocusPainted(false);
RightSlide.addActionListener(new ActionListener(){
该代码生成一个自定义按钮。当鼠标悬停、按下、单击和选择时,按钮的行为与预期一致。这适用于 MacOS 和 Linux (Ubuntu)。但相同的代码在 Windows 上有浅蓝色背景。这是从哪里来的以及我该如何摆脱它?
谢谢
I have the following code to make a custom looking JButton
ImageIcon icon = createImageIcon(
CommonUtils.class.getClassLoader().getResource("images/wright.png")
);
RightSlide.setIcon( icon );
ImageIcon icon2 = createImageIcon(
CommonUtils.class.getClassLoader().getResource("images/right_selected.png")
);
RightSlide.setPressedIcon( icon2);
RightSlide.setSelectedIcon(icon2);
RightSlide.setRolloverEnabled(true); // turn on before rollovers work
RightSlide.setRolloverIcon(icon2);
RightSlide.setBorderPainted(false);
RightSlide.setFocusPainted(false);
RightSlide.addActionListener(new ActionListener(){
The code generates a custom button. The button behaves as expected when hover over, pressed, clicked, and selected. This works on MacOS and Linux (Ubuntu). But the same code has a light blue background on Windows. Where does this come from and how do I get rid of it ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您缺少 JButton #setContentAreaFilled(false); 示例 此处
I think that you missing JButton#setContentAreaFilled(false); example here