Skip to content

Commit

Permalink
fixed updating (embedded) menu bar layout when window is narrow and c…
Browse files Browse the repository at this point in the history
…hanging `TitlePane.menuBarEmbedded`
  • Loading branch information
DevCharly committed Dec 7, 2021
1 parent 47a1122 commit f61a728
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.LookAndFeel;
import javax.swing.PopupFactory;
import javax.swing.RootPaneContainer;
Expand Down Expand Up @@ -878,12 +879,23 @@ public static void setUseNativeWindowDecorations( boolean enabled ) {

/**
* Revalidate and repaint all displayable frames and dialogs.
* <p>
* Useful to update UI after changing {@code TitlePane.menuBarEmbedded}.
*
* @since 1.1.2
*/
public static void revalidateAndRepaintAllFramesAndDialogs() {
for( Window w : Window.getWindows() ) {
if( isDisplayableFrameOrDialog( w ) ) {
// revalidate menu bar
JMenuBar menuBar = (w instanceof JFrame)
? ((JFrame)w).getJMenuBar()
: (w instanceof JDialog
? ((JDialog)w).getJMenuBar()
: null);
if( menuBar != null )
menuBar.revalidate();

w.revalidate();
w.repaint();
}
Expand All @@ -892,6 +904,9 @@ public static void revalidateAndRepaintAllFramesAndDialogs() {

/**
* Repaint all displayable frames and dialogs.
* <p>
* Useful to update UI after changing {@code TitlePane.unifiedBackground},
* {@code MenuItem.selectionType} or {@code Component.hideMnemonics}.
*
* @since 1.1.2
*/
Expand Down

0 comments on commit f61a728

Please sign in to comment.