Beruflich Dokumente
Kultur Dokumente
CLIENT/SERVER COMMUNICATION
AIM:
To create a java program to investigate client server communication.
ALGORITHM:
1.
2.
3.
4.
5.
6.
PROGRAM:
//DateServer.java
import java.io.*;
import java.net.*;
import java.util.*;
public class DateServer extends Thread {
private ServerSocket dateServer;
public static void main(String argv[]) throws Exception {
new DateServer();
}
public DateServer() throws Exception {
dateServer = new ServerSocket(3000);
System.out.println("Server listening on port 3000.");
this.start();
}
public void run() {
while(true) {
try {
System.out.println("Waiting for connections.");
Socket client = dateServer.accept();
Ex.No.:2
AIM:
To create a java program for file transfer using FTP socket.
ALGORITHM:
1.
2.
3.
4.
5.
6.
7.
8.
9.
//FTP Server
import java.io.*;
import java.net.*;
class ftpserver
{
public static void main(String args[])throws Exception
{
String filename;
ServerSocket serverw=new ServerSocket(9981);
System.out.println("\n ftp server running");
while(true)
{
Socket serverc=serverw.accept();
BufferedReader informclient=new BufferedReader(new
InputStreamReader(serverc.getInputStream()));
filename=informclient.readLine();
BufferedReader br=new BufferedReader(new FileReader(filename));
System.out.println("\n file received");
System.out.println("\n filename"+filename);
System.out.println("\n the content of the file are");
String out=br.readLine();
while(!out.equals("ends"));
{
System.out.println("\n \t"+out);
out=br.readLine();
if(out==null)
break;
}
}
}
}
//FTP client:
import java.io.*;
import java.net.*;
public class ftpclient
{
public static void main(String args[])throws IOException
{
Socket clients=new Socket(InetAddress.getLocalHost(),9981);
String sent1;
BufferedReader informuser= new BufferedReader(new InputStreamReader(System.in));
DataOutputStream outtoserver=new DataOutputStream(clients.getOutputStream());
System.out.println("\n enter the file name");
sent1=informuser.readLine();
outtoserver.writeBytes(sent1+"\n");
clients.close();
}
}
OUTPUT:
Server:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\MCA-HOD>d:
D:\>set path=C:\Program Files\Java\jdk1.5.0_06\bin;
D:\>set classpath=.;
D:\>javac ftpserver.java
D:\>java ftpserver
ftp server running
file received
filenameswing.java
the content of the file are
Client:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\MCA-HOD>d:
D:\>set path=C:\Program Files\Java\jdk1.5.0_06\bin;
D:\>set classpath=.;
D:\>javac ftpclient.java
D:\>java ftpclient
enter the file name
swing.java
D:\>
Ex.No.: 3
AIM:
To create a java program to perform addition using RMI
ALGORITHM:
1.
2.
3.
4.
5.
6.
7.
8.
PROGRAM:
//impl.java
import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
public class impl extends UnicastRemoteObject implements iface
{
public impl() throws RemoteException{ }
public int add(int m,int n) throws RemoteException
{
return(m+n); // function for addition
}
}
//iface.java
import java.rmi.*;
import java.rmi.server.*;
public interface iface extends Remote
{
public int add(int a,int b)throws RemoteException;
}
//rmiserver.java
import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
public class rmiserver
{
public static void main(String args[ ])throws IOException
{
impl i=new impl();
System.out.println("Installing server");
Naming.rebind("addition",i);
System.out.println("Registered");
}
}
//rmiclient.java
import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
public class rmiclient1
{
public static void main(String args[ ])throws Exception
{
String url="rmi://"+args[0]+"/addition";
iface ifa=(iface)Naming.lookup(url); // interface used for connection
System.out.println("Enter value for x...");
InputStreamReader reader=new InputStreamReader(System.in);
BufferedReader in=new BufferedReader(reader);
String text=in.readLine();
int x=Integer.parseInt(text);
System.out.println("Enter value for y...");
text=in.readLine();
int y=Integer.parseInt(text);
int r=ifa.add(x,y);
// calling addition function
System.out.println("Result:"+r);
}
}
OUTPUT:
Server:
C:\Program files\Java\Jdk1.5.0_06\bin>javac *.java
C:\Program files\Java\Jdk1.5.0_06\bin>rmic impl
C:\Program files\Java\Jdk1.5.0_06\bin>start rmiregitry
C:\Program files\Java\Jdk1.5.0_06\bin>java rmiserver
Installing server.
Registered.
Client:
C:\Program files\Java\Jdk1.5.0_06\bin>java rmiclient1 10.0.25.21
Enter value for x
10
Enter value for y
20
Result: 30
Ex. No.: 4
AIM:
To create java program for copying file using Remote Method Invocation.
ALGORITHM:
1.
2.
3.
4.
System.err.println("fileserverException:"+e.getMessage());
e.printStackTrace();
}
}
}
//fileserver.java
import java.io.*;
import java.rmi.*;
public class fileserver
{public static void main(String args[])
{
try{
fileface f=new fileimp("file server");
Naming.rebind("fileserver",f);
}
catch(Exception e)
{System.out.println("fileserver"+e.getMessage());
e.printStackTrace();
}
}
}
OUTPUT:
C:\Documents and Settings\MCA-HOD>d:
D:\>set path=C:\Program Files\Java\jdk1.5.0_06\bin;
D:\>set classpath=.;
D:\>javac fileface.java
D:\>javac fileimp.java
D:\>javac fileclient.java
D:\>javac fileserver.java
D:\>rmic fileimp
D:\>start rmiregistry
D:\>java fileserver
Client:
C:\Documents and Settings\MCA-HOD>d:
D:\>set path=C:\Program Files\Java\jdk1.5.0_06\bin;
D:\>set classpath=.;
D:\>java fileclient h.txt 10.0.26.203
enter the new name to file
h1.txt
File copied
D:\>type h1.txt
HELLO MCA
D:\>
EX NO: 5
AIM:
A Program to find whether the number is prime or not using the Remote Method Invocation.
ALGORITHM:
1. A server program waits for the client.
2. The Client gets the data from the user and calls a remote function in the server side.
3. The server finds whether the number is prime or not .
4. The server returns the result.
5. An Interface program has the remote methods declaration.
PROGRAM :
//Cliprime.java:
import java.rmi.*;
import java.net.*;
import java.io.*;
public class Cliprime
{
public static void main (String args []) throws Exception
{
Ifprime ifp;
String answer="";
InputStreamReader ins=new InputStreamReader (System.in);
BufferedReader br=new BufferedReader (ins);
InetAddress ia=InetAddress.getLocalHost ();
String ip=ia.toString ().substring (ia.toString ().indexOf ('/') +1);
String url="rmi://"+ip+"/Srvprime";
System.out.println ("Check whether the number is prime or not");
System.out.println ("Type an int to test for prime :");
ifp= (Ifprime) Naming.lookup (url);
String sn=br.readLine ();
int n =Integer.parseInt (sn);
System.out.println (ifp.Checkprime (n));
}
}
//Ifprime.java:
import java.rmi.*;
public interface Ifprime extends Remote
{
String Checkprime (int n) throws RemoteException;
}
Srvprime.java
import java.rmi.*;
import java.rmi.server.*;
Ex.No.:6
CORBA
AIM:
To write a program to print Hello World in CORBA.
ALGORITHM:
1. Start the process.
2. Create the interface stockmarket.
3. Declare the price function.
4. StockmarketImpl class extends from the base class.
5. Initialize the price=0 and checck the length of symbol with chart().
6. Calculate the price and return and call Super().
7. Create server class and object orb, allocate the memory for server implementation.
8. Connect the orb and refer the object reference.
9. Allocate the component for the specific path.
10. Rebind the path, a swing naming component reference.
11. In client side,call the resolve() with specification path.
12. Call the market getprice() tp display the price.
13. Stop the process.
PROGRAM:
//Simplestocks.idl
module simplestocks
{
interface stockmarket
{
float get_price(in string symbol);
};
};
//Stockmarketimpl.java
import org.omg.CORBA.*;
import simplestocks.*;
public class stockmarketimpl extends _stockmarketImplBase
{
public float get_price(String symbol)
{
float price=0;
for(int i=0;i<symbol.length();i++)
{
price+=(int)symbol.charAt(i);
}
price/=5;
return price;
}
public stockmarketimpl()
{
super();
}
}
//Stockmarketserver.java
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import simplestocks.*;
public class stockmarketserver
{
public static void main(String args[])
{
try
{
ORB orb=ORB.init(args,null);
stockmarketimpl d=new stockmarketimpl();
orb.connect(d);
org.omg.CORBA.Object objRef=orb.resolve_initial_references("NameService");
NamingContext ncRef=NamingContextHelper.narrow(objRef);
NameComponent nc=new NameComponent("NASDAQ","");
NameComponent path[]={nc};
ncRef.rebind(path,(d));
System.out.println("\n\tSTOCK MARKET SERVER IS UP AND READY");
Thread.currentThread().join();
}
catch(Exception e)
{}
}
}
//Stockmarketclient.java
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import simplestocks.*;
public class stockmarketclient
{
public static void main(String args[])
{
try
{
ORB orb=ORB.init(args,null);
org.omg.CORBA.Object objRef=orb.resolve_initial_references("NameService");
NamingContext ncRef=NamingContextHelper.narrow(objRef);
NameComponent nc=new NameComponent("NASDAQ","");
NameComponent path[]={nc};
stockmarket market=stockmarketHelper.narrow(ncRef.resolve(path));
System.out.println("\n\tTHE PRICE OF MY COMPANY IS "+market.get_price("b"));
}
catch(Exception e)
{}
}
}
OUTPUT:
C:\>cd bea
C:\bea>idlj -fall -oldImplBase simplestocks.idl
C:\bea>set classpath=%classpath%;.;
C:\bea>javac *.java
Note: .\simplestocks\_stockmarketImplBase.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
C:\bea>tnameserv
Initial Naming Context:
IOR:000000000000002b49444c3a6f6d672e6f72672f436f734e616d696e672f4e616d696e67436f
6e746578744578743a312e30000000000001000000000000009a000102000000000b31302e302e32
362e323900000384000000000045afabcb00000000206619a1450000000100000000000000020000
0008526f6f74504f41000000000d544e616d65536572766963650000000000000008000000010000
00011400000000000002000000010000002000000000000100010000000205010001000100200001
0109000000010001010000000026000000020002
TransientNameServer: setting port for initial object references to: 900
Ready.
Client Window:
C:\Documents and Settings\admin>cd\
C:\>cd bea
C:\bea>java stockmarketserver
STOCK MARKET SERVER IS UP AND READY
Server Window:
C:\Documents and Settings\admin>cd\
C:\>cd bea
C:\bea>java stockmarketclient
THE PRICE OF MY COMPANY IS 19.6
Ex.No.:7
AIM:
To create a java program for chat room application.
ALGORITHM:
1. Start the process.
2. Create more than one client program and one server program.
3. Compile the client and server program.
4. Execute the client and server program.
5. Display the result.
6. Stop the process.
PROGRAM:
//Client:
import java.io.*;
import java.net.*;
public class MultiThreadChatClient implements Runnable{
static Socket clientSocket = null;
static PrintStream os = null;
static DataInputStream is = null;
static BufferedReader inputLine = null;
static boolean closed = false;
public static void main(String[] args)
{
int port_number=2222;
String host="localhost";
if (args.length < 2)
{
System.out.println("Usage: java MultiThreadChatClient \n"+
"Now using host="+host+", port_number="+port_number);
} else {
host=args[0];
port_number=Integer.valueOf(args[1]).intValue();
}
try {
clientSocket = new Socket(host, port_number);
inputLine = new BufferedReader(new InputStreamReader(System.in));
os = new PrintStream(clientSocket.getOutputStream());
is = new DataInputStream(clientSocket.getInputStream());
} catch (UnknownHostException e) {
System.err.println("Don't know about host "+host);
} catch (IOException e) {
System.err.println("Couldn't get I/O for the connection to the host "+host);
}
if (clientSocket != null && os != null && is != null) {
try {
if (args.length < 1)
{
System.out.println("Usage: java MultiThreadChatServer \n"+
"Now using port number="+port_number);
} else {
port_number=Integer.valueOf(args[0]).intValue();
}
try {
serverSocket = new ServerSocket(port_number);
}
catch (IOException e)
{System.out.println(e);}
while(true){
try {
clientSocket = serverSocket.accept();
for(int i=0; i<=9; i++){
if(t[i]==null)
{
(t[i] = new clientThread(clientSocket,t)).start();
break;
}
}
}
catch (IOException e) {
System.out.println(e);}
}
}
}
class clientThread extends Thread{
DataInputStream is = null;
PrintStream os = null;
Socket clientSocket = null;
clientThread t[];
public clientThread(Socket clientSocket, clientThread[] t){
this.clientSocket=clientSocket;
this.t=t;
}
public void run()
{
String line;
String name;
try{
is = new DataInputStream(clientSocket.getInputStream());
os = new PrintStream(clientSocket.getOutputStream());
os.println("Enter your name.");
name = is.readLine();
os.println("Hello "+name+" to our chat room.\nTo leave enter /quit in a new line");
for(int i=0; i<=9; i++)
if (t[i]!=null && t[i]!=this)
t[i].os.println("*** A new user "+name+" entered the chat room !!! ***" );
while (true) {
line = is.readLine();
if(line.startsWith("/quit")) break;
for(int i=0; i<=9; i++)
if (t[i]!=null) t[i].os.println("<"+name+"> "+line);
}
for(int i=0; i<=9; i++)
if (t[i]!=null && t[i]!=this)
t[i].os.println("*** The user "+name+" is leaving the chat room !!! ***" );
os.println("*** Bye "+name+" ***");
// Clean up:
// Set to null the current thread variable such that other client could
// be accepted by the server
for(int i=0; i<=9; i++)
if (t[i]==this) t[i]=null;
is.close();
os.close();
clientSocket.close();
}
catch(IOException e){};
}
}
OUTPUT:
Client1:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\MCA-HOD>d:
D:\>set path=C:\Program Files\Java\jdk1.5.0_06\bin;
D:\>set classpath=.;
D:\>javac MultiThreadChatClient.java
Note: MultiThreadChatClient.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
D:\>java MultiThreadChatClient
Usage: java MultiThreadChatClient
Now using host=localhost, port_number=2222
Ex.No.:8
AIM:
To create a web application program for student details
ALGORITHM:
1. Start the process.
2. Create the database StudentDB and create the table as student.
3. Declare the source for server and to trusted the connection is enable( set as YES).
4. Establish the connection by using object.
5. Insert the student values by using query to stored in insvalue of the variable.
6. Open the connection and execute the query.
7. Delete the student details using query by using cmd object.
8. Update the student details by using update query.
9. Select the student details based on the condition rno.
10. Stop the process.
PROGRAM:
//Creating Database
create database studentDB;
use studentDB;
create table student(rno int, name varchar(15), dept varchar(5));
//Program
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
public static string source = "server = CL233;Trusted_Connection = yes;database=studentDB";
SqlConnection conn = new SqlConnection(source);
protected void Page_Load(object sender, EventArgs e)
{
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
int rno = int.Parse(TextBox1.Text);
string name = TextBox2.Text;
string dept = TextBox3.Text;
string ins = "insert into student values(" + rno + ",'" + name + "','" + dept + "')";
SqlCommand cmd = new SqlCommand(ins, conn);
try
{
conn.Open();
cmd.ExecuteNonQuery();
Response.Write("RECORD INSERTED SUCCESSFULLY");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
conn.Close();
}
}
protected void Button3_Click(object sender, EventArgs e)
{
int rno = int.Parse(TextBox1.Text);
string ins = "delete from student where rno = " + rno;
SqlCommand cmd = new SqlCommand(ins, conn);
try
{
conn.Open();
cmd.ExecuteNonQuery();
Response.Write("RECORD DELETED SUCCESSFULLY");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
conn.Close();
}
}
protected void Button2_Click(object sender, EventArgs e)
{
int rno = int.Parse(TextBox1.Text);
string name = TextBox2.Text;
string dept = TextBox3.Text;
string ins = "update student set name = '" + name + "',dept = '" + dept + "' where rno = " + rno;
SqlCommand cmd = new SqlCommand(ins, conn);
try
{
conn.Open();
cmd.ExecuteNonQuery();
Response.Write("RECORD UPDATED SUCCESSFULLY");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
conn.Close();
}
}
protected void Button4_Click(object sender, EventArgs e)
{
int rno = int.Parse(TextBox1.Text);
string cmd = "select * from student where rno = " + rno;
SqlDataAdapter SDA = new SqlDataAdapter(cmd, source);
DataSet DS = new DataSet();
SDA.Fill(DS, "student");
DataTable DT = DS.Tables[0];
String name = "";
String dept = "";
foreach (DataRow DR in DT.Rows)
{
name = DR["name"].ToString();
dept = DR["dept"].ToString();
}
TextBox2.Text = name;
TextBox3.Text = dept;
}
Ex.No. 9
DESIGNING OF E-BUSINESS
AIM:
To create a java swing program for currency conversion.
ALGORITHM:
1.
2.
3.
4.
5.
PROGRAM:
import java.io.*;
import javax.swing.*;
import java.awt.event.*;
class swing
{
JTextField t1,t2;
JLabel l1,l2;
public swing()
{
JFrame f1=new JFrame();
f1.setSize(500,500);
f1.setVisible(true);
f1.setLayout(null);
l1=new JLabel("Indian Rupees");
l1.setBounds(10,100,200,30);
f1.add(l1);
l2=new JLabel("American doller");
l2.setBounds(10,200,200,30);
f1.add(l2);
t2=new JTextField();
t2.setBounds(100,200,200,30);
f1.add(t2);
t1=new JTextField();
t1.setBounds(100,100,200,30);
f1.add(t1);
JButton b1=new JButton("Convert");
b1.setBounds(200,300,100,30);
f1.add(b1);
b1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent EE)
{
int aa=Integer.parseInt(t1.getText());
int vv=aa/50;
Integer sss=new Integer(vv);
String con=sss.toString();
t2.setText(con + " $ ");
}
});
}
public static void main(String r[])
{
new swing();
}
}
OUTPUT:
C:\Documents and Settings\MCA-HOD>d:
D:\>javac swing.java
D:\>java swing
D:\>javac swing.java
D:\>java swing
D:\>javac swing.java
D:\>java swing
Ex.No.10
ONLINE GAMES
AIM:
To create the java program for sudoku game.
ALGORITHM:
1. Start the process.
2. Create the program for sudoku game.
3. Compile the program.
4. Execute and display the result.
5. Stop the process.
PROGRAM:
import java.io.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import java.util.*;
class easy1
{
public static JFrame f,p1;
public static JPanel f1;
JButton b1,b2,b3,b4;
JTextField
ht1,ht2,ht3,ht4,ht5,ht6,ht7,ht8,ht9,ht10,ht11,ht12,ht13,ht14,ht15,ht16,ht17,ht18,ht19,ht20,ht21,ht22,
ht23,ht24,ht25,ht26,ht27,ht28,ht29,ht30,ht31,ht32,ht33,ht34,ht35,ht36,ht37,ht38,ht39,ht40,ht41,ht4
2,ht43,ht44,ht45,ht46,ht47,ht48,ht49,ht50,ht51,ht52,ht53,ht54,ht55,ht56,ht57,ht58,ht59,ht60,ht61,ht
62,ht63,ht64,ht65,ht66,ht67,ht68,ht69,ht70,ht71,ht72,ht73,ht74,ht75,ht76,ht77,ht78,ht79,ht80,ht81;
easy1()
{
p1=new JFrame("SUDOKU");
p1.setSize(1300,1000);
p1.setVisible(true);
f1=new JPanel()
{
ImageIcon d=new ImageIcon("yy.jpg");
public void paint(Graphics g)
{
g.drawImage(d.getImage(),0,0,null,null);
super.paint(g);
}
};
p1.add(f1);
f1.setOpaque(false);
f1.setSize(1300,1000);
f1.setVisible(true);
f1.setLayout(null);
ht1=new JTextField("5");
ht1.setEditable(false);
ht1.setBackground(Color.gray);
ht1.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht1.setBounds(110,20,50,50);
f1.add(ht1);
ht2=new JTextField("1");
ht2.setEditable(false);
ht2.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht2.setBackground(Color.gray);
ht2.setBounds(160,20,50,50);
f1.add(ht2);
ht3=new JTextField();
ht3.setForeground(Color.black);
ht3.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht3.setBounds(210,20,50,50);
f1.add(ht3);
JTextField t2=new JTextField();
t2.setBounds(270,20,5,490);
t2.setBackground(Color.BLACK);
f1.add(t2);
ht4=new JTextField();
ht4.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht4.setBounds(280,20,50,50);
f1.add(ht4);
ht5=new JTextField();
ht5.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht5.setBounds(330,20,50,50);
f1.add(ht5);
ht6=new JTextField("3");
ht6.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht6.setEditable(false);
ht6.setBackground(Color.gray);
ht6.setBounds(380,20,50,50);
f1.add(ht6);
ht7=new JTextField();
ht7.setFont(new Font("MS Sans Serif",Font.BOLD,30));
JTextField t1=new JTextField();
t1.setBounds(440,20,5,490);
t1.setBackground(Color.BLACK);
f1.add(t1);
ht7.setBounds(450,20,50,50);
f1.add(ht7);
ht8=new JTextField();
ht8.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht8.setBounds(500,20,50,50);
f1.add(ht8);
ht9=new JTextField();
f1.add(ht18);
ht19=new JTextField();
ht19.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht19.setBounds(110,120,50,50);
f1.add(ht19);
ht20=new JTextField();
ht20.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht20.setBounds(160,120,50,50);
f1.add(ht20);
ht21=new JTextField();
ht21.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht21.setBounds(210,120,50,50);
f1.add(ht21);
ht22=new JTextField();
ht22.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht22.setBounds(280,120,50,50);
f1.add(ht22);
ht23=new JTextField();
ht23.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht23.setBounds(330,120,50,50);
f1.add(ht23);
ht24=new JTextField();
ht24.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht24.setBounds(380,120,50,50);
f1.add(ht24);
ht25=new JTextField("8");
ht25.setEditable(false);
ht25.setBackground(Color.gray);
ht25.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht25.setBounds(450,120,50,50);
f1.add(ht25);
ht26=new JTextField("5");
ht26.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht26.setEditable(false);
ht26.setBackground(Color.gray);
ht26.setBounds(500,120,50,50);
f1.add(ht26);
ht27=new JTextField();
ht27.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht27.setBounds(550,120,50,50);
f1.add(ht27);
JTextField t3=new JTextField();
t3.setBounds(110,180,490,5);
t3.setBackground(Color.BLACK);
f1.add(t3);
ht28=new JTextField();
ht28.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht28.setBounds(110,190,50,50);
f1.add(ht28);
ht29=new JTextField("2");
ht29.setEditable(false);
ht29.setBackground(Color.gray);
ht29.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht29.setBounds(160,190,50,50);
f1.add(ht29);
ht30=new JTextField("1");
ht30.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht30.setEditable(false);
ht30.setBackground(Color.gray);
ht30.setBounds(210,190,50,50);
f1.add(ht30);
ht31=new JTextField();
ht31.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht31.setBounds(280,190,50,50);
f1.add(ht31);
ht32=new JTextField("7");
ht32.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht32.setEditable(false);
ht32.setBackground(Color.gray);
ht32.setBounds(330,190,50,50);
f1.add(ht32);
ht33=new JTextField();
ht33.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht33.setBounds(380,190,50,50);
f1.add(ht33);
ht34=new JTextField();
ht34.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht34.setBounds(450,190,50,50);
f1.add(ht34);
ht35=new JTextField();
ht35.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht35.setBounds(500,190,50,50);
f1.add(ht35);
ht36=new JTextField();
ht36.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht36.setBounds(550,190,50,50);
f1.add(ht36);
ht37=new JTextField("9");
ht37.setEditable(false);
ht37.setBackground(Color.gray);
ht37.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht37.setBounds(110,240,50,50);
f1.add(ht37);
ht38=new JTextField();
ht38.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht38.setBounds(160,240,50,50);
f1.add(ht38);
ht39=new JTextField("4");
ht39.setEditable(false);
ht39.setBackground(Color.gray);
ht39.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht39.setBounds(210,240,50,50);
f1.add(ht39);
ht40=new JTextField();
ht40.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht40.setBounds(280,240,50,50);
f1.add(ht40);
ht41=new JTextField();
ht41.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht41.setBounds(330,240,50,50);
f1.add(ht41);
ht42=new JTextField();
ht42.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht42.setBounds(380,240,50,50);
f1.add(ht42);
ht43=new JTextField("7");
ht43.setEditable(false);
ht43.setBackground(Color.gray);
ht43.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht43.setBounds(450,240,50,50);
f1.add(ht43);
ht44=new JTextField();
ht44.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht44.setBounds(500,240,50,50);
f1.add(ht44);
ht45=new JTextField("1");
ht45.setEditable(false);
ht45.setBackground(Color.gray);
ht45.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht45.setBounds(550,240,50,50);
f1.add(ht45);
ht46=new JTextField();
ht46.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht46.setBounds(110,290,50,50);
f1.add(ht46);
ht47=new JTextField();
ht47.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht47.setBounds(160,290,50,50);
f1.add(ht47);
ht48=new JTextField();
ht48.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht48.setBounds(210,290,50,50);
f1.add(ht48);
ht49=new JTextField();
ht49.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht49.setBounds(280,290,50,50);
f1.add(ht49);
ht50=new JTextField("1");
ht50.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht50.setEditable(false);
ht50.setBackground(Color.gray);
ht50.setBounds(330,290,50,50);
f1.add(ht50);
ht51=new JTextField();
ht51.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht51.setBounds(380,290,50,50);
f1.add(ht51);
ht52=new JTextField("3");
ht52.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht52.setEditable(false);
ht52.setBackground(Color.gray);
ht52.setBounds(450,290,50,50);
f1.add(ht52);
ht53=new JTextField("2");
ht53.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht53.setEditable(false);
ht53.setBackground(Color.gray);
ht53.setBounds(500,290,50,50);
f1.add(ht53);
ht54=new JTextField();
ht54.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht54.setBounds(550,290,50,50);
f1.add(ht54);
JTextField t4=new JTextField();
t4.setBounds(110,350,490,5);
t4.setBackground(Color.BLACK);
f1.add(t4);
ht55=new JTextField();
ht55.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht55.setBounds(110,360,50,50);
f1.add(ht55);
ht56=new JTextField("4");
ht56.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht56.setEditable(false);
ht56.setBackground(Color.gray);
ht56.setBounds(160,360,50,50);
f1.add(ht56);
ht57=new JTextField("3");
ht57.setEditable(false);
ht57.setBackground(Color.gray);
ht57.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht57.setBounds(210,360,50,50);
f1.add(ht57);
ht58=new JTextField();
ht58.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht58.setBounds(280,360,50,50);
f1.add(ht58);
ht59=new JTextField();
ht59.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht59.setBounds(330,360,50,50);
f1.add(ht59);
ht60=new JTextField();
ht60.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht60.setBounds(380,360,50,50);
f1.add(ht60);
ht61=new JTextField();
ht61.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht61.setBounds(450,360,50,50);
f1.add(ht61);
ht62=new JTextField();
ht62.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht62.setBounds(500,360,50,50);
f1.add(ht62);
ht63=new JTextField();
ht63.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht63.setBounds(550,360,50,50);
f1.add(ht63);
ht64=new JTextField("1");
ht64.setEditable(false);
ht64.setBackground(Color.gray);
ht64.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht64.setBounds(110,410,50,50);
f1.add(ht64);
ht65=new JTextField();
ht65.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht65.setBounds(160,410,50,50);
f1.add(ht65);
ht66=new JTextField("5");
ht66.setEditable(false);
ht66.setBackground(Color.gray);
ht66.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht66.setBounds(210,410,50,50);
f1.add(ht66);
ht67=new JTextField("3");
ht67.setEditable(false);
ht67.setBackground(Color.gray);
f1.add(ht77);
ht78=new JTextField();
ht78.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht78.setBounds(380,460,50,50);
f1.add(ht78);
ht79=new JTextField();
ht79.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht79.setBounds(450,460,50,50);
f1.add(ht79);
ht80=new JTextField("3");
ht80.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht80.setEditable(false);
ht80.setBackground(Color.gray);
ht80.setBounds(500,460,50,50);
f1.add(ht80);
ht81=new JTextField("9");
ht81.setEditable(false);
ht81.setBackground(Color.gray);
ht81.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht81.setBounds(550,460,50,50);
f1.add(ht81);
JButton b1=new JButton("SUBMIT");
f1.add(b1);
b1.setBounds(230,590,80,40);
b1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ee)
{
try
{
if(Integer.parseInt(ht3.getText())==8 && Integer.parseInt(ht4.getText())==7 &&
Integer.parseInt(ht5.getText())==9 && Integer.parseInt(ht7.getText())==6 &&
Integer.parseInt(ht8.getText())==4 && Integer.parseInt(ht9.getText())==2
&&Integer.parseInt(ht11.getText())==3 && Integer.parseInt(ht13.getText())==8 &&
Integer.parseInt(ht14.getText())==4 && Integer.parseInt(ht17.getText())==1 &&
Integer.parseInt(ht19.getText())==4 && Integer.parseInt(ht20.getText())==7 &&
Integer.parseInt(ht21.getText())==9 && Integer.parseInt(ht22.getText())==1 &&
Integer.parseInt(ht23.getText())==6 && Integer.parseInt(ht24.getText())==2 &&
Integer.parseInt(ht27.getText())==3 && Integer.parseInt(ht28.getText())==3 &&
Integer.parseInt(ht31.getText())==5 && Integer.parseInt(ht33.getText())==8 &&
Integer.parseInt(ht34.getText())==4 && Integer.parseInt(ht35.getText())==9 &&
Integer.parseInt(ht36.getText())==6 && Integer.parseInt(ht38.getText())==5 &&
Integer.parseInt(ht40.getText())==2 && Integer.parseInt(ht41.getText())==3 &&
Integer.parseInt(ht42.getText())==6 && Integer.parseInt(ht44.getText())==8 &&
Integer.parseInt(ht46.getText())==8 && Integer.parseInt(ht47.getText())==6 &&
Integer.parseInt(ht48.getText())==7 && Integer.parseInt(ht49.getText())==4 &&
Integer.parseInt(ht51.getText())==9 && Integer.parseInt(ht54.getText())==5 &&
}
});
JButton b3=new JButton("CANCEL");
f1.add(b3);
b3.setBounds(430,590,80,40);
b3.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
p1.dispose();
}
});
}
public static void main(String aa[])
{
new easy1();
}
}
OUTPUT: