Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Friday 29 June 2012

java program to display labels using applet

import java.awt.*;
import java.applet.Applet;

/* <applet code="lables" width=200 height=300>
   </applet>
*/

public class lables extends Applet
{
      public void init()
      {

java program to draw human face using applet

import java.applet.*;
import java.awt.*;
      /* <applet code ="humanface" width=600 height=600>
        </applet>  */

  public class humanface extends Applet
    {
     public void paint(Graphics g)
       {

java program to display checkbox using applet

import java.awt.*;
import java.applet.Applet;

/* <applet code="checkboxes" width=200 height=300 >
   </applet>
*/

public class checkboxes extends Applet
{
      Checkbox cb;
      public void init()
      {

java program to read no, name, sex and percentage and display grade.

import java.io.*;
class student
  {
       public static void main(String args[]) throws IOException
        {
          int rno;
          String name,sex,grade;
          double percentage;
          BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
          String in;

Wednesday 27 June 2012

java program in which we create array of object to desribes emplyee information.

import java.io.*;
class Emp
{
    int id[];
    String name[];
    int bs[];
    Emp(int id[],String name[],int bs[])
    {
        this.id=id;
        this.name=name;
        this.bs=bs;
    }

java program to create and maintian circular linked list.

import java.io.*;
class Node
{    private Node next,prev;
    private int data;
    public Node(int data)
    {    this.data=data;
        next=null;
    }
   
    public void setNext(Node next)
    {
        this.next=next;
    }

java program that performed various bitwise operations.

import java.io.*;

class Bitwise
{
    public static void main(String args[])
    {
    byte a=4,b=10,c;

    c=(byte)    (a&b);
   
    System.out.println("Bitwise and is:"+ c);
   
    c=(byte)     (a|b);
    System.out.println("Bitwise or is:"+ c);
   

java program that used finalized method.

class test
{
   int n;
   test()
    {
      n=0;
    }
    test( int pn)
      {
         n = pn;
      }
    void display()
    {

          System.out.println("\n n = "+n);
    }
     protected void finalize()
    {
        System.out.println("\n releasing memory...!");
    }
}

Tuesday 26 June 2012

java program to display clock (with current time) using applet.


import java.util.*;
import java.awt.*;
import java.applet.*;
import java.text.*;
/*
 <applet code = "Clock" width=300 height=100>
 </applet>
 */
public class Clock extends Applet implements Runnable {
    Thread timer;                // The thread that displays clock
    int lastxs, lastys, lastxm,
        lastym, lastxh, lastyh;  // Dimensions used to draw hands
    SimpleDateFormat formatter;  // Formats the date displayed
    String lastdate;             // String to hold date displayed
    Font clockFaceFont;          // Font for number display on clock
    Date currentDate;            // Used to get date to display
    Color handColor;             // Color of main hands and dial
    Color numberColor;           // Color of second hand and numbers

    public void init() {
        int x,y;
        lastxs = lastys = lastxm = lastym = lastxh = lastyh = 0;
        formatter = new SimpleDateFormat ("EEE MMM dd hh:mm:ss yyyy", Locale.getDefault());
        currentDate = new Date();
        lastdate = formatter.format(currentDate);
        clockFaceFont = new Font("Serif", Font.PLAIN, 14);
        handColor = Color.blue;
        numberColor = Color.darkGray;

Sunday 24 June 2012

java program to draw a swastik in applet

import java.applet.*;
import java.awt.*;
 /* <applet code ="Swastik" width=600 height=600>
    </applet>  */

  public class Swastik extends Applet
    {
     public void paint(Graphics g)
       {
        g.setColor(Color.yellow);
        g.drawOval(40,40,120,150);
        g.setColor(Color.cyan);
        g.drawArc(92,40,13,40,180,180);
        g.fillOval(68,81,10,10);
      

java program to rotate a string(Banner) in applet.

import java.awt.*;
import java.applet.*;

/* <applet code="banner" width=300 height=200>
   </applet> */

 public class banner extends Applet import java.awt.*;
import java.applet.*;

/* <applet code="banner" width=300 height=200>
   </applet> */

 public class banner extends Applet implements Runnable 
   {
     Font f;
    String mgs="welcome to applet programming language...";
    Thread t=null;
    int state;

Saturday 23 June 2012

java program to describe use of Generic class.

 class GenericClass1<T1,T2> // Parameter T1 and T2 must be unique
{
    private T1 t1;
    private T2 t2;
    private T1[] t3;//= new T1[12]; will give error: generic array creation

        public void addDataT1(T1 t1) {
            this.t1 = t1;
       }

    public T1 getDataT1() {
            return t1;
        }

java program of Wrapper class.

class WrapperClass{
    private  Object  object;
        public void add(Object object) {
            this.object = object;
        }
        public Object get() {
            return object;
        }
    }

java program that describes various operation on Vector.

import java.util.*;
import java.io.*;
class VectorDemo2
{
     public static void main(String args[])
     {
    Vector<Integer> v = new Vector<Integer>();
    System.out.println("Initial size: " + v.size());
    System.out.println("Initial capacity: " + v.capacity());
   
    v.addElement(new Integer(1));
    v.addElement(new Integer(2));
    v.addElement(new Integer(3));    
    v.addElement(new Integer(4));

java program of Doubly Linked List.

import java.io.*;
class Node
{
    private Node next,prev;
    private int data;
    public Node(int data)
    {
        this.data=data;
        next=null;
        prev=null;       
    }

java program to maintain stack using java.util.Stack class.

import java.io.*;
import java.util.*;
class StackArray
{
    Stack s=new Stack();
    public void push(int i) throws Exception
    {
        s.push(new Integer(i));
       
    }

java program to maintain Singly Linked List.

import java.io.*;
class Node
{
    private Node next;
    private int data;

    public Node(int data)
    {
        this.data=data;
        next=null;
    }

java program of taking input from user using BufferedReader.

import java.io.*;

class InputFromUser
{
   public static void main(String args[]) throws IOException
   {
    
      String a;
      System.out.println("Enter a number");

java program of Inheritence example(Dyanmic dispatch).

import java.io.*;
abstract class c1
{
    int i;
    c1()
    {
        i=10;
    }
    void myMehtod()
    {
        System.out.println("class c1");
    }
}

java program for passing object as argument.

import java.io.*;
class MyDate
{
    int d,m,y;
    String ds;
    MyDate(int d,int m,int y)
    {
        this.d=d;
        this.m=m;
        this.y=y;
   
    }