Skip to content

Commit

Permalink
Cleaned up the CustomPopup class. Removed two unnecessary accessors.
Browse files Browse the repository at this point in the history
  • Loading branch information
BlakeTNC committed Nov 29, 2016
1 parent 7deba2f commit 2b95814
Showing 1 changed file with 9 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ public class CustomPopup extends Popup
private Window topWindow;

/**
* enableHideAction, This is part of the bug fix for blank popup windows in linux.
* enableHideWhenFocusIsLost, This is used to prevent a previous intermittent bug where blank
* popup windows could occur in linux. This is set to true during the "WindowOpen" event. This
* is never set to false after initialization. This is checked whenever the window loses focus.
* The window can only be hidden when the focus is lost, if this has been set to true.
*/
private boolean enableHideAction = false;
private boolean enableHideWhenFocusIsLost = false;

/**
* Constructor, This creates and initializes instances of this class.
Expand Down Expand Up @@ -112,11 +115,11 @@ public CustomPopup(Component contentsComponent, Window topWindow,
}
// Create the display window.
displayWindow = new JWindow(topWindow);
// This is part of the bug fix for blank popup windows in linux.
// This is part of the bug fix for blank popup windows in linux.
displayWindow.addWindowListener(new WindowAdapter() {
@Override
public void windowOpened(WindowEvent e) {
setEnableHideAction(true);
enableHideWhenFocusIsLost = true;
}
});

Expand Down Expand Up @@ -249,28 +252,14 @@ public void windowGainedFocus(WindowEvent e) {
*/
@Override
public void windowLostFocus(WindowEvent e) {
// This section is part of the bug fix for blank popup windows in linux.
if (isEnableHideAction()) {
// This section is part of the bug fix for blank popup windows in linux.
if (enableHideWhenFocusIsLost) {
hide();
} else {
e.getWindow().requestFocus();
}
}

/**
* setEnableHideAction, This is part of the bug fix for blank popup windows in linux.
*/
public void setEnableHideAction(boolean isEnabled) {
enableHideAction = isEnabled;
}

/**
* isEnableHideAction, This is part of the bug fix for blank popup windows in linux.
*/
public boolean isEnableHideAction() {
return enableHideAction;
}

public void setMinimumSize(Dimension minimumSize) {
displayWindow.setMinimumSize(minimumSize);
}
Expand Down

0 comments on commit 2b95814

Please sign in to comment.