[英]How to remove the blue box that appears when i click JButton
When i click Button, the blank part of the image looks blue.当我单击按钮时,图像的空白部分看起来是蓝色的。 Is there any way?有什么办法吗?
left.setPressedIcon(l1);
left.setOpaque(false);
left.setFocusPainted(false);
left.setBackground(new Color(0,0,0,0));
left.setBorderPainted(false);
left.setBounds(-15, 400, 100, 200);
left.setBackground(new Color(0,0,0,0));
Don't attempt to use a transparent color.不要尝试使用透明颜色。 Swing doesn't paint transparent colors properly. Swing 不能正确绘制透明 colors。 See: Backgrounds With Transparency .请参阅: 具有透明度的背景。
In any case that is not needed be you are using在任何情况下,您都不需要使用
left.setOpaque( false );
When i click Button, the blank part of the image looks blue当我单击按钮时,图像的空白部分看起来是蓝色的
Try:尝试:
left.setContentAreaFilled( false );
Also:还:
left.setBounds(-15, 400, 100, 200);
Don't use setBounds(...) and a null layout.不要使用 setBounds(...) 和 null 布局。 Swing was designed to be used with layout managers. Swing 旨在与布局管理器一起使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.