import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import java.net.*;
import javax.swing.event.MenuEvent.*;
private JPanel p1,p2,p3,p4,p5,p6,p7,p8,p9
;
private static JButton b1,b2,dv,die,ctime,cpoint,etime
;
static int value,no_click,total;
static int a,bvalue,v;
static int sstime,smtime,estime,emtime,tt;
public well()
{
super("--------JGamez--------");
setDefaultLookAndFeelDecorated(false);
setBounds(10,10, 900, 500);
getContentPane().add(d);
f1.setTitle("welcome");
f1.setBounds(10,10,350,350);
f1.
getContentPane().
setLayout(new GridLayout(9,
9));
for(int i=0;i<=80;i++)
{
ba[i].setText(" ");
ba
[i
].
setBackground(Color.
white);
ba[0].setText("Start");
f1.getContentPane().add(ba[i]);
}
ba
[80].
setBackground(Color.
red);
ba[80].setText("Goal");
f1.setResizable(false);
f1.setIconifiable(true);
f1.setDefaultCloseOperation(HIDE_ON_CLOSE);
d.add(f1,0);
f1.setVisible(false);
f2.setTitle("Remote Control");
f2.
getContentPane().
setLayout(new GridLayout(1,
1));
{
{
well.die.setEnabled(true);
well.etime.setText(" ");
well.ctime.setText(" ");
well.cpoint.setText("point: ");
well.f1.setVisible(true);
well.b1.setEnabled(true);
well.b2.setEnabled(true);
well.f1.show();
well.f5.setVisible(false);
well.f6.setVisible(true);
int i=0;
while(i<=80)
{
if(i>=10&&i<=20){
if(i==11||i==12||i==13)
ba
[i
].
setBackground(Color.
red);
else
ba
[i
].
setBackground(Color.
white);}
else if(i>=21&&i<=31){
if(i==23||i==26||i==29)
ba
[i
].
setBackground(Color.
red);
else
ba
[i
].
setBackground(Color.
white); }
else if(i>=32&&i<=45){
if(i==34||i==37||i==41)
ba
[i
].
setBackground(Color.
red);
else
ba
[i
].
setBackground(Color.
white); }
else if(i>=45&&i<=60){
if(i==46||i==49||i==58||i==52)
ba
[i
].
setBackground(Color.
red);
else
ba
[i
].
setBackground(Color.
white); }
else if(i>=61&&i<=78){
if(i==66||i==69||i==75)
ba
[i
].
setBackground(Color.
red);
else
ba
[i
].
setBackground(Color.
white); }
else
ba
[i
].
setBackground(Color.
white);
i++;
}
new well(0,0);
}
};
{
{
smtime
=new Date().
getMinutes();
sstime
=new Date().
getSeconds();
well.
ctime.
setText(" StartedTime:"+String.
valueOf(new Date().
getHours())+":"+String.
valueOf(new Date().
getMinutes())+":"+String.
valueOf(new Date().
getSeconds()));
well.etime.setText(" ");
well.cpoint.setText("point: ");
well.b1.setEnabled(false);
well.b2.setEnabled(false);
well.f5.setVisible(true);
well.f1.setVisible(false);
well.die.setEnabled(false);
well.f6.setVisible(true);
well.f5.show();
no_click=0;
total=0;
for(int j=0;j<=15;j++)
{
bvalue
=(int)(Math.
random()*75);
bb
[j
].
setText(String.
valueOf(bvalue
));
}
}
};
item10.addActionListener(al);
item11.addActionListener(ab);
item1.add(item10);
item1.add(item11);
file.add(item1);
file.add(item2);
{
{
well.f7.setVisible(true);
well.f7.show();
}
};
{
{
JOptionPane.
showMessageDialog(null,
"(c)copyright 2006 by NeXT solutionsn owner: R.Sindhukumar",
"JGamez",
JOptionPane.
INFORMATION_MESSAGE);
}
};
item3.addActionListener(ag);
item4.addActionListener(ad);
Help.add(item3);
Help.add(item4);
jmb.add(file);
jmb.add(Help);
f2.getContentPane().add(jmb);
f2.setBounds(370,100,350,50);
f2.setResizable(false);
f2.
setDefaultCloseOperation(JFrame.
DO_NOTHING_ON_CLOSE);
die.setEnabled(false);
die.
setBackground(Color.
cyan);
die.addActionListener(this);
f2.getContentPane().add(die);
d.add(f2,1);
f2.show();
f3.
getContentPane().
setLayout(new GridLayout(1,
1));
b1
=new JButton("HIDE THE Die GAME WINDOW");
b2
=new JButton("SHOW THE Die GAME WINDOW");
b1.addActionListener(this);
b2.addActionListener(this);
f3.getContentPane().add(b1);
f3.getContentPane().add(b2);
f3.setBounds(370,10,420,50);
f3.setResizable(false);
f3.
setDefaultCloseOperation(JFrame.
DO_NOTHING_ON_CLOSE);
d.add(f3,3);
f3.show();
f4.
getContentPane().
setLayout(new GridLayout(1,
1));
dv.
setBackground(Color.
white);
f4.getContentPane().add(dv);
f4.setBounds(370,150,350,50);
f4.setResizable(false);
f4.setTitle("Dice Value");
f4.
setDefaultCloseOperation(JFrame.
DO_NOTHING_ON_CLOSE);
d.add(f4,4);
f4.show();
f5.setTitle("Number Game");
f5.setBounds(10,10,350,350);
f5.
getContentPane().
setLayout(new GridLayout(4,
4));
f5.setDefaultCloseOperation(HIDE_ON_CLOSE);
{
{
String val
=e.
getActionCommand();
no_click++;
if(no_click<=4)
{
total=total+s;
if(total==100&&no_click==4)
{
well.
etime.
setText(" Finished Time:"+String.
valueOf(new Date().
getHours())+":"+String.
valueOf(new Date().
getMinutes())+":"+String.
valueOf(new Date().
getSeconds()));
emtime
=new Date().
getMinutes();
if(emtime!=0){
tt=(emtime*60)-(smtime*60);
if(tt<=10){
well.cpoint.setText("point: "+stt);}
else if(tt>=11&&tt<=20){
well.cpoint.setText("point: "+stt);}
else if(tt>=21&&tt<=25){
well.cpoint.setText("point: "+stt);}
else if(tt>=26&&tt<=35){
well.cpoint.setText("point: "+stt);}
else
{
well.cpoint.setText("point: "+stt);}
}
else if(emtime==0)
{
tt=estime-sstime;
if(tt<=10){
well.cpoint.setText("point: "+stt);}
else if(tt>=11&&tt<=20){
well.cpoint.setText("point: "+stt);}
else if(tt>=21&&tt<=25){
well.cpoint.setText("point: "+stt);}
else if(tt>=26&&tt<=35){
well.cpoint.setText("point: "+stt);}
else
{
well.cpoint.setText("point: "+stt);}
}
}
}
else
{
if(total==100&&no_click>=4)
{
JOptionPane.
showMessageDialog(null,
"Sorry! You are already won");
JOptionPane.
showMessageDialog(null,
"To Play again Click File->new->number game");
}
else
{
well.
etime.
setText(" Finished Time:"+String.
valueOf(new Date().
getHours())+":"+String.
valueOf(new Date().
getMinutes())+":"+String.
valueOf(new Date().
getSeconds()));
JOptionPane.
showMessageDialog(null,
"Bad luck! You are failed");
}
}
}
};
for(int j=0;j<=15;j++)
{
bb[j].setText(" ");
bb
[j
].
setBackground(Color.
yellow);
bvalue
=(int)(Math.
random()*75);
bb
[j
].
setText(String.
valueOf(bvalue
));
bb[j].addActionListener(ngl);
f5.getContentPane().add(bb[j]);
d.add(f5,0);
}
f5.setVisible(false);
f6
=new JInternalFrame("Your Points-Only for Number Game",
false,
false,
true,
true);
f6.setBounds(370,200,350, 75);
f6.
getContentPane().
setLayout(new GridLayout(2,
2));
ctime.setText(" ");
f6.getContentPane().add(cpoint);
f6.getContentPane().add(ctime);
f6.getContentPane().add(etime);
f6.show();
d.add(f6,0);
f7.setBounds(10,10, 350,350);
f7.setDefaultCloseOperation(HIDE_ON_CLOSE);
f7.
setBackground(new Color(170,
172,
100));
editor.setContentType("text/html");
editor.setText("<font color='#800000'><b>Number Game</b></font><font color='#800000'><b><pre>Number Game contains 16 boxes. Each box contains a Number. You want to select 4 numbers from the boxes by clicking them and the total of the numbers must be 100 ...............</pre></b></font><p align=center><font color='#800000'><b>Die Game</b></font><pre>Die Game is the game in which you want to move around thecells based on value get by throwing the die and it containssome Red cells on whichyou can't go</pre>.............<font color='#800000'><b>Thank you</b></font>");
editor.setEditable(false);
f7.getContentPane().add(scroll);
f7.setDefaultCloseOperation(HIDE_ON_CLOSE);
f7.setVisible(false);
d.add(f7,0);
f8.setBounds(10,10,350,350);
editor.setContentType("text/html");
editor.setText("<font size=12 color=blue>Welcome Friends!</font><b><font size=8 color=#ff0ce4>JGamez contains two games--die game and Number gameTry it...</font></b>");
editor.setEditable(false);
f8.getContentPane().add(scroll);
f8.setDefaultCloseOperation(HIDE_ON_CLOSE);
f8.setVisible(true);
f8.show();
d.add(f8,0);
}
public well(int value1)
{
a=a+value1;
if(a<=80)
{
if(a==11||a==12||a==13||a==23||a==26||a==29||a==34||a==37||a==41||a==46||a==49||a==58||a==52||a==66||a==69||a==75)
{
JOptionPane.
showMessageDialog(null,
"sorry! you can't proceedn you landed on red cell");
JOptionPane.
showMessageDialog(well.
f1,
"Window will close now ");
well.f1.setVisible(false);
well.b1.setEnabled(false);
well.b2.setEnabled(false);
}
else
{
ba
[a
].
setBackground(Color.
green);
for(int i=a-1;i>=0;i--)
{
ba
[i
].
setBackground(Color.
pink);
}
}
}
else
{
ba
[0].
setBackground(Color.
red);
ba[0].setText("Game over");
repaint();
}
}
public well(int value1,int a1)
{
a=a1;
new well(value1);
}
{
if(evt.getSource()==b1)
{
well.f1.setVisible(false);
}
else if(evt.getSource()==die)
{
if(ba
[80].
getBackground()!=Color.
green){
value
=(int)(Math.
random()*6);
value=value+1;
well.dv.setText(c);
new well(value);
}
else
{
JOptionPane.
showMessageDialog(null,
"your are successfull winner",
"winnner notice",
JOptionPane.
INFORMATION_MESSAGE);
}}
else{
well.f1.show();
well.f1.setVisible(true);
well.f1.repaint();
}
}
public static void main
(String args
[])
{
well a=new well();
a.
setDefaultCloseOperation(JFrame.
EXIT_ON_CLOSE);
a.setVisible(true);
}
}