-
Notifications
You must be signed in to change notification settings - Fork 235
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
Custom window decoration works incorrectly in some cases #604
Comments
The problem appears to be in recently modified part of There are a few solutions that can be applied to fix this (and this isn't actually the first time this problem appeared), in perfect case scenario - |
I've added temporary workaround for this, it will be available in v1.3.0 snapshot version soon and in the final v1.3.0 update once it goes live. |
Added for v1.5.0 as planned improvement. |
Just a small note - workaround be available in v1.2.13 update that will be going live shortly. |
Workaround is available in v1.2.13, the remaining larger changes will be added in future updates. |
and i fix it by code ` JDialog dialog = new JDialog();
but the dialog can not drag move as normal dialog. how can this do ? |
Before I proceed to offer a solution I must add a disclaimer: Swing currently doesn't support subpixel font antialiasing in non-opaque (undecorated) windows under any OS (check #130). Also undecorated windows are only properly supported under Windows and Mac OS X operating systems, you will most probably encounter issues with undecorated windows on other OS. And there are generally some other problems with undecorated windows (example #466) that you may encounter. So I generally do not recommend using non-native window decoration unless your application's target audience is now Windows or Mac OS X and you are sure that issues mentioned above do not matter for your application. Now, as for the solution - I would recommend simply using a custom dialog style: <!-- Undecorated control-less dialog -->
<style type="rootpane" id="my-dialog" extends="dialog-undecorated">
<painter>
<decorations>
<decoration>
<WebShape round="10" />
</decoration>
</decorations>
</painter>
</style> This is enough to make it look exactly as you've shown on the screenshot. Also this style applies directly to You can also further customize the style if you want to. <!-- Undecorated control-less dialog -->
<style type="rootpane" id="my-dialog" extends="dialog-undecorated">
<painter>
<decorations>
<decoration>
<WebShape round="10" />
<WebShadow type="outer" opacity="0.3" width="20" />
</decoration>
<decoration states="focused">
<WebShadow type="outer" opacity="0.5" />
</decoration>
</decorations>
</painter>
</style> You can customize background, border, shadow, add any supported elements in any supported states etc. You can use the style directly in the final WebDialog dialog = new WebDialog ( StyleId.of ( "my-dialog" ) ); Or apply the style to final JDialog dialog = new JDialog ( parent );
dialog.getRootPane ().putClientProperty ( StyleId.STYLE_PROPERTY, StyleId.of ( "my-dialog" ) ); No other settings are necessary. |
try you method i found the whole dialog font type not change but they all look not same as it is. wyh ?can any method fix it. |
As I've mentioned it in the disclaimer above - non-opaque windows have various issues, including text rendering. It's not the font that changes, it's the rendering - it changes from subpixel antialias to grayscale antialias which makes it look different and in most cases - worse. Check #130 for more information. Unfortunately this is a Java/Swing issue with subpixel text rendering on non-opaque destination and I don't have any way to workaround it yet. |
learn it. can i custom WebPopup with round conner by xml? the following code can't . <style type="popup" id="element-choose" extends="undecorated">
<painter>
<decorations>
<decoration>
<WebShape round="10" />
</decoration>
</decorations>
</painter>
</style> |
You can, but you will need to extend a style that has decoration to begin with. <style type="popup" id="custom">
<painter>
<decorations>
<decoration>
<WebShape round="10" />
</decoration>
</decorations>
</painter>
</style> Just in case, no extend is the same as extending default component's style. You're extending <style type="popup" id="custom" extends="undecorated">
<component>
<opaque>false</opaque>
</component>
<painter>
<decorations>
<decoration>
<WebShape round="10" />
<WebShadow type="outer" width="2" />
<LineBorder color="20,20,20" />
<ColorBackground color="68,68,68" />
</decoration>
</decorations>
</painter>
</style> Result should should look like this: If you don't make in non-opaque - you will have the default window/root pane background visible: Note that when you make popup non-opaque - window also becomes non-opaque, causing the same issues as non-opaque windows have. I've mentioned them in my reply before and they're fully described in #130. |
Easy solution is to use a common modal But if your goal is to block content of a In the meantime you can implement it yourself in your project for any
That is pretty much it, you can make some utility classes to simplify the whole operation. For instance your custom popup component may have a method that will take in a Alternatively - you can use layered pane to place your popup instead of using popup as the glass pane. That might be a bit trickier, but generally I would recommend it over replacing glass pane. If you aren't sure how you can use/access glass pane/layered pane on the window I recommend reading this Swing guide: Also just a side note - I recommend creating new issues for questions/bugs/suggestions unrelated to the current issue topic. It will be easier for me to both track and answer such issues. |
and how to create round conner with WebWindow? which xml is it? |
You can use Similar one can be used to style There is also a separate wiki article on window decoration you can check: |
Reported by @kovadam69 on gitter:
The text was updated successfully, but these errors were encountered: