Skip to content

Commit

Permalink
fixed broken rendering after resizing window to minimum size and then…
Browse files Browse the repository at this point in the history
… increasing size again (issue #767)
  • Loading branch information
DevCharly committed Nov 25, 2023
1 parent ec76737 commit 5388353
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ FlatLaf Change Log
and #750)
- OptionPane: Fixed styling custom panel background in `JOptionPane`. (issue
#761)
- Fixed broken rendering after resizing window to minimum size and then
increasing size again. (issue #767)


## 3.2.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ public void layoutContainer( Container parent ) {
@Override
public void invalidateLayout( Container parent ) {
if( titlePane != null )
titlePane.menuBarChanged();
titlePane.menuBarInvalidate();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ public class FlatTabbedPaneUI
private boolean blockRollover;
private boolean rolloverTabClose;
private boolean pressedTabClose;
private boolean inBasicLayoutContainer;

private Object[] oldRenderingHints;
private Map<String, Object> oldStyleValues;
Expand Down Expand Up @@ -2044,14 +2045,28 @@ private TabCloseButton() {

//---- class ContainerUIResource ------------------------------------------

private static class ContainerUIResource
private class ContainerUIResource
extends JPanel
implements UIResource
{
private ContainerUIResource( Component c ) {
super( new BorderLayout() );
add( c );
}

@SuppressWarnings( "deprecation" )
@Override
public void reshape( int x, int y, int w, int h ) {
// Avoid that leading/trailing tab area components are temporary moved/resized
// to content area bounds (done in BasicTabbedPaneUI.TabbedPaneLayout.layoutContainer()
// and in BasicTabbedPaneUI.TabbedPaneScrollLayout.layoutContainer())
// and subsequently moved/resized to its final bounds within the tab area.
// This avoids an unnecessary repaint (and maybe re-layout) of the content area.
if( inBasicLayoutContainer )
return;

super.reshape( x, y, w, h );
}
}

//---- class FlatTabAreaButton --------------------------------------------
Expand Down Expand Up @@ -3009,7 +3024,12 @@ protected Dimension calculateTabAreaSize() {

@Override
public void layoutContainer( Container parent ) {
super.layoutContainer( parent );
inBasicLayoutContainer = true;
try {
super.layoutContainer( parent );
} finally {
inBasicLayoutContainer = false;
}

Rectangle bounds = tabPane.getBounds();
Insets insets = tabPane.getInsets();
Expand Down Expand Up @@ -3214,7 +3234,12 @@ public void layoutContainer( Container parent ) {
// runWithOriginalLayoutManager() is necessary for correct locations
// of tab components layed out in TabbedPaneLayout.layoutTabComponents()
runWithOriginalLayoutManager( () -> {
delegate.layoutContainer( parent );
inBasicLayoutContainer = true;
try {
delegate.layoutContainer( parent );
} finally {
inBasicLayoutContainer = false;
}
} );

int tabsPopupPolicy = getTabsPopupPolicy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,10 @@ protected void menuBarLayouted() {
doLayout();
}

void menuBarInvalidate() {
menuBarPlaceholder.invalidate();
}

@Override
public void paint( Graphics g ) {
super.paint( g );
Expand Down

0 comments on commit 5388353

Please sign in to comment.