Search in sources :

Example 51 with WindowEvent

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));
}
Also used : WindowEvent(java.awt.event.WindowEvent)

Example 52 with WindowEvent

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));
    }
}
Also used : WindowEvent(java.awt.event.WindowEvent)

Example 53 with WindowEvent

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);
    }
}
Also used : Window(java.awt.Window) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) Preferences(java.util.prefs.Preferences) JDialog(javax.swing.JDialog)

Example 54 with WindowEvent

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();
    }
}
Also used : WindowEvent(java.awt.event.WindowEvent)

Example 55 with WindowEvent

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));
}
Also used : WindowEvent(java.awt.event.WindowEvent)

Aggregations

WindowEvent (java.awt.event.WindowEvent)201 WindowAdapter (java.awt.event.WindowAdapter)140 JPanel (javax.swing.JPanel)44 JButton (javax.swing.JButton)40 JFrame (javax.swing.JFrame)40 BorderLayout (java.awt.BorderLayout)36 ActionEvent (java.awt.event.ActionEvent)34 Dimension (java.awt.Dimension)32 JLabel (javax.swing.JLabel)30 JScrollPane (javax.swing.JScrollPane)26 ActionListener (java.awt.event.ActionListener)25 GridBagConstraints (java.awt.GridBagConstraints)19 GridBagLayout (java.awt.GridBagLayout)19 FlowLayout (java.awt.FlowLayout)18 Frame (java.awt.Frame)15 Insets (java.awt.Insets)15 JDialog (javax.swing.JDialog)13 JTextArea (javax.swing.JTextArea)13 Container (java.awt.Container)12 WindowListener (java.awt.event.WindowListener)10