- Here full source code(full project bottom of the page)
- !Important: no limit given the numbers.
package Lotterys;
import java.awt.Color;
/**
*
* @author Chathura
*/
public class uLotterys extends javax.swing.JFrame {
int num1, num2, num3, num4, num5, num6;
String q1="", q2="", q3="", q4="", q5="", q6="";
public uLotterys() {
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() {
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jTextField4 = new javax.swing.JTextField();
jTextField5 = new javax.swing.JTextField();
jTextField6 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setMaximumSize(new java.awt.Dimension(710, 398));
setMinimumSize(new java.awt.Dimension(710, 398));
setPreferredSize(new java.awt.Dimension(710, 398));
setResizable(false);
addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
public void mouseMoved(java.awt.event.MouseEvent evt) {
formMouseMoved(evt);
}
});
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jTextField1.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N
getContentPane().add(jTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 150, 90, 80));
jTextField2.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N
getContentPane().add(jTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 150, 90, 80));
jTextField3.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N
getContentPane().add(jTextField3, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 150, 90, 80));
jTextField4.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N
getContentPane().add(jTextField4, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 150, 90, 80));
jTextField5.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N
getContentPane().add(jTextField5, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 150, 90, 80));
jTextField6.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N
getContentPane().add(jTextField6, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 150, 90, 80));
jButton1.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
jButton1.setText("Generate Numbers");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) {
jButton1MouseEntered(evt);
}
});
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 250, 440, 70));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 255, 255));
jLabel1.setText("Lotter Numbers Generator");
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 60, 490, 70));
pack();
setLocationRelativeTo(null);
}// </editor-fold>
private void formMouseMoved(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
this.getContentPane().setBackground(Color.black);
}
private void jButton1MouseEntered(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
jTextField1.setText(q1="");
jTextField2.setText(q2="");
jTextField3.setText(q3="");
jTextField4.setText(q4="");
jTextField5.setText(q5="");
jTextField6.setText(q6="");
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
num1 = 1 + (int) (Math.random() *48);
q1 +=num1;
jTextField1.setText(q1);
num2 = 1 + (int) (Math.random() *48);
q2 +=num2;
jTextField2.setText(q2);
num3 = 1 + (int) (Math.random() *48);
q3 +=num3;
jTextField3.setText(q3);
num4 = 1 + (int) (Math.random() *48);
q4 +=num4;
jTextField4.setText(q4);
num5 = 1 + (int) (Math.random() *48);
q5 +=num5;
jTextField5.setText(q5);
num6 = 1 + (int) (Math.random() *48);
q6 +=num6;
jTextField6.setText(q6);
}
/**
* @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(uLotterys.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(uLotterys.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(uLotterys.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(uLotterys.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 uLotterys().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
private javax.swing.JTextField jTextField6;
// End of variables declaration
}
0 Comments