Skip to content

Commit

Permalink
Panel: rounded background of panel with rounded corners is now painte…
Browse files Browse the repository at this point in the history
…d even if panel is not opaque (issue #840)
  • Loading branch information
DevCharly committed May 20, 2024
1 parent 3f3ef6b commit bbbdd7e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
10 changes: 6 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FlatLaf Change Log
indeterminate progress bar UI or using JProgressBar.setIndeterminate(false)
not on AWT thread, because this may throw NPE in FlatProgressBarUI.paint().
(issues #841 and #830)
- Panel: Rounded background of panel with rounded corners is now painted even if
panel is not opaque. (issue #840)


## 3.4.1
Expand All @@ -20,7 +22,7 @@ FlatLaf Change Log
- TabbedPane: Fixed swapped back and forward scroll buttons when using
`TabbedPane.scrollButtonsPlacement = trailing` (regression in FlatLaf 3.3).
- Fixed missing window top border on Windows 10 in "full window content" mode.
(issue 809)
(issue #809)
- Extras:
- `FlatSVGIcon` color filters now support linear gradients. (PR #817)
- `FlatSVGIcon`: Use log level `CONFIG` instead of `SEVERE` and allow
Expand Down Expand Up @@ -65,7 +67,7 @@ FlatLaf Change Log
- Fonts: Updated **Inter** to
[v4.0](https://github.com/rsms/inter/releases/tag/v4.0).
- Table: Select all text in cell editor when starting editing using `F2` key.
(issue 652)
(issue #652)

#### Fixed bugs

Expand Down Expand Up @@ -93,7 +95,7 @@ FlatLaf Change Log
#### Fixed bugs

- Button and ToggleButton: Selected buttons did not use explicitly set
foreground color. (issue 756)
foreground color. (issue #756)
- FileChooser: Catch NPE in Java 21 when getting icon for `.exe` files that use
default Windows exe icon. (see
[JDK-8320692](https://bugs.openjdk.org/browse/JDK-8320692))
Expand Down Expand Up @@ -846,7 +848,7 @@ FlatLaf Change Log
- Native window decorations (Windows 10 only):
- Fixed occasional application crash in `flatlaf-windows.dll`. (issue #357)
- When window is initially shown, fill background with window background color
(instead of white), which avoids flickering in dark themes. (issue 339)
(instead of white), which avoids flickering in dark themes. (issue #339)
- When resizing a window at the right/bottom edge, then first fill the new
space with the window background color (instead of black) before the layout
is updated.
Expand Down
37 changes: 19 additions & 18 deletions flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPanelUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,29 +160,30 @@ public Object getStyleableValue( JComponent c, String key ) {

@Override
public void update( Graphics g, JComponent c ) {
int arc = (this.arc >= 0)
? this.arc
: ((c.getBorder() instanceof FlatLineBorder)
? ((FlatLineBorder)c.getBorder()).getArc()
: 0);

// fill background
if( c.isOpaque() ) {
int width = c.getWidth();
int height = c.getHeight();
int arc = (this.arc >= 0)
? this.arc
: ((c.getBorder() instanceof FlatLineBorder)
? ((FlatLineBorder)c.getBorder()).getArc()
: 0);

// fill background with parent color to avoid garbage in rounded corners
if( arc > 0 )
if( arc > 0 ) {
// fill background with parent color to avoid garbage in rounded corners
FlatUIUtils.paintParentBackground( g, c );
} else {
g.setColor( c.getBackground() );
g.fillRect( 0, 0, c.getWidth(), c.getHeight() );
}
}

// fill rounded rectangle if having rounded corners
if( arc > 0 ) {
g.setColor( c.getBackground() );
if( arc > 0 ) {
// fill rounded rectangle if having rounded corners
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
FlatUIUtils.paintComponentBackground( (Graphics2D) g, 0, 0, width, height,
0, UIScale.scale( arc ) );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
} else
g.fillRect( 0, 0, width, height );
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
FlatUIUtils.paintComponentBackground( (Graphics2D) g, 0, 0, c.getWidth(), c.getHeight(),
0, UIScale.scale( arc ) );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
}

paint( g, c );
Expand Down

0 comments on commit bbbdd7e

Please sign in to comment.