All Downloads are FREE. Search and download functionalities are using the official Maven repository.

test.DefaultButtonTest Maven / Gradle / Ivy

Go to download

A Mavenisation of the Quaqua Mac OSX Swing Look and Feel (Java library) Quaqua Look and Feel (C) 2003-2017, Werner Randelshofer. Mavenisation by Matt Gumbley, DevZendo.org - for problems with Mavenisation, see Matt; for issues with Quaqua, see the Quaqua home page. For full license details, see http://randelshofer.ch/quaqua/license.html

The newest version!
/*
 * @(#)OkayButtonTest.java  1.0  2013-06-04
 * 
 * Copyright (c) 2013 Werner Randelshofer, Switzerland.
 * All rights reserved.
 * 
 * You may not use, copy or modify this file, except in compliance with the 
 * license agreement you entered into with Werner Randelshofer. 
 * For details see accompanying license terms.
 */

package test;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.SwingUtilities;

/**
 * OkayButtonTest.
 *
 * @author Werner Randelshofer
 * @version 1.0 2013-06-04 Created.
 */
public class DefaultButtonTest extends javax.swing.JPanel {

    /** Creates new form OkayButtonTest */
    public DefaultButtonTest() {
        initComponents();
        okayButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                new Throwable().printStackTrace();
            }
        });
    }
    
    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // //GEN-BEGIN:initComponents
    private void initComponents() {

        okayButton = new javax.swing.JButton();

        FormListener formListener = new FormListener();

        addAncestorListener(formListener);
        setLayout(new java.awt.GridBagLayout());

        okayButton.setMnemonic('O');
        okayButton.setText("Okay");
        add(okayButton, new java.awt.GridBagConstraints());
    }

    // Code for dispatching events from components to event handlers.

    private class FormListener implements javax.swing.event.AncestorListener {
        FormListener() {}
        public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
            if (evt.getSource() == DefaultButtonTest.this) {
                DefaultButtonTest.this.formAncestorAdded(evt);
            }
        }

        public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
        }

        public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
        }
    }// //GEN-END:initComponents

    private void formAncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_formAncestorAdded
        SwingUtilities.getRootPane(this).setDefaultButton(okayButton);
    }//GEN-LAST:event_formAncestorAdded


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton okayButton;
    // End of variables declaration//GEN-END:variables

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy