Sie sind auf Seite 1von 39

MKCE/MCA

Subject Code/Name: PCA1250P/Middleware Technology Lab


Batch: 2014-2017
Staff In-Charge: N.Anitha
Year/Sem : III/V
LAB MANUAL
Ex.No:1

CLIENT/SERVER COMMUNICATION

AIM:
To create a java program to investigate client server communication.
ALGORITHM:
1.
2.
3.
4.
5.
6.

Start the process.


Create the client and server program.
Compile the client and server program.
Execute the client and server program.
Display the result.
Stop the process.

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();

System.out.println("Accepted a connection from: "+


client.getInetAddress());
Connect c = new Connect(client);
} catch(Exception e) {}
}
}
}
class Connect extends Thread {
private Socket client = null;
private ObjectInputStream ois = null;
private ObjectOutputStream oos = null;
public Connect() {}
public Connect(Socket clientSocket) {
client = clientSocket;
try {
ois = new ObjectInputStream(client.getInputStream());
oos = new ObjectOutputStream(client.getOutputStream());
} catch(Exception e1) {
try {
client.close();
}catch(Exception e) {
System.out.println(e.getMessage());
}
return;
}
this.start();
}
public void run() {
try {
oos.writeObject(new Date());
oos.flush();
// close streams and connections
ois.close();
oos.close();
client.close();
} catch(Exception e) {}
}
}
//DateClient.java
import java.io.*;
import java.net.*;
import java.util.*;

public class DateClient {


public static void main(String argv[]) {
ObjectOutputStream oos = null;
ObjectInputStream ois = null;
Socket socket = null;
Date date = null;
try {
// open a socket connection
socket = new Socket("localhost", 3000);
// open I/O streams for objects
oos = new ObjectOutputStream(socket.getOutputStream());
ois = new ObjectInputStream(socket.getInputStream());
// read an object from the server
date = (Date) ois.readObject();
System.out.print("The date is: " + date);
oos.close();
ois.close();
} catch(Exception e) {
System.out.println(e.getMessage());
}
}
}
OUTPUT:
//DateClient:
C:\Documents and Settings\MCA-HOD>d:
D:\>d:
D:\>set path=C:\Program Files\Java\jdk1.5.0_06\bin;
D:\>set classpath=.;
D:\>javac DateClient.java
D:\>java DateClient
The date is: Thu Jun 20 11:21:50 IST 2013
D:\>
//DateServer:
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 DateServer.java
D:\>java DateServer
Server listening on port 3000.
Waiting for connections.
Accepted a connection from: /127.0.0.1

Ex.No.:2

FILE TRANSFER PROTOCOL

AIM:
To create a java program for file transfer using FTP socket.
ALGORITHM:
1.
2.
3.
4.
5.
6.
7.
8.
9.

Start the process.


Declare the required class as ftpserver.
ftpclass for establishing the connection.
Object serverw and serverc for creating the server socket and accept the connection.
Read the file by using reeadLine().
Create the class ftpclient and get the localhost with address.
Write the file by using writeLine().
Read and write the data in BufferredReader().
Stop the process.

//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

ADDITION USING RMI

AIM:
To create a java program to perform addition using RMI
ALGORITHM:
1.
2.
3.
4.
5.
6.
7.
8.

Start the process.


Declare the add() method in the interface calculator.
Implement the calculator and define the Super().
Method definition for addition and return the value.
Lookup the server from client based on the object.
Call the add(), with parameter by using object.
Bind the server with remote object.
Stop the process.

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

FILE COPYING USING RMI

AIM:
To create java program for copying file using Remote Method Invocation.
ALGORITHM:
1.
2.
3.
4.

Start the process.


