use of java.awt.event.WindowEvent in project jgnash by ccavanaugh.
the class AccountListDialog method okAction.
private void okAction() {
account = list.getSelectedAccount();
returnStatus = true;
dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
}
use of java.awt.event.WindowEvent in project jgnash by ccavanaugh.
the class YesNoDialog method actionPerformed.
/**
* Invoked when an action occurs.
*/
@Override
public void actionPerformed(final ActionEvent e) {
if (e.getSource() == noButton) {
result = false;
dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
} else if (e.getSource() == yesButton) {
result = true;
dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
}
}
use of java.awt.event.WindowEvent in project jgnash by ccavanaugh.
the class DialogUtils method addBoundsListener.
/**
* Listens to a JDialog to save and restore windows bounds automatically.
* <p>
* {@code setVisible(false)} and {@code dispose()} must not be used
* to close the window. Instead, dispatch a window closing event.
* <PRE>
* dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
* </PRE>
* and the dialog must be set to dispose on close
* <PRE>
* setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
* </PRE>
*
* @param w {@code Window} to listen to
* @param prefNode String identifier to preference node to save and restore from
* @param key the key to save and restore from
*/
private static void addBoundsListener(final Window w, final String prefNode, final String key) {
String bounds = Preferences.userRoot().node(prefNode).get(key, null);
if (bounds != null) {
if (w instanceof JDialog) {
if (((JDialog) w).isResizable()) {
w.setBounds(decodeRectangle(bounds));
} else {
w.setLocation(decodeRectangle(bounds).getLocation());
}
} else {
w.setBounds(decodeRectangle(bounds));
}
Window owner = w.getOwner();
if (owner != null) {
w.setLocationRelativeTo(owner);
}
}
/* listen for a window closing event and deal with it */
w.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
// save position and size
Preferences p = Preferences.userRoot().node(prefNode);
p.put(key, encodeRectangle(w.getBounds()));
// make GC easy
w.removeWindowListener(this);
}
});
if (w instanceof JDialog) {
addEscapeListener((JDialog) w);
}
}
use of java.awt.event.WindowEvent in project jgnash by ccavanaugh.
the class BudgetGoalDialog method actionPerformed.
@Override
public void actionPerformed(final ActionEvent e) {
if (e.getSource() == cancelButton) {
result = false;
dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
} else if (e.getSource() == okButton) {
result = true;
dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
} else if (e.getSource() == budgetPeriodCombo) {
updatePeriod();
} else if (e.getSource() == historicalButton) {
performHistoricalImport();
} else if (e.getSource() == fillButton) {
performFillAction();
} else if (e.getSource() == fillPatternEnterButton) {
performFillPatternAction();
}
}
use of java.awt.event.WindowEvent in project jgnash by ccavanaugh.
the class ReconcileSettingsDialog method actionPerformed.
/**
* Invoked when an action occurs
*/
@Override
public void actionPerformed(final ActionEvent e) {
returnValue = e.getSource() == okButton;
if (returnValue) {
// save the value in a background thread as this could take a little bit
new Thread(() -> {
ReconcileManager.setAccountDateAttribute(account, Account.RECONCILE_LAST_ATTEMPT_DATE, LocalDate.now());
ReconcileManager.setAccountDateAttribute(account, Account.RECONCILE_LAST_STATEMENT_DATE, getStatementDate());
ReconcileManager.setAccountBigDecimalAttribute(account, Account.RECONCILE_LAST_OPENING_BALANCE, getOpeningBalance());
ReconcileManager.setAccountBigDecimalAttribute(account, Account.RECONCILE_LAST_CLOSING_BALANCE, getClosingBalance());
}).start();
}
dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
}
Aggregations