Search Your Question

Thursday, March 12, 2009

Game Apps2

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/*
* MainFrame.java
*
* Created on Mar 6, 2009, 3:14:48 PM
*/

package gameapps;

import java.awt.event.KeyEvent;
import java.util.Random;
import java.util.Vector;
import javax.swing.JTextField;
import java.awt.*;


/**
*
* @author gdwebj6
*/
public class MainFrame extends javax.swing.JFrame {

/** Creates new form MainFrame */
public MainFrame()
{
// super("Game Window");
initComponents();
Dimension dm=Toolkit.getDefaultToolkit().getScreenSize();
setSize(240,280);
int height=dm.height;
int width=dm.width;
this.setLocation((width/2)-(240/2), (height/2)-(280/2));
tp=new TestProg();

}

private void close() {
System.exit(0);
}

/** 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">//GEN-BEGIN:initComponents
private void initComponents() {

jPanel1 = new javax.swing.JPanel();
pan1 = new javax.swing.JPanel();
txt1 = new javax.swing.JTextField();
txt2 = new javax.swing.JTextField();
txt3 = new javax.swing.JTextField();
pan2 = new javax.swing.JPanel();
txt6 = new javax.swing.JTextField();
txt5 = new javax.swing.JTextField();
txt4 = new javax.swing.JTextField();
pan3 = new javax.swing.JPanel();
txt9 = new javax.swing.JTextField();
txt8 = new javax.swing.JTextField();
txt7 = new javax.swing.JTextField();
pan_leb2 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
pan_leb1 = new javax.swing.JPanel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
pan_res1 = new javax.swing.JPanel();
res3 = new javax.swing.JTextField();
res2 = new javax.swing.JTextField();
res1 = new javax.swing.JTextField();
pan_res2 = new javax.swing.JPanel();
res4 = new javax.swing.JTextField();
res5 = new javax.swing.JTextField();
res6 = new javax.swing.JTextField();
jPanel2 = new javax.swing.JPanel();
btn_sol = new javax.swing.JButton();
btn_clr = new javax.swing.JButton();
jLabel7 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
setUndecorated(true);

txt1.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
txt1FocusLost(evt);
}
});
txt1.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
txt1KeyPressed(evt);
}
public void keyTyped(java.awt.event.KeyEvent evt) {
txt1KeyTyped(evt);
}
});

txt2.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
txt2FocusLost(evt);
}
});
txt2.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
txt2KeyTyped(evt);
}
});

txt3.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
txt3FocusLost(evt);
}
});
txt3.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
txt3KeyTyped(evt);
}
});

javax.swing.GroupLayout pan1Layout = new javax.swing.GroupLayout(pan1);
pan1.setLayout(pan1Layout);
pan1Layout.setHorizontalGroup(
pan1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pan1Layout.createSequentialGroup()
.addComponent(txt1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt2, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt3, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
);
pan1Layout.setVerticalGroup(
pan1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pan1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(pan1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txt1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txt2, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txt3, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)))
);

txt6.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
txt6FocusLost(evt);
}
});
txt6.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
txt6KeyTyped(evt);
}
});

txt5.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
txt5FocusLost(evt);
}
});
txt5.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
txt5KeyTyped(evt);
}
});

txt4.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
txt4FocusLost(evt);
}
});
txt4.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
txt4KeyTyped(evt);
}
});

javax.swing.GroupLayout pan2Layout = new javax.swing.GroupLayout(pan2);
pan2.setLayout(pan2Layout);
pan2Layout.setHorizontalGroup(
pan2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pan2Layout.createSequentialGroup()
.addComponent(txt4, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt5, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt6, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
);
pan2Layout.setVerticalGroup(
pan2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pan2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txt4, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txt5, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txt6, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
);

txt9.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
txt9FocusLost(evt);
}
});
txt9.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
txt9KeyTyped(evt);
}
});

txt8.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
txt8FocusLost(evt);
}
});
txt8.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
txt8KeyTyped(evt);
}
});

txt7.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
txt7FocusLost(evt);
}
});
txt7.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
txt7KeyTyped(evt);
}
});

javax.swing.GroupLayout pan3Layout = new javax.swing.GroupLayout(pan3);
pan3.setLayout(pan3Layout);
pan3Layout.setHorizontalGroup(
pan3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pan3Layout.createSequentialGroup()
.addComponent(txt7, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt8, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt9, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
);
pan3Layout.setVerticalGroup(
pan3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pan3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txt7, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txt8, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txt9, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
);

jLabel1.setText("=");

jLabel2.setText("=");

jLabel3.setText("=");

javax.swing.GroupLayout pan_leb2Layout = new javax.swing.GroupLayout(pan_leb2);
pan_leb2.setLayout(pan_leb2Layout);
pan_leb2Layout.setHorizontalGroup(
pan_leb2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pan_leb2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(38, 38, 38)
.addComponent(jLabel2)
.addGap(37, 37, 37)
.addComponent(jLabel3)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pan_leb2Layout.setVerticalGroup(
pan_leb2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pan_leb2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3))
);

jLabel4.setText("=");

jLabel5.setText("=");

jLabel6.setText("=");

javax.swing.GroupLayout pan_leb1Layout = new javax.swing.GroupLayout(pan_leb1);
pan_leb1.setLayout(pan_leb1Layout);
pan_leb1Layout.setHorizontalGroup(
pan_leb1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel6)
);
pan_leb1Layout.setVerticalGroup(
pan_leb1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pan_leb1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel4)
.addGap(18, 18, 18)
.addComponent(jLabel5)
.addGap(18, 18, 18)
.addComponent(jLabel6)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

res3.setEditable(false);

res2.setEditable(false);

res1.setEditable(false);

javax.swing.GroupLayout pan_res1Layout = new javax.swing.GroupLayout(pan_res1);
pan_res1.setLayout(pan_res1Layout);
pan_res1Layout.setHorizontalGroup(
pan_res1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pan_res1Layout.createSequentialGroup()
.addGroup(pan_res1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(res1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(res2, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(res3, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pan_res1Layout.setVerticalGroup(
pan_res1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pan_res1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(res1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(res2, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(res3, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
);

res4.setEditable(false);

res5.setEditable(false);

res6.setEditable(false);

javax.swing.GroupLayout pan_res2Layout = new javax.swing.GroupLayout(pan_res2);
pan_res2.setLayout(pan_res2Layout);
pan_res2Layout.setHorizontalGroup(
pan_res2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pan_res2Layout.createSequentialGroup()
.addComponent(res4, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(res5, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(res6, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(70, Short.MAX_VALUE))
);
pan_res2Layout.setVerticalGroup(
pan_res2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pan_res2Layout.createSequentialGroup()
.addGroup(pan_res2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(res4, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(res5, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(res6, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

btn_sol.setText("Solve!!");
btn_sol.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_solActionPerformed(evt);
}
});

btn_clr.setText("Clear");
btn_clr.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_clrActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addContainerGap(57, Short.MAX_VALUE)
.addComponent(btn_clr)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btn_sol)
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btn_sol)
.addComponent(btn_clr))
.addContainerGap())
);

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pan_res2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(pan_leb2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(pan2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pan1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pan3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pan_leb1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pan_res1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(pan_res1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(pan_leb1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(pan1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pan2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pan3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pan_leb2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pan_res2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gameapps/close.PNG"))); // NOI18N
jLabel7.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
jLabel7MouseReleased(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(209, Short.MAX_VALUE)
.addComponent(jLabel7))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel7))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

pack();
}// </editor-fold>//GEN-END:initComponents

private void txt1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt1KeyPressed
// TODO add your handling code here:

}//GEN-LAST:event_txt1KeyPressed

private void txt1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt1KeyTyped
// TODO add your handling code here:
stopKeyEvent(evt,txt1);

int x;
int p=evt.getKeyChar();
if(txt2.getText().length()>0)
{
x=txt2.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt3.getText().length()>0)
{
x=txt3.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt4.getText().length()>0)
{
x=txt4.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt5.getText().length()>0)
{
x=txt5.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt6.getText().length()>0)
{
x=txt6.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt7.getText().length()>0)
{
x=txt7.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt8.getText().length()>0)
{
x=txt8.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt9.getText().length()>0)
{
x=txt9.getText().charAt(0);
if(x==p)
evt.consume();
}
}//GEN-LAST:event_txt1KeyTyped

private void txt2KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt2KeyTyped
// TODO add your handling code here:
stopKeyEvent(evt,txt2);

int x;
int p=evt.getKeyChar();
if(txt1.getText().length()>0)
{
x=txt1.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt3.getText().length()>0)
{
x=txt3.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt4.getText().length()>0)
{
x=txt4.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt5.getText().length()>0)
{
x=txt5.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt6.getText().length()>0)
{
x=txt6.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt7.getText().length()>0)
{
x=txt7.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt8.getText().length()>0)
{
x=txt8.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt9.getText().length()>0)
{
x=txt9.getText().charAt(0);
if(x==p)
evt.consume();
}

}//GEN-LAST:event_txt2KeyTyped

private void txt3KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt3KeyTyped
// TODO add your handling code here:
stopKeyEvent(evt,txt3);

int x;
int p=evt.getKeyChar();
if(txt2.getText().length()>0)
{
x=txt2.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt1.getText().length()>0)
{
x=txt1.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt4.getText().length()>0)
{
x=txt4.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt5.getText().length()>0)
{
x=txt5.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt6.getText().length()>0)
{
x=txt6.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt7.getText().length()>0)
{
x=txt7.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt8.getText().length()>0)
{
x=txt8.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt9.getText().length()>0)
{
x=txt9.getText().charAt(0);
if(x==p)
evt.consume();
}

}//GEN-LAST:event_txt3KeyTyped

private void txt4KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt4KeyTyped
// TODO add your handling code here:
stopKeyEvent(evt,txt4);


int x;
int p=evt.getKeyChar();
if(txt2.getText().length()>0)
{
x=txt2.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt3.getText().length()>0)
{
x=txt3.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt1.getText().length()>0)
{
x=txt1.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt5.getText().length()>0)
{
x=txt5.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt6.getText().length()>0)
{
x=txt6.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt7.getText().length()>0)
{
x=txt7.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt8.getText().length()>0)
{
x=txt8.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt9.getText().length()>0)
{
x=txt9.getText().charAt(0);
if(x==p)
evt.consume();
}

}//GEN-LAST:event_txt4KeyTyped

private void txt5KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt5KeyTyped
// TODO add your handling code here:
stopKeyEvent(evt,txt5);

int x;
int p=evt.getKeyChar();
if(txt2.getText().length()>0)
{
x=txt2.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt3.getText().length()>0)
{
x=txt3.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt4.getText().length()>0)
{
x=txt4.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt1.getText().length()>0)
{
x=txt1.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt6.getText().length()>0)
{
x=txt6.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt7.getText().length()>0)
{
x=txt7.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt8.getText().length()>0)
{
x=txt8.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt9.getText().length()>0)
{
x=txt9.getText().charAt(0);
if(x==p)
evt.consume();
}

}//GEN-LAST:event_txt5KeyTyped

private void txt6KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt6KeyTyped
// TODO add your handling code here:
stopKeyEvent(evt,txt6);

int x;
int p=evt.getKeyChar();
if(txt2.getText().length()>0)
{
x=txt2.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt3.getText().length()>0)
{
x=txt3.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt4.getText().length()>0)
{
x=txt4.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt5.getText().length()>0)
{
x=txt5.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt1.getText().length()>0)
{
x=txt1.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt7.getText().length()>0)
{
x=txt7.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt8.getText().length()>0)
{
x=txt8.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt9.getText().length()>0)
{
x=txt9.getText().charAt(0);
if(x==p)
evt.consume();
}

}//GEN-LAST:event_txt6KeyTyped

private void txt7KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt7KeyTyped
// TODO add your handling code here:
stopKeyEvent(evt,txt7);

int x;
int p=evt.getKeyChar();
if(txt2.getText().length()>0)
{
x=txt2.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt3.getText().length()>0)
{
x=txt3.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt4.getText().length()>0)
{
x=txt4.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt5.getText().length()>0)
{
x=txt5.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt6.getText().length()>0)
{
x=txt6.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt1.getText().length()>0)
{
x=txt1.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt8.getText().length()>0)
{
x=txt8.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt9.getText().length()>0)
{
x=txt9.getText().charAt(0);
if(x==p)
evt.consume();
}

}//GEN-LAST:event_txt7KeyTyped

private void txt8KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt8KeyTyped
// TODO add your handling code here:
stopKeyEvent(evt,txt8);


int x;
int p=evt.getKeyChar();
if(txt2.getText().length()>0)
{
x=txt2.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt3.getText().length()>0)
{
x=txt3.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt4.getText().length()>0)
{
x=txt4.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt5.getText().length()>0)
{
x=txt5.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt6.getText().length()>0)
{
x=txt6.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt7.getText().length()>0)
{
x=txt7.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt1.getText().length()>0)
{
x=txt1.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt9.getText().length()>0)
{
x=txt9.getText().charAt(0);
if(x==p)
evt.consume();
}

}//GEN-LAST:event_txt8KeyTyped

private void txt9KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt9KeyTyped
// TODO add your handling code here:
stopKeyEvent(evt,txt9);


int x;
int p=evt.getKeyChar();
if(txt2.getText().length()>0)
{
x=txt2.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt3.getText().length()>0)
{
x=txt3.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt4.getText().length()>0)
{
x=txt4.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt5.getText().length()>0)
{
x=txt5.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt6.getText().length()>0)
{
x=txt6.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt7.getText().length()>0)
{
x=txt7.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt8.getText().length()>0)
{
x=txt8.getText().charAt(0);
if(x==p)
evt.consume();
}
if(txt1.getText().length()>0)
{
x=txt1.getText().charAt(0);
if(x==p)
evt.consume();
}

}//GEN-LAST:event_txt9KeyTyped

private void txt1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txt1FocusLost
// TODO add your handling code here
setTotal(txt1,txt2,txt3,res1);
setTotal(txt1,txt4,txt7,res4);
}//GEN-LAST:event_txt1FocusLost

private void txt2FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txt2FocusLost
// TODO add your handling code here:
setTotal(txt2,txt1,txt3,res1);
setTotal(txt2,txt5,txt8,res5);
}//GEN-LAST:event_txt2FocusLost

private void txt3FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txt3FocusLost
// TODO add your handling code here:
setTotal(txt3,txt2,txt1,res1);
setTotal(txt3,txt6,txt9,res6);
}//GEN-LAST:event_txt3FocusLost

private void txt4FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txt4FocusLost
// TODO add your handling code here:
setTotal(txt4,txt5,txt6,res2);
setTotal(txt4,txt1,txt7,res4);
}//GEN-LAST:event_txt4FocusLost

private void txt5FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txt5FocusLost
// TODO add your handling code here:
setTotal(txt5,txt4,txt6,res2);
setTotal(txt5,txt2,txt8,res5);
}//GEN-LAST:event_txt5FocusLost

private void txt6FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txt6FocusLost
// TODO add your handling code here:
setTotal(txt6,txt4,txt5,res2);
setTotal(txt6,txt3,txt9,res6);
}//GEN-LAST:event_txt6FocusLost

private void txt7FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txt7FocusLost
// TODO add your handling code here:
setTotal(txt7,txt8,txt9,res3);
setTotal(txt7,txt1,txt4,res4);
}//GEN-LAST:event_txt7FocusLost

private void txt8FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txt8FocusLost
// TODO add your handling code here:
setTotal(txt8,txt9,txt7,res3);
setTotal(txt8,txt5,txt2,res5);
}//GEN-LAST:event_txt8FocusLost

private void txt9FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txt9FocusLost
// TODO add your handling code here:
setTotal(txt9,txt7,txt8,res3);
setTotal(txt9,txt3,txt6,res6);
}//GEN-LAST:event_txt9FocusLost

private void btn_solActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_solActionPerformed
// TODO add your handling code here:
Random rndm=new Random();
int a=rndm.nextInt(tp.getVector().size());
// System.out.println(tp.getVector().size()+" "+a);
Vector temp=(Vector) tp.getVector().get(a);

Vector _2d_1=(Vector) temp.get(0);
Vector _2d_2=(Vector) temp.get(1);
Vector _2d_3=(Vector) temp.get(2);

// int[][] temp=(int[][]) tp.getVector().get(a);

// try{
// for(int p=0;p<tp.getVector().size();p++)
// {
// Vector temp=(Vector) tp.getVector().get(p);
// System.out.println(temp+" temp: "+temp.size());
// for(int i=0;i<temp.size();i++)
// {
// Vector _2d=(Vector) temp.get(i);
// System.out.println(_2d+" _2d: "+_2d.size());
// for(int j=0;j<3;j++)
// {
// System.out.print (" "+_2d.get(j));
// }
// System.out.println ();
// }
// System.out.println ("---------------------");
// }
// }
// catch(Exception e)
// {
// System.out.println(e);
// }

txt1.setText(""+_2d_1.get(0));
txt2.setText(""+_2d_1.get(1));
txt3.setText(""+_2d_1.get(2));
txt4.setText(""+_2d_2.get(0));
txt5.setText(""+_2d_2.get(1));
txt6.setText(""+_2d_2.get(2));
txt7.setText(""+_2d_3.get(0));
txt8.setText(""+_2d_3.get(1));
txt9.setText(""+_2d_3.get(2));
res1.setText("15");
res2.setText("15");
res3.setText("15");
res4.setText("15");
res5.setText("15");
res6.setText("15");
}//GEN-LAST:event_btn_solActionPerformed

private void btn_clrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_clrActionPerformed
// TODO add your handling code here:

txt1.setText("");
txt2.setText("");
txt3.setText("");
txt4.setText("");
txt5.setText("");
txt6.setText("");
txt7.setText("");
txt8.setText("");
txt9.setText("");
res1.setText("");
res2.setText("");
res3.setText("");
res4.setText("");
res5.setText("");
res6.setText("");
}//GEN-LAST:event_btn_clrActionPerformed

private void jLabel7MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel7MouseReleased
// TODO add your handling code here:
close();
}//GEN-LAST:event_jLabel7MouseReleased

public void stopKeyEvent(KeyEvent evt,JTextField txt)
{
int p=evt.getKeyChar();
if(p>=49 && p<=57)
{
if(txt.getText().length()==0)
{

}
else
evt.consume();
}
else
evt.consume();
}

public void setTotal(JTextField txt1,JTextField txt2,JTextField txt3,JTextField res1)
{
int sum=0;
if(!txt1.getText().equals(""))
{
if(!txt2.getText().equals("") && !txt3.getText().equals(""))
{
sum=Integer.parseInt(txt1.getText())+Integer.parseInt(txt2.getText())+Integer.parseInt(txt3.getText());
res1.setText(""+sum);
}
else if(!txt2.getText().equals("") && txt3.getText().equals(""))
{
sum=Integer.parseInt(txt1.getText())+Integer.parseInt(txt2.getText());
res1.setText(""+sum);
}
else if(txt2.getText().equals("") && !txt3.getText().equals(""))
{
sum=Integer.parseInt(txt1.getText())+Integer.parseInt(txt3.getText());
res1.setText(""+sum);
}
else
res1.setText(""+txt1.getText());
}
}
/**
* @param args the command line arguments
*/
// public static void main(String args[]) {
// java.awt.EventQueue.invokeLater(new Runnable() {
// public void run() {
// new MainFrame().setVisible(true);
// }
// });
// }

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btn_clr;
private javax.swing.JButton btn_sol;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel pan1;
private javax.swing.JPanel pan2;
private javax.swing.JPanel pan3;
private javax.swing.JPanel pan_leb1;
private javax.swing.JPanel pan_leb2;
private javax.swing.JPanel pan_res1;
private javax.swing.JPanel pan_res2;
private javax.swing.JTextField res1;
private javax.swing.JTextField res2;
private javax.swing.JTextField res3;
private javax.swing.JTextField res4;
private javax.swing.JTextField res5;
private javax.swing.JTextField res6;
private javax.swing.JTextField txt1;
private javax.swing.JTextField txt2;
private javax.swing.JTextField txt3;
private javax.swing.JTextField txt4;
private javax.swing.JTextField txt5;
private javax.swing.JTextField txt6;
private javax.swing.JTextField txt7;
private javax.swing.JTextField txt8;
private javax.swing.JTextField txt9;
// End of variables declaration//GEN-END:variables
int done[]=new int[9];
int count=0;
TestProg tp;
}