Create interface that extends Remote class.
Create another program that implements the interface.
Create fileserver and fileclient program.
5. Compile four java programs.
6. Using rmic create the skeleton and stub class.
7. Start the rmiregistry.
8. Execute the client and server program.
9. Display the result.
10. Stop the process.
PROGRAM:
//fileface.java
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface fileface extends Remote
{
public byte[] downloadfile(String filename)throws RemoteException;
}
//fileimp.java
import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
public class fileimp extends UnicastRemoteObject implements fileface
{
private String name;
public fileimp(String s)throws RemoteException
{
super( );
name=s;
}
public byte[] downloadfile(String filename) // function to read the source file
{
try
{

File file=new File(filename);


byte buffer[]=new byte[(int)file.length()];
BufferedInputStream input=new BufferedInputStream(new
FileInputStream(filename));
input.read(buffer,0,buffer.length);
input.close();
return(buffer);
}
catch(Exception e)
{
System.out.println("fileimp"+e.getMessage());
e.printStackTrace( );
return(null);
}
}
}
//fileclient.java
import java.io.*;
import java. rmi.*;
public class fileclient
{
public static void main(String args[])
{
if(args.length!=2)
{
System.out.println("usage:javafileclient filename, machinename");
System.exit(0);
}
try
{
String name="rmi://"+args[1]+"/fileserver";
fileface f=(fileface)Naming.lookup(name); //interface
byte[] filedata=f.downloadfile(args[0]);
System.out.println("enter the new name to file");
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
String newname=br.readLine();
File file=new File(newname);
BufferedOutputStream output=new BufferedOutputStream(new
FileOutputStream(file.getName()));
output.write(filedata,0,filedata.length); // file copying
System.out.println("File copied");
output.flush();
output.close();
}
catch(Exception e)
{

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

PRIME NUMBER USING RMI

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.*;

public class Srvprime extends UnicastRemoteObject implements Ifprime


{
int i;
boolean test=true;
public Srvprime () throws RemoteException {;}
public String Checkprime (int gn)
{
for (i=2;i<gn;i++)
if (gn%i==0)
return gn+ "is not a prime number";
return gn + "is a prime number";
}
public static void main (String args [])
{
try {
Srvprime svp=new Srvprime ();
Naming.bind ("Srvprime", svp);
System.out.println ("Server is bound");
} catch (Exception e)
{
System.out.println (Error in connection");
}
System.out.println (Server End");
}
}
OUTPUT:

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

CHAT ROOM APPLICATION

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 {

// Create a thread to read from the server


new Thread(new MultiThreadChatClient()).start();
while (!closed) {
os.println(inputLine.readLine());
}
os.close();
is.close();
clientSocket.close();
} catch (IOException e) {
System.err.println("IOException: " + e);
}
}
}
public void run() {
String responseLine;
try{
while ((responseLine = is.readLine()) != null) {
System.out.println(responseLine);
if (responseLine.indexOf("*** Bye") != -1) break;
}
closed=true;
} catch (IOException e) {
System.err.println("IOException: " + e);
}
}
}
//Server:
import java.io.*;
import java.net.*;
public class MultiThreadChatServer{
static Socket clientSocket = null;
static ServerSocket serverSocket = null;
// This chat server can accept up to 10 clients' connections
static clientThread t[] = new clientThread[10];
public static void main(String args[]) {
// The default port
int port_number=2222;

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

Enter your name.


anitha
Hello anitha to our chat room.
To leave enter /quit in a new line
<Kumar>
hi
< Kumar > hi
*** A new user Arun entered the chat room !!! ***
<hello> hello
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:\>javac MultiThreadChatClient1.java
Note: MultiThreadChatClient1.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
D:\>java MultiThreadChatClient1
Usage: java MultiThreadChatClient1
Now using host=localhost, port_number=2222
Enter your name.
*** A new user Kumar entered the chat room !!! ***
< Kumar >
< Kumar > hi
Arun
Hello Arun to our chat room.
To leave enter /quit in a new line
hello
< Arun> hello
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 MultiThreadChatServer.java
Note: MultiThreadChatServer.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
D:\>java MultiThreadChatServer
Usage: java MultiThreadChatServer
Now using port number=2222

Ex.No.:8

STUDENT DETAILS USING WEB APPLICATION

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;
}

protected void Button5_Click(object sender, EventArgs e)


{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
}
}
OUTPUT:

Ex.No. 9

DESIGNING OF E-BUSINESS

AIM:
To create a java swing program for currency conversion.
ALGORITHM:
1.
2.
3.
4.
5.

Start the process.


Create the swing program for currency conversion.
Compile the program.
Execute and display the result.
Stop the process.

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();

ht9.setFont(new Font("MS Sans Serif",Font.BOLD,30));


ht9.setBounds(550,20,50,50);
f1.add(ht9);
ht10=new JTextField("2");
ht10.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht10.setEditable(false);
ht10.setBackground(Color.gray);
ht10.setBounds(110,70,50,50);
f1.add(ht10);
ht11=new JTextField();
ht11.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht11.setBounds(160,70,50,50);
f1.add(ht11);
ht12=new JTextField("6");
ht12.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht12.setEditable(false);
ht12.setBackground(Color.gray);
ht12.setBounds(210,70,50,50);
f1.add(ht12);
ht13=new JTextField();
ht13.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht13.setBounds(280,70,50,50);
f1.add(ht13);
ht14=new JTextField();
ht14.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht14.setBounds(330,70,50,50);
f1.add(ht14);
ht15=new JTextField("5");
ht15.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht15.setEditable(false);
ht15.setBackground(Color.gray);
ht15.setBounds(380,70,50,50);
f1.add(ht15);
ht16=new JTextField("9");
ht16.setEditable(false);
ht16.setBackground(Color.gray);
ht16.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht16.setBounds(450,70,50,50);
f1.add(ht16);
ht17=new JTextField();
ht17.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht17.setBounds(500,70,50,50);
f1.add(ht17);
ht18=new JTextField("7");
ht18.setEditable(false);
ht18.setBackground(Color.gray);
ht18.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht18.setBounds(550,70,50,50);

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);

ht67.setFont(new Font("MS Sans Serif",Font.BOLD,30));


ht67.setBounds(280,410,50,50);
f1.add(ht67);
ht68=new JTextField();
ht68.setBounds(330,410,50,50);
ht68.setFont(new Font("MS Sans Serif",Font.BOLD,30));
f1.add(ht68);
ht69=new JTextField();
ht69.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht69.setBounds(380,410,50,50);
f1.add(ht69);
ht70=new JTextField("2");
ht70.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht70.setEditable(false);
ht70.setBackground(Color.gray);
ht70.setBounds(450,410,50,50);
f1.add(ht70);
ht71=new JTextField();
ht71.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht71.setBounds(500,410,50,50);
f1.add(ht71);
ht72=new JTextField("4");
ht72.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht72.setEditable(false);
ht72.setBackground(Color.gray);
ht72.setBounds(550,410,50,50);
f1.add(ht72);
ht73=new JTextField();
ht73.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht73.setBounds(110,460,50,50);
f1.add(ht73);
ht74=new JTextField();
ht74.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht74.setBounds(160,460,50,50);
f1.add(ht74);
ht75=new JTextField();
ht75.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht75.setBounds(210,460,50,50);
f1.add(ht75);
ht76=new JTextField("6");
ht76.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht76.setEditable(false);
ht76.setBackground(Color.gray);
ht76.setBounds(280,460,50,50);
f1.add(ht76);
ht77=new JTextField();
ht77.setFont(new Font("MS Sans Serif",Font.BOLD,30));
ht77.setBounds(330,460,50,50);

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 &&

Integer.parseInt(ht55.getText())==6 && Integer.parseInt(ht58.getText())==9&&


Integer.parseInt(ht59.getText())==2 && Integer.parseInt(ht60.getText())==1 &&
Integer.parseInt(ht61.getText())==5 && Integer.parseInt(ht62.getText())==7 &&
Integer.parseInt(ht63.getText())==8 && Integer.parseInt(ht65.getText())==9 &&
Integer.parseInt(ht68.getText())==8 && Integer.parseInt(ht69.getText())==7 &&
Integer.parseInt(ht71.getText())==6 && Integer.parseInt(ht73.getText())==7 &&
Integer.parseInt(ht74.getText())==8 && Integer.parseInt(ht75.getText())==2 &&
Integer.parseInt(ht77.getText())==5 && Integer.parseInt(ht78.getText())==4 &&
Integer.parseInt(ht79.getText())==1)
{
JFrame ff=new JFrame("THANKYOU");
ff.setSize(550,500);
ff.setVisible(true);
JPanel pp=new JPanel()
{
ImageIcon d=new ImageIcon("su.jpg");
public void paint(Graphics g)
{
g.drawImage(d.getImage(),0,0,null,null);
super.paint(g);
}
};
ff.add(pp);
pp.setOpaque(false);
pp.setSize(550,500);
pp.setVisible(true);
pp.setLayout(null);
}
else
{
JOptionPane.showMessageDialog(p1,"SORRY.... VERIFY YOUR ANSWER");
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(p1,"PLEASE FILL ALL NUMBERS");
}
}
});
JButton b2=new JButton("RESET");
f1.add(b2);
b2.setBounds(330,590,80,40);
b2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
p1.dispose();
new easy1();

}
});
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:

Das könnte Ihnen auch gefallen