Skip to content

Commit

Permalink
0.10.0 snapshot uncaught exception in removeNotify in JFormDesigner (#…
Browse files Browse the repository at this point in the history
…127)

* Fixes issue #126

Adding null checks to fix exceptions when using JFormDesigner.
  • Loading branch information
andrewauclair authored Nov 17, 2023
1 parent 0c31c3e commit d2f6f22
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions docking-api/src/ModernDocking/api/RootDockingPanelAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ of this software and associated documentation files (the "Software"), to deal
* Panel that should be added to each frame that should support docking
*/
public class RootDockingPanelAPI extends DockingPanel {
private DockingAPI docking;
private DockingAPI docking = null;

private Window window;
private Window window = null;

private DockingPanel panel;
private DockingPanel panel = null;

private JPanel emptyPanel = new JPanel();

Expand All @@ -51,17 +51,17 @@ public class RootDockingPanelAPI extends DockingPanel {
/**
* South toolbar of this panel. Only created if pinning is supported.
*/
private DockableToolbar southToolbar;
private DockableToolbar southToolbar = null;
/**
* West toolbar of this panel. Only created if pinning is supported.
*/
private DockableToolbar westToolbar;
private DockableToolbar westToolbar = null;
/**
* East toolbar of this panel. Only created if pinning is supported.
*/
private DockableToolbar eastToolbar;
private DockableToolbar eastToolbar = null;

private EnumSet<ToolbarLocation> supportedToolbars;
private EnumSet<ToolbarLocation> supportedToolbars = EnumSet.noneOf(ToolbarLocation.class);

/**
* Create root panel with GridBagLayout as the layout
Expand Down Expand Up @@ -238,8 +238,12 @@ private boolean removeExistingPanel() {

@Override
public void removeNotify() {
Window rootWindow = (Window) SwingUtilities.getRoot(this);
docking.deregisterDockingPanel(rootWindow);
// this class has a default constructor which could be called and docking would be null
if (docking != null) {
Window rootWindow = (Window) SwingUtilities.getRoot(this);

docking.deregisterDockingPanel(rootWindow);
}

super.removeNotify();
}
Expand Down Expand Up @@ -428,9 +432,15 @@ private void createContents() {
* Hide all unpinned panels on the west, south and east toolbars
*/
public void hideUnpinnedPanels() {
westToolbar.hideAll();
southToolbar.hideAll();
eastToolbar.hideAll();
if (westToolbar != null) {
westToolbar.hideAll();
}
if (southToolbar != null) {
southToolbar.hideAll();
}
if (eastToolbar != null) {
eastToolbar.hideAll();
}
}

/**
Expand Down

0 comments on commit d2f6f22

Please sign in to comment.