因为它不会让我添加图片-新帐户



这是利用Java GUI
上面的图像是粘贴到按钮上的图像,我试图使按钮透明,以便用户看不到它,但我似乎无法摆脱这个蓝色边框。
我到目前为止的代码

    boss2 = new JButton();    //declared the static button earlier on in the code

    boss2.setSize(300, 300);
    boss2.setLocation(315, 200);
    boss2.setIcon(new ImageIcon("dragon.gif"));
    boss2.setRolloverIcon(new ImageIcon("dragon.gif"));
    boss2.setOpaque(false);
    boss2.setContentAreaFilled(false);
    boss2.setBorder(null);


有没有办法消除图像周围的蓝色边框?

编辑-很抱歉,您之前的不幸事故,上传了错误的文件

最佳答案

我建议您看到的是焦点矩形,用于将按钮“突出显示”为具有键盘焦点。

您可以使用boss2.setFocusPainted(false);阻止其绘制。

10-04 17:23