test.DefaultButtonTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Quaqua Show documentation
Show all versions of Quaqua Show documentation
A Mavenisation of the Quaqua Mac OSX Swing Look and Feel (Java library)
Quaqua Look and Feel (C) 2003-2010, 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!
/*
* @(#)DefaultButtonTest.java
*
* Copyright (c) 2005-2010 Werner Randelshofer, Immensee, Switzerland.
* All rights reserved.
*
* The copyright of this software is owned by Werner Randelshofer.
* You may not use, copy or modify this software, except in
* accordance with the license agreement you entered into with
* Werner Randelshofer. For details see accompanying license terms.
*/
package test;
import ch.randelshofer.quaqua.*;
import java.text.*;
import javax.swing.*;
import javax.swing.text.*;
/**
* DefaultButtonTest.
*
* @author Werner Randelshofer
* @version $Id: DefaultButtonTest.java 363 2010-11-21 17:41:04Z wrandelshofer $
*/
public class DefaultButtonTest extends javax.swing.JFrame {
/**
* Creates new form DefaultButtonTest
*/
public DefaultButtonTest() {
initComponents();
getRootPane().setDefaultButton(button);
}
/** 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.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
label = new javax.swing.JLabel();
textField = new javax.swing.JTextField();
textField2 = new javax.swing.JTextField();
button = new javax.swing.JButton();
FormListener formListener = new FormListener();
addWindowListener(formListener);
getContentPane().setLayout(new java.awt.GridBagLayout());
label.setText("Label:");
getContentPane().add(label, new java.awt.GridBagConstraints());
textField.setColumns(10);
textField.addActionListener(formListener);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0);
getContentPane().add(textField, gridBagConstraints);
textField2.setColumns(10);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0);
getContentPane().add(textField2, gridBagConstraints);
button.setText("jButton1");
button.addActionListener(formListener);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
getContentPane().add(button, gridBagConstraints);
pack();
}
// Code for dispatching events from components to event handlers.
private class FormListener implements java.awt.event.ActionListener, java.awt.event.WindowListener {
FormListener() {}
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (evt.getSource() == textField) {
DefaultButtonTest.this.textFieldPerformed(evt);
}
else if (evt.getSource() == button) {
DefaultButtonTest.this.buttonPerformed(evt);
}
}
public void windowActivated(java.awt.event.WindowEvent evt) {
}
public void windowClosed(java.awt.event.WindowEvent evt) {
}
public void windowClosing(java.awt.event.WindowEvent evt) {
if (evt.getSource() == DefaultButtonTest.this) {
DefaultButtonTest.this.exitForm(evt);
}
}
public void windowDeactivated(java.awt.event.WindowEvent evt) {
}
public void windowDeiconified(java.awt.event.WindowEvent evt) {
}
public void windowIconified(java.awt.event.WindowEvent evt) {
}
public void windowOpened(java.awt.event.WindowEvent evt) {
}
}// //GEN-END:initComponents
private void buttonPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPerformed
// TODO add your handling code here:
label.setText("Button "+NumberFormat.getIntegerInstance().format(System.currentTimeMillis()));
}//GEN-LAST:event_buttonPerformed
private void textFieldPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textFieldPerformed
// TODO add your handling code here:
label.setText("TextField "+NumberFormat.getIntegerInstance().format(System.currentTimeMillis()));
}//GEN-LAST:event_textFieldPerformed
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
System.exit(0);
}//GEN-LAST:event_exitForm
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
try {
UIManager.setLookAndFeel(QuaquaManager.getLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
new DefaultButtonTest().setVisible(true);
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton button;
private javax.swing.JLabel label;
private javax.swing.JTextField textField;
private javax.swing.JTextField textField2;
// End of variables declaration//GEN-END:variables
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy