-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
[FlatLaf 3.5.1] Repaint issue on Windows 11 #887
Comments
I'm seeing the same problem with a JComboBox in the FlatLaf demo app. flatlaf_demo_jcombobox.mp4However, I am unable to replicate the issue with JComboBoxes within a JTable when using the demo app. @nevemlaci Are you able to reproduce the same issue using the demo app for the JComboBoxes within a JTable? |
I'd love to but the demo app is impossible to navigate for me due to the repaint issues, 2 clicks and the whole thing just breaks down. I'm not sure where to look for a JTable + JComboBox in the demo app either, I've never used it. |
Some of the users of our software which uses FlatLAF 3.5.1 are also reporting this issue |
Had the same issue on windows after some update
fixed this for me. |
The JTable is located under the Data components tab in the demo app. |
I'm no longer seeing the issue with the demo app or the minimal reproduction project. It also addressed my problem of the menu not being integrated into the title bar using my initial solution. Thank you @norbert-gaulia! Note, turning off DirectDraw disables hardware acceleration, which will reduce performance, especially in graphics-intensive applications. While this isn’t a problem for me at the moment, I suspect this may not be a solution for everyone. |
I'll take a look today. |
@IAmBaguette thanks for the detailed report and the screencasts. Very useful 👍 Unfortunately I can not reproduce the issue on my systems... What happens if you use the flag Since you wrote that it first occurs with FlatLaf 3.1, I assume that it has something to do with the (native) rounded popup borders, which are the only change in native code in this version. Does it work if you disable rounded popup borders with: UIManager.put( "PopupMenu.borderCornerRadius", 0 );
UIManager.put( "ComboBox.borderCornerRadius", 0 );
UIManager.put( "ToolTip.borderCornerRadius", 0 );
UIManager.put( "Popup.borderCornerRadius", 0 ); |
@DevCharly Disabling the FlatLaf window decorations while DirectDraw is enabled results to the same issue with the Minimal reproduction project (MRP). -Dflatlaf.useWindowDecorations=false -Dsun.java2d.noddraw=false Disabling the rounded popup borders using the I also attempted to turn off hardware acceleration from my Windows display graphics settings to see if it would make a difference, but the option does not seem to be available with my AMD graphics card. If there's anything else you'd like me to try, let me know. |
I think that following lines, which are invoked before setting rounded popup border, could cause the problem: FlatLaf/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java Lines 367 to 369 in 09f2d65
|
Could you please try latest |
It could be a general Swing issue with "heavy-weight" popup windows, which are used if the popup does not fit into the owner window. If the popup fits into the owner window, FlatLaf 3.0 (and most other L&Fs) use "light-weight" popups (simple Swing component). But FlatLaf 3.1 always uses "heavy-weight" popups on Windows 11 to show Windows rounded borders and drop shadows. Here is an issue that reports same redraw issue for Windows L&F: kaikramer/keystore-explorer#497 Here is a test case that uses Windows L&F and large menus. import javax.swing.*;
public class HeavyWeightPopupsTest {
public static void main( String[] args ) {
try {
UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
} catch( Exception ex ) {
ex.printStackTrace();
}
JFrame frame = new JFrame( "HeavyWeightPopupsTest" );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
JMenu fileMenu = new JMenu( "File" );
JMenu editMenu = new JMenu( "Edit" );
for( int i = 1; i <= 20; i++ )
fileMenu.add( "Item " + 1 );
for( int i = 1; i <= 20; i++ )
editMenu.add( "Item " + 1 );
JMenuBar menuBar = new JMenuBar();
menuBar.add( fileMenu );
menuBar.add( editMenu );
frame.setJMenuBar( menuBar );
JTable table = new JTable( 100, 5 );
frame.getContentPane().add( new JScrollPane( table ) );
frame.setSize( 400, 300 );
frame.setLocationRelativeTo( null );
frame.setVisible( true );
}
} |
There doesn't appear to be any redraw issue on Windows 11. heavy-weight_popups.mp4There are no redraw issue with FlatLaf either. Tested with versions heavy-weight_popups_flatlaf.mp4However, the issue reappears with FlatLaf when the heavy-weight_popups_flatlaf_redraw.mp4I was able to reproduce the redraw issue using the system LAF with two If you need more details about when the redraw issue appears with specific layouts, I will need to conduct a more thorough investigation to compile a comprehensive list. Let me know what you would like me to do. |
@IAmBaguette thanks for testing and confirming that this is can also happen in other L&Fs. So it is actually not a FlatLaf bug. Not sure whether it makes sense to try layouts... Found an undocumented Java system property that disables parts of DirectX. |
I was unable to reproduce the redraw issue with It does appear the issue originates from Java rather than FlatLaf. Both I’m not sure if you plan to continue pursuing this. The question is whether it’s worth the effort now that there are workarounds for this Java-related issue. @DevCharly Thank you for your help, I really appreciate it! |
Great that Compared to BTW IntelliJ IDEA has disabled Direct3D (since 13 years). See Too avoid/fix the redraw issue, I'm going to set |
@IAmBaguette you mentioned in this comment #887 (comment) that the redraw issue appears only if the menu contains 6 or fewer menu items. There is some code in method Could you please try following test case? (without using any import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
public class GhostingTest
{
public static void main( String[] args ) {
JFrame frame = new JFrame( "GhostingTest" );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
UIManager.put( "PopupMenu.border", BorderFactory.createEmptyBorder() );
// force heavy-weight popups
JPopupMenu.setDefaultLightWeightPopupEnabled( false );
JMenuBar menuBar = new JMenuBar();
frame.setJMenuBar( menuBar );
// showing this popups should not start ghosting
menuBar.add( createMenuOfSize( 152 ) );
menuBar.add( createMenuOfSize( 151 ) );
// showing this popup should start ghosting
menuBar.add( createMenuOfSize( 150 ) );
JTable table = new JTable( 100, 5 );
frame.getContentPane().add( new JScrollPane( table ) );
frame.setSize( 400, 300 );
frame.setLocationRelativeTo( null );
frame.setVisible( true );
}
private static JMenu createMenuOfSize( int size ) {
JPanel p = new JPanel();
p.setPreferredSize( new Dimension( size, size ) );
p.setBorder( new LineBorder( Color.red ) );
JMenu menu = new JMenu( size + " x " + size );
menu.add( p );
return menu;
}
} |
@DevCharly I was able to reproduce the redraw issue inconsistently when following your exact instructions. To consistently trigger the redraw issue, I needed to repeat the action of showing and hiding the 150x150 menu exactly twice.
I've provided more screencasts than you asked to provide a more complete view of what's happening. I prefer to give you more information so that you can decide whether it is necessary for your report to Oracle. |
…sun.java2d.d3d.onscreen` to `false` (issue #887)
@DevCharly Would you like me to close issue now that the issue is resolved? |
Issue Description
I'm experiencing a repaint issue with FlatLaf 3.5.1 on Windows 11. My setup includes an AMD graphics card (RX 6700 XT) with three monitors (1920 x 1080, 120Hz). The issue occurs when using a
JFrame
with aJMenuBar
. Notably, the same project does not exhibit the issue on Windows 10 with an Intel integrated graphics card.Details:
flatlaf_demo.mp4
Observations:
flatlaf.uiScale
property to2x
appears to resolve the issue, but any smaller scale does not.-Dflatlaf.useNativeLibrary=false
flag resolves the issue but removes the menu bar and title bar integration, which I would like to keep.JFrame
window to another monitor forces a full repaint.Steps to reproduce
flatlaf_windows11.mp4
Minimal reproduction project (MRP)
flatlaf-windows11.zip
The text was updated successfully, but these errors were encountered: