Posts

Showing posts from January, 2013

Oracle Database Connection in GUI Application

Image
Write the following code in a java file named "insertDemo.java" import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; public class insertData extends JFrame implements ActionListener  {      JTextField name,addr,sal;      JLabel n,a,s;      JButton ins,canc,clr;     insertData()      {        setLayout(null);           name=new JTextField(15);         addr=new JTextField(15);        sal=new JTextField(15);        n=new JLabel("Enter Employee Name :");        a=new JLabel("Enter Employee Address :");        s=new JLabel("Enter Employee Salary :");        ins=new JButton("Insert");        canc=new JButton("Close");        clr=new JButton("Clear"); ...

Applet Progarm with Combo box, radio button,Check box

Image
Step 1 : Create a source file named "testapp2.java". Step 2: Write the following code with applet tag. import java.applet.*; import java.awt.*; import java.awt.event.*; /* <APPLET CODE="testapp2" HEIGHT =240  WIDTH=370 > </APPLET> */ public class testapp2 extends Applet implements ActionListener,ItemListener {     Label l1,l2,l3,l4;     Button ok,cancel;     TextField n1,n2;     Choice ch,colorchoice;     Color clr;     Checkbox cb1,cb2,cb3,cb4;     CheckboxGroup cgroup;     public void init()      {        clr=new Color(219,240,251);       setBackground(clr);       setLayout(null);       cgroup=new CheckboxGroup();        cb1=new Checkbox("ADD",true,cgroup);        cb2=new Checkbox("SUBTRACT",false,cgroup);        cb3=new ...

Creating and Running Applet with AWT Components

Image
Step 1: Create a Source file named "testapp.java" Step 2: Write the following code. import java.applet.*; import java.awt.*; import java.awt.event.*; /*   <applet code="testapp" height=140 width=320 align="center">  </applet> */ public class testapp extends Applet implements ActionListener {     Label l1,l2,l3,l4;     Button ok,cancel;     TextField name,add;     public void init()      {         setBackground(new Color(219,240,251));         setLayout(null);        name=new TextField(15);       add=new TextField(15);              l1=new Label("Enter Your Name:");        l1.setBounds(5,10,130,30);        name.setBounds(150,10,130,20);        l2=new Label("Enter Your Address:");        l2.set...

HOW TO CREATE AND RUN APPLET PROGRAMS

Image
Step 1 - Create Source code ( . java ) file Step 2:  Write the following code.. import java.awt.*; import java.awt.event.*; import java.applet.*; /*    <applet code="testapp" width=450 height=350 >     // Define class file to be load and                                                                                                          applet window size   <param name="p1" value="Hello! SABAB" >     // Passing parameter to applet   </applet> */ public class testapp extends Applet implements MouseMotionListener {    int x[]={213,280,148,300,180,213};     // Setting X coordinates of points to draw Polygon  ...

File Transfer via LAN using JAVA

Image
Step 1-   Create java source file named "fileSender.java" import java.net.*; import java.io.*; class fileSender {     public static void main(String arg[])throws IOException       {          DataInputStream dis=new DataInputStream(System.in);  // For Keyboard Input          DatagramSocket dgsocket=new DatagramSocket();          DatagramPacket datapack;          InetAddress destination;         System.out.print("Enter Machine IP Address / Name :  ");   //  IP Address of Host (Receiver)         String ipadd=dis.readLine();         destination=InetAddress.getByName(ipadd);         System.out.print("Enter file name or path to be send :  ");         String filepath=dis.readLine();         String file...

Program for Text Chatting via LAN using JAVA

Step 1: Create Server Program /**********Code to create Server Machine program.***************/ import java.net.*; import java.io.*; public class server {    public static void main(String arg[]) throws IOException           {             DataInputStream dis=new DataInputStream(System.in); // To read Data from Keyboard            ServerSocket serv=new ServerSocket(1212);            Socket sc=serv.accept();            InetAddress cMachine=sc.getInetAddress();            PrintStream out=new PrintStream(sc.getOutputStream());            DataInputStream in=new DataInputStream(sc.getInputStream());                          while(true)          {         ...