Closed Blanco27 closed 3 years ago
Hmm, can't reproduce here...
I think the problem comes from the wrapped message, because the dialog width is correct, but not the height.
Is this HTML text in the message? Or a custom control?
Nah, simple text message with a default option pane. Might it be relevant that we are using remotedesktop? The zoom on the host and client might differ, is flatlaf able to retrieve the correct value in this situation?
Nah, simple text message...
Are you sure?
There is a bold '6'
in the text 😉
Don't think that FlatLaf is involved in computing dialog size. This is standard Swing layout calculation.
I am sorry, you are right for this specific dialog. I thought of a different dialog when I said no.
I noticed there's more dialogs that have this problem. Some of which don't use any HTML. Meaning there's also no <html>
at the start or end of the string.
However, we are creating them in a "non standard" way:
final JOptionPane pane = new JOptionPane( message, messageType, optionType, icon, options, initialValue )
{
@Override
public int getMaxCharactersPerLineCount()
{
return narrowness;
}
};
final JDialog dialog = pane.createDialog( parentComponent, title );
Might that be related?
@MioBlanco can you see whether there are any dialogs that work?
Don't think that this makes a difference.
BTW FlatLaf supports maxCharactersPerLine
option out-of-the-box.
The default value is 80 characters.
You can assign a different value with:
UIManager.put( "OptionPane.maxCharactersPerLine", 60 );
If JOptionPane.getMaxCharactersPerLineCount()
returns a value greater than zero, then this value is used.
So if you don't use other Lafs, you can try to create option panes in a "standard way" and check whether this makes a difference.
Can you please try the FlatLaf Demo (with the same JRE as your app) and check whether the option panes on the "Option Pane" tab have correct sizes? Also try to click on "Show dialog" links to check whether option dialogs have correct sizes?
Okay, so we are able to constantly reproduce this with our application. However we can't seem to reproduce it with the flatlaf demo application.
Steps to reproduce:
Switching between themes while the applicaton is still running doesn't seem to "fix" the incorrect sizing.
Also reproducible using this demo:
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.WindowConstants;
import com.formdev.flatlaf.FlatLightLaf;
public class OptionPaneTest
{
public static void main( final String[] args )
{
FlatLightLaf.install();
final JFrame frame = new JFrame();
final JButton button = new JButton( "Click me" );
button.addActionListener( __ ->
{
showDialog( frame );
} );
frame.add( button );
frame.setSize( 400, 300 );
frame.setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE );
frame.setLocationRelativeTo( null );
frame.setVisible( true );
}
private static void showDialog( final JFrame frame )
{
final String[] options = { "Ja", "Nein" };
final String initialValue = options[ 1 ];
final JOptionPane pane =
new JOptionPane( "Wollen Sie sich wirklich abmelden?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options,
initialValue )
{
@Override
public int getMaxCharactersPerLineCount()
{
return Integer.MAX_VALUE;
}
};
final JDialog dialog = pane.createDialog( frame, "Abmelden" );
dialog.setVisible( true );
}
}
@MioBlanco thanks for the detailed steps and the code.
Unfortunately the problem does not show up on my machines. Used Windows 10 Remote Desktop to connect two PCs.
And the issue happens only if you start the app on the first machine and then connect from the second one? When you start the app while already connected, it works?
Could you post a screenshot made with your code snippet?
Does it work for other Lafs? Windows Laf or Metal?
And the issue happens only if you start the app on the first machine and then connect from the second one? When you start the app while already connected, it works?
Yes thats the only way I managed to reproduce it.
I tested it on Windows and Metal Laf and here are my results:
As you can see it looks kinda weird on all lafs, so it might a java bug.
Thx.
What is the exact Java version that you use? You're using ojdkbuild, right?
And this problem occurs only for option panes? Not for "normal" dialogs?
I used ojkdbuild 11.0.10.9-1.
It only appeared on optionspanes, but I tested ojkdbuild 14.0.2.12-1 by now and I couldn't reproduce it there, so I assume they fixed it already.
Can now reproduce it, but with a different scenario:
OptionPaneTest
on primarySeems that the difference between the two scaling factors affect the option pane size, because when I change primary to 150%, then option pane is also too small, but not much:
Seems that the problem does not occur in OpenJDK 12 - 14, but is back in 15 😒
I tried it myself and yes, the bug is back in 15 indeed. And your way to reproduce it saves quite a lot of time 😄
Seems that some change made in Java 15, which causes the problem, was then back-ported to Java 11.0.8. OpenJDK 11.0.2, 10.0.2 work fine. AdoptOpenJDK 11.0.7 is also ok, but 11.0.8 has the problem...
Gotta love big scale software development ^^
Have re-tested the issue and it turns out that it is fixed since FlatLaf 1.1, which introduced native window decorations on Windows.
When disabling native window decorations (TitlePane.useWindowDecorations = false
),
it is still there. Even in OpenJDK 17.0.1.
Closing because it is a issue in OpenJDK...
We are on a Windows 10 with 200% system zoom. We are running openJDK 11 and flatlaf 1.0rc1 (afaik this hasn't aleady been fied with rc2/rc3). The monitor is 4k.