Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make swingx/MaterialTaskPaneUI optional #199

Merged
merged 2 commits into from
Feb 5, 2024
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
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();
vincenzopalazzo marked this conversation as resolved.
Show resolved Hide resolved
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
Loading