Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ public static Theme createTheme(Properties p) {
}

Theme base = getTheme(PlafManager.getSystemThemeName());
if(base==null) {
// look and feel without a <plaf> mapping
base = getTheme(DEFAULT);
}

ViewUI view = getViewUI(p);
if(view==null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
import javax.swing.plaf.metal.MetalLookAndFeel;
import java.util.Properties;

import static org.junit.jupiter.api.Assertions.*;
Expand Down Expand Up @@ -68,17 +68,13 @@ void testRemovedCustomThemeIsReturnedOnce() {
assertNull(PlafManager.removeCustomTheme(THEME_NAME));
}

// Known bug (https://github.com/opencollab/flexdock/issues/35):
// under a look and feel without a <plaf> mapping (e.g. Aqua on macOS, Nimbus)
// there is no base theme, so a custom theme with missing UIs throws an NPE in
// UIFactory.createTheme. Once fixed, assertThrows fails: check that the theme is created.
@Test
void testCustomThemeUnderUnmappedLookAndFeelKnownBug() throws Exception {
void testCustomThemeUnderUnmappedLookAndFeel() throws Exception {
LookAndFeel original = UIManager.getLookAndFeel();
UIManager.setLookAndFeel(new NimbusLookAndFeel());
// The anonymous subclass has a class name that no <plaf> mapping knows
UIManager.setLookAndFeel(new MetalLookAndFeel() { });
try {
assertThrows(NullPointerException.class,
() -> PlafManager.addCustomTheme(THEME_NAME, new Properties()));
assertNotNull(PlafManager.addCustomTheme(THEME_NAME, new Properties()));
} finally {
UIManager.setLookAndFeel(original);
PlafManager.removeCustomTheme(THEME_NAME);
Expand Down
1 change: 1 addition & 0 deletions release-notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Fixes:
* DockingSplitPane: track the divider percentage from the first drag
* DockingSplitPane: apply the percentage consistently in setDividerLocation()
* DockingSplitPane: keep the percentage set before the size is known
* UIFactory: create a custom theme under a look and feel without a theme mapping

== flexdock 1.3 RELEASE NOTES ==

Expand Down
Loading