Tuesday, 25 June 2013

java project

Working on a interesting java project airport management  send me suggestions to make it better
so recently ive been working on swings and they are really intresting so ill be uploading them tomorrow as soon as possible

Sunday, 23 June 2013

applets animation

hi guys i could'nt post gor last few days bcoz i was busy in a project so moving on
in previous one i told you about applets today i'll be telling you how you can perform basic level animation
it is done with the help of threads
threads are something required for
1-stop any function during execution time
2-decide speed for animation
3-suspend the programme
4-resume the programme
and many more but in this one we'll be using simple methods
Just run this programme and what it does
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
import java.awt.*;
import java.applet.*;
public class gui extends Applet
{
Thread t=null;
int i;

public void paint(Graphics g)
{

g.drawOval(200,200,10,10);
g.drawOval(175,170,100,100);
g.drawOval(241,200,10,10);
g.drawArc(219,200,10,25,200,142);

g.drawArc(200,200,50,50,200,140);
try{

for(i=0;i<10;i++)
{
repaint();
t.sleep(50);
g.drawOval(220,250,10,i);
}


for(i=220;i<233;i+=2)
{
repaint();
t.sleep(50);
g.drawLine(i,223,i,230);

}}
catch(InterruptedException ab)
{
}
}
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

create itscorresponding HTML file and run it
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
<html>
<body>
<applet code = "gui.class",width="500",height="500"></applet>
</body>
</html>
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

Thursday, 20 June 2013

applet example

1-A simple example for how to use applets
this programme takes user input
name
date of birth
address
METHODS IN THE PROGRAMME
{
1-String a = JOptionPane.showInputDialog("enter your name");
IT IS USED TO DISPLAY AN INPUT DIALOGUE BOX ON SCREEN
2-g.drawString("name is", 25, 30);
IT IS A FUNCTION USED TO DISPLAY ON THE SCREEN 25,30 DECIDE THE
POSITION OF RESULT ON PAGE
}
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
import java.awt.*;

public class apl  extends Applet{
String a,b,c;
public void init(){
 a = JOptionPane.showInputDialog("enter your name");
 b=JOptionPane.showInputDialog("enter your dob");
 c=JOptionPane.showInputDialog("enter your address");

}
public void paint(Graphics g)
{

g.drawString("name is"+a, 25, 30);
g.drawString("dob is"+b, 45, 30);
g.drawString("address is"+c, 65, 30);
}
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

2----save this file as" .html" file anr run it it will automatically inherit the class
now only java can not run a applet so you need to know a bit of html
<HTML>
<body>
<applet code="usr.class",width="500",height="500">
</applet>
</body>
</HTML>



html for applet

Creating an html programme to use applet


<HTML>
<Body>
<applet code="apl.class",width="500",height="500">
</applet>
</Body>
</HTML>

apl.class------------------- is the name of your class in the programme of java
width="500",height="500"--define the height and width of output

Applets intro

Guess what recently ive been working on java applets and it is some really cool stuff
So for the introduction part there are a few things you should keep in mind while
working with applets
1-import java.awt.*; package for appletsdont forget to import it
2-public class apl  extends Applet
here apl is name of your class and Applet is a inbuilt class
3-public void init()
this is also inbuilt method used for declairing every data type or what attributes the programme is going to have
4-public void paint(Graphics g)
this is also an inbuilt function used for printing things on screen
------------------------------------------------------------------------------------------------------------
These things would be more clear in our next post

Monday, 17 June 2013

Introduction to treads

I came across some intresting things like threads where you can perform more than one task at a time
There are many methods you can apply on threads but in this one i'll be showing you how to create a thread and how to run it
1- in this example we can se how threads can  be used it is a inbuilt class and we inherit it by using extends key word .Run is a function we dont need to call it it is automatically called
and we use our first function START used to start execution of thread making objects and calling are same

Saturday, 15 June 2013

Exception handling

started with new topic exception handling here is a simple example to start with
it is a division programme that divides two numbers and if denominator is 0 it shows error if catch exception is not there
1-
import java.io.*;
class se{
public static void main(String arg[])
{
DataInputStream dis=new DataInputStream(System.in);


try{
int a,b;
a=Integer.parseInt(dis.readLine());
b=Integer.parseInt(dis.readLine());
int c=a/b;
System.out.println(""+c);
}

catch(Exception e)
{
System.out.println("you cant do that");
}
}
}