Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rounded buttons are opaque #20

Closed
lbalazscs opened this issue Oct 22, 2019 · 6 comments
Closed

Rounded buttons are opaque #20

lbalazscs opened this issue Oct 22, 2019 · 6 comments

Comments

@lbalazscs
Copy link

The buttons don't seem to have real transparency at the corners and borders. Instead of the content behind them the panel color can be seen - this is only OK in simple cases when a button is on a panel.

In the following zoomed-in picture the red arrows indicate the problem areas. Here two buttons are placed on top of each other using a JLayeredPane in order to indicate the foreground and background colors that can be chosen. Such opaque areas don't appear when using Nimbus. Also the Intellij widgets have real transparency, this can be seen if you set a background picture in Idea.

flat_button_borders

@DevCharly
Copy link
Collaborator

You're right. Most components in FlatLaf (also in Metal and Windows LaF) are opaque.

I just used the default opacity of the components.

JLabel is maybe the only component that is not opaque. Even components like JCheckBox, JRadioButton and JSlider are opaque, although it would make much more sense that they are not opaque.

Nimbus, Substance and Aqua seem to use much more non-opaque components. Which makes sense, if the component does not fill its whole bounds.

Seems that I have to rework usage of opacity in FlatLaf completely...

@kirill-grouchnikov
Copy link

Yeah, I don't think that this has ever been on the Swing team radar - have some kind of a mechanism akin to the UIResource marker interface, but for the opacity. I made the decision to take control over opacity in Substance, and if the app starts changing it, the visual behavior is undefined.

@DevCharly
Copy link
Collaborator

Hmm, isn't LookAndFeel.installProperty() this mechanism?

LookAndFeel.installProperty( comboBox, "opaque", Boolean.FALSE);

Convenience method for installing a property with the specified name
and value on a component if that property has not already been set
by the developer. This method is intended to be used by
ui delegate instances that need to specify a default value for a
property of primitive type (boolean, int, ..), but do not wish
to override a value set by the client. Since primitive property
values cannot be wrapped with the UIResource marker, this method
uses private state to determine whether the property has been set
by the client.

As soon as the developer invokes c.setOpaque(...) it keeps this value and the UI delegate does/can not change it with LookAndFeel.installProperty(c, "opaque", ...).

Isn't this the same as when the developer invokes c.setBackground(new Color(1,2,3)). Then the UI delegate also do not change it.

I think when the developer uses setOpaque() or setBackground(), then he is responsible for the result.

@kirill-grouchnikov
Copy link

It eventually does get to set a separate OPAQUE_SET flag on the component, but also calls setOpaque. Maybe I'm thinking of some kind of mechanism that has two places to store opacity - one for app calls, and one for the current look-and-feel calls, and then somehow queries the two together at paint time. That might be too complicated though.

@lbalazscs
Copy link
Author

I don't understand everything you guys are talking about, I just wanted to mention that if I call

fgButton.setOpaque(false);

explicitly, then it becomes transparent at the border, but the background color also disappears:
flat_button_notopaque

So for my special case it would be enough to respect the background color property even if the component is set to non-opaque. But in general it seems that the idea of rounded buttons does not go well with the idea of opaque components.

JFormDesigner pushed a commit that referenced this issue Oct 23, 2019
@JFormDesigner
Copy link
Owner

fixed in 0.16

JFormDesigner pushed a commit that referenced this issue Oct 25, 2019
…paque.

`JPasswordField`, `JScrollPane` and `JTextField` are non-opaque if they have
an outside focus border (e.g. IntelliJ and Darcula themes).
(issues #20 and #17)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants