Skip to content

Commit

Permalink
Merge pull request vincenzopalazzo#199 from juanmuscaria/master
Browse files Browse the repository at this point in the history
Make swingx/MaterialTaskPaneUI optional
  • Loading branch information
vincenzopalazzo authored Feb 5, 2024
2 parents d057043 + 1996797 commit ffa02de
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ dependencies {

```

### Excluding Swingx

While swingx is a transitive dependency for Material-UI-Swing, it is not strictly required for it to work.
Projects that wish to exclude it can use dependency exclusion on [Maven](https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html)
or [Gradle](https://docs.gradle.org/current/userguide/dependency_downgrade_and_exclude.html#sec:excluding-transitive-deps).

## Code Style
> We live in a world where robots can drive a car, so we shouldn't just write code, we should write elegant code.
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/mdlaf/MaterialLookAndFeel.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public class MaterialLookAndFeel extends MetalLookAndFeel {
private static final String separatorUI = MaterialSeparatorUI.class.getCanonicalName();
private static final String fileChooserUI = MaterialFileChooserUI.class.getCanonicalName();
private static final String toolTipUI = MaterialToolTipUI.class.getCanonicalName();
private static final String taskPaneUI = MaterialTaskPaneUI.class.getCanonicalName();
private static final String taskPaneUI;
private static final String formattedTextFieldUI =
MaterialFormattedTextFieldUI.class.getCanonicalName();
private static final String listUI = MaterialListUI.class.getCanonicalName();
Expand All @@ -125,6 +125,16 @@ public class MaterialLookAndFeel extends MetalLookAndFeel {
private static final String colorChooserUI = MaterialColorChooser.class.getCanonicalName();
private static final String splitPaneUI = MaterialSplitPaneUI.class.getCanonicalName();

static {
String taskPaneUIName = null;
try {
taskPaneUIName = MaterialTaskPaneUI.class.getCanonicalName();
} catch (NoClassDefFoundError ignored) {
// Swingx is not in the classpath
}
taskPaneUI = taskPaneUIName;
}

public static void changeTheme(MaterialTheme theme) {
if (theme == null) {
return;
Expand Down Expand Up @@ -235,7 +245,9 @@ protected void initClassDefaults(UIDefaults table) {
table.put("SplitPaneUI", splitPaneUI);
table.put("ColorChooserUI", colorChooserUI);
// java swingx
table.put("swingx/TaskPaneUI", taskPaneUI);
if (taskPaneUI != null) {
table.put("swingx/TaskPaneUI", taskPaneUI);
}
}

@Override
Expand Down

0 comments on commit ffa02de

Please sign in to comment.