/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* JFrame.java
*
* Created on Nov 13, 2011, 1:44:14 PM
*/
package date;
import javax.swing.JOptionPane;
/**
*
* @author grandmstramrod
*/
public class JFrame extends javax.swing.JFrame {
public String name;
private boolean day,month,year;
/** Creates new form JFrame */
public JFrame() {
initComponents();
}
/** 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jTextFieldInput = new javax.swing.JTextField();
jButtonEnter = new javax.swing.JButton();
jTextFieldOutput = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(153, 153, 153));
jTextFieldInput.setText("jTextField1");
jButtonEnter.setText("jButton1");
jButtonEnter.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonEnterActionPerformed(evt);
}
});
jTextFieldOutput.setText("jTextField2");
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.add(88, 88, 88)
.add(jTextFieldInput))
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.add(91, 91, 91)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, jTextFieldOutput)
.add(org.jdesktop.layout.GroupLayout.LEADING, jButtonEnter, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE))))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jTextFieldInput, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 47, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(18, 18, 18)
.add(jButtonEnter, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 63, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(11, 11, 11)
.add(jTextFieldOutput, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 54, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(99, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButtonEnterActionPerformed(java.awt.event.ActionEvent evt) {
name=jTextFieldInput.getText();
name = subName (day, month, year);
checkinput();
jTextFieldOutput.setText("the day is" + day );
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new JFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButtonEnter;
private javax.swing.JTextField jTextFieldInput;
private javax.swing.JTextField jTextFieldOutput;
// End of variables declaration
public void checkinput(){
String subName = jTextFieldInput.getText();
if (subName.isEmpty()){
JOptionPane.showMessageDialog(null,subName,"is empty",JOptionPane.ERROR_MESSAGE);
}else{
try {
day = dateFormat.parse (jTextFieldInput.getText());
= Integer.parseInt (jTextFieldOutput.getText());
} catch (NumberFormatException n) {
subName (day);