I've prepared transparent Button class:

public MyButton() {

        super("button");
        setOpaque(false);
        setContentAreaFilled(false);
        setBorder(null);
        setBorderPainted(false);
    }

But button is not fully transparent. When it is clicked it looks like this:

enter image description here

Is there any way to avoid this annoying rectangle? There is no such problem in default L&F but I'd like to use SystemLookAndFeel.

有帮助吗?

解决方案

You could do

setFocusPainted(false);

Note: All the above functionality can be achieved by just creating an instance of JButton and using rather than sub-classing the component

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top