Monday, March 31, 2014

Windows XP : End of the Road

Everyone seems alarmed that, as of April 8, Microsoft no longer will provide technical support for Windows XP. The company has been trying to kill off its old but still widely used operating system for several years now.
Consider, for example, that since 2011, updated versions of Microsoft's Internet Explorer browser have not worked on Windows XP. And if you're running XP on your computer, you won't be able to run the latest versions of Microsoft Office.
The real problem (for Microsoft) is not that Windows XP is three generations old, having been succeeded by Vista, Windows 7 and now Windows 8. It's that despite the company's best efforts to bump it off, XP is still the OS on nearly one-third of all Windows computers. And the refusal of users to abandon it is hurting sales of Windows 8.

In pulling the plug on Windows XP, Microsoft strongly implied that users should either upgrade to Windows 8 or buy a new computer (with Windows 8 on it). The company said that sticking with XP after technical support is withdrawn could leave computers vulnerable to security risks and viruses, and that users can expect to encounter more apps and devices that won't work with XP. 
You don't need Microsoft for technical support. You can protect your computer with a good antivirus program, like the free versions of Kaspersky, Avast and AVG. And don't worry about apps and devices. Most software is available now in the cloud - making it compatible with any operating system - and most printers, routers and other devices you're likely to need will work with XP. Interestingly, other browsers (apart from Microsoft’s Internet Explorer), including Mozilla Firefox and Google Chrome, work fine with XP, as do free office software such as OpenOffice and LibreOffice. So moreover, till now you may consider it as a strategy by Microsoft to bring back its falling Windows 8 OS on track. 
The danger in sticking with XP is not that compatibility will be hard. It is that there will be no more security patches from Microsoft. No more patches means that if there is a remote exploit that can allow someone to gain administrator access to your system, no fix for you. Your system joins a botnet. There have been multitudes of these exploits over XP's lifespan and there is no reason to doubt that there are some exploits that are known and not yet reported, held back until this end of support. Antivirus is not going to save you. 



Conclusion: 
Get a Mac, Get Windows 7 or Get Linux. If you want to poke your eye with a sharp object, get Windows 8. But please do not stick with XP if you are in any way connected to the Internet. Botnets built out of compromised XP systems are one of the reasons why we can't have nice things.

Also Suggested : The end of Windows XP is also the end of everything we thought we knew about computing

Sunday, March 30, 2014

Change random image,background and font using Java Applet


import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.Random;
/*<applet code=app1 width=300 height=300></applet>*/
public class app1 extends Applet implements ActionListener{
                Button b1,b2,b3;
                boolean a,b,c;
                Random r = new Random();
                Image img[] = new Image[3];
                static int z=0;
                static int m=0;
                Font f[] = new Font[2];
                public void init(){
                                setBackground(Color.blue);
                                b1=new Button("change bg");
                                b2=new Button("change img");
                                b3=new Button("change font");
                               
                                 b1.addActionListener(this);
                                 b2.addActionListener(this);
                                 b3.addActionListener(this);
                                add(b1);
                                add(b2);
                                add(b3);
                                String str;
                               
                                img[0] = getImage(getDocumentBase(),"1.jpg");
                                img[1] = getImage(getDocumentBase(),"2.jpg");
                                img[2] = getImage(getDocumentBase(),"3.jpg");

                                f[0]= new Font("Impact",Font.PLAIN,14);
                                f[1]= new Font("Dialog",Font.PLAIN,24);

                        }
                public void paint(Graphics g){
                                                b1.setFont(f[m]);
                                                b2.setFont(f[m]);
                                                b3.setFont(f[m]);
                                g.drawImage(img[z],20,20,200,200,this);
                                if(a==true){
                                                Color c[] = {Color.red,Color.blue,Color.orange,Color.black,Color.pink};
                                                int k = r.nextInt(5);
                                                setBackground(c[k]);
                                        }
                                if(b==true){
                                               
                                                z=r.nextInt(3);
                                                g.drawImage(img[z],20,20,200,200,this);
                                        }
                                if(c==true){
                                                m=r.nextInt(2);
                                                b1.setFont(f[m]);
                                                b2.setFont(f[m]);
                                                b3.setFont(f[m]);

                                        }

                        }
                public void actionPerformed(ActionEvent e){
                                if(e.getSource()==b1){
                                        b=false;
                                        a=true;
                                        c=false;
                                        repaint();
                                }
                                if(e.getSource()==b2){
                                                                        a=false;
                                                                        b=true;
                                                                        c=false;
                                                                        repaint();
                                }
                                if(e.getSource()==b3){
                                                a=false;
                                                b=false;
                                                c=true;
                                                repaint();
                                        }
                        }
        }



// OUTPUT

Tuesday, March 25, 2014

Colorful Bouncing Ball using Java applet





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

/*<applet code="bb" width=500 height=400></applet>*/

public class bb extends Applet implements Runnable {
  int x,y,dx,dy,diam,sizex,sizey;

  public void init() {

    sizex=Integer.parseInt(getParameter("WIDTH"));
    sizey=Integer.parseInt(getParameter("HEIGHT"));

    x=(int)(Math.random()*1000)%sizex;
    y=(int)(Math.random()*1000)%sizey;

    dx=dy=5; diam=20;

setBackground(Color.black);
   (new Thread(bb.this)).start();

  }

  public void run() {
    while (true) {
      try {
        Thread.sleep(50);
      }
      catch (InterruptedException e) {};

      x+=dx; y+=dy;
      if ((x<=0)||(x+dx+diam>=sizex))
      dx=-dx;
      if ((y<=0)||(y+dy+diam>=sizey))
      dy=-dy;

      repaint();
    }
  }

  public void paint(Graphics g) {

    g.setColor(new Color((int)(Math.random()*1000)%254,(int)(Math.random()*1000)%254,(int)(Math.random()*1000)%254));
g.fillOval(x,y,diam,diam);

  }
}

Monday, March 24, 2014

Twinkling Stars using Java Applet



import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
/*<applet code="Star" width=600 height=600></applet>*/
public class Star extends Applet implements ActionListener,Runnable
{
Thread t;
Button b1,b2,b3,b4;
TextField tf1,tf2;
Label l1,l2;
Font f;
public void init()
{
setBackground(Color.black);
l1= new Label("speed");
l2 =new Label("No. of stars");
f=new Font("Arial",Font.BOLD,20);
l1.setFont(f);
l2.setFont(f);
l1.setBackground(Color.white);
l2.setBackground(Color.white);
tf1= new TextField(6);
tf1.setFont(f);
tf2 = new  TextField(6);
tf2.setFont(f);
b1 = new Button("start");
b2 = new Button("kill");
b3 = new Button("pause");
b4 = new Button("Resume");
b1.setFont(f);
b2.setFont(f);
b3.setFont(f);
b4.setFont(f);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
add(l1);
add(l2);
add(tf1);
add(tf2);
add(b1);
add(b2);
add(b3);
add(b4);
}
public void actionPerformed(ActionEvent ae)
{
if((ae.getSource()==b1)&&(t==null))
{
t = new Thread(this);
t.start();
}
else if((ae.getSource()==b2)&&(t!=null))
{
t.stop();
t=null;
}
else if((ae.getSource()==b3)&&(t!=null))
{
t.suspend();
}
else if((ae.getSource()==b4)&&(t!=null))
{
t.resume();
}
}
public void run()
{
while(true)
{
repaint();
try{
Thread.sleep(Long.parseLong(tf1.getText()));
  }catch(InterruptedException ie)
  {
}
}
}
public void paint(Graphics g)
{
for(int i=0;i<Integer.parseInt(tf2.getText());i++)
{
g.setColor(new Color(((int)(Math.random()*1000))%254,((int)(Math.random()*1000))%254,((int)(Math.random()*1000))%254));

star(g,((int)(Math.random()*1000))%600,((int)(Math.random()*1000))%600);
}
}
static void star(Graphics g,int x,int y){
Point[] points = new Point[9];
points[0] = new Point(28+x, 5+y);
points[1] = new Point(27+x, 21+y);
points[2] = new Point(13+x, 24+y);
points[3] = new Point(27+x, 27+y);
points[4] = new Point(28+x, 41+y);
points[5] = new Point(31+x, 27+y);
points[6] = new Point(42+x, 24+y);
points[7] = new Point(31+x, 21+y);
points[8] = new Point(28+x, 5+y);
int i;
for (i=1; i<points.length; i++)
g.drawLine(points[i-1].x, points[i-1].y, points[i].x, points[i].y);
}

}


simple calculator using java applet

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class calc extends Applet implements ActionListener
{
Label l1,l2,l3;
TextField t1,t2,t3;
Button add1,sub,mult,div;
public void init()
{
l1=new Label("first no.:");
add(l1);



t1=new TextField(10);
add(t1);

l2=new Label("2nd no.:");
add(l2);

t2=new TextField(10);
add(t2);

l3=new Label("Result:");
add(l3);


t3=new TextField(10);
add(t3);


add1=new Button("+");
add(add1);
add1.addActionListener(this);


sub=new Button("-");
add(sub);
sub.addActionListener(this);

mult=new Button("*");
add(mult);
mult.addActionListener(this);

div=new Button("/");
add(div);
div.addActionListener(this);


}

public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==add1)
{
int sum=Integer.parseInt(t1.getText()) + Integer.parseInt(t2.getText());
t3.setText(String.valueOf(sum));
}

if(ae.getSource()==sub)
{
int sub=Integer.parseInt(t1.getText()) - Integer.parseInt(t2.getText());
t3.setText(String.valueOf(sub));
}


if(ae.getSource()==mult)
{
int mul=Integer.parseInt(t1.getText()) * Integer.parseInt(t2.getText());
t3.setText(String.valueOf(mul));
}


if(ae.getSource()==div)
{
int div=Integer.parseInt(t1.getText()) / Integer.parseInt(t2.getText());
t3.setText(String.valueOf(div));
}

}

}
/*
<applet code="calc" width=200 height=200>
</applet>
*/


Monday, March 10, 2014

Anonymous class in Java

//Anonymous class
class outer{
int x=80;
public void display(){
System.out.println("i am in outer class ");
}
}
class inner{
int y=60;

outer out=new outer(){
public void display(){
System.out.println("i am in inner class "+x);
System.out.println("i am in outer class "+y);
}
};
}
class inmain{
public static void main(String arg[]){
inner in=new inner();
in.out.display();

}
}

OUTPUT

Java program to copy one directory filres to another directory

import java.io.*;
class dirfile{

      public static void main(String arg[])throws IOException{
  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  System.out.println("entre the location ");
  String s1=br.readLine();
  System.out.println("entre the  new location ");
  String s2=br.readLine();
File f1=new File(s1);
   File f2=new File(s2);
   copy(f1,f2);

  }
public static void copy(File f1,File f2)throws IOException{
                if(f1.isDirectory()){
    if(!f2.exists()){
                       f2.mkdir();
}
                       String f[]=f1.list();
                            for(int k=0;k<f.length;k++){
             File f3=new File(f1,f[k]);
             File f4=new File(f2,f[k]);
             copy(f3,f4);
 }
 }
 else{
  FileInputStream fis=new FileInputStream(f1);
  FileOutputStream fos=new FileOutputStream(f2);
                  PrintStream fs=new PrintStream(fos);
int ch;
                byte []b=new byte[1024];
                while((ch=fis.read(b))!=-1){
                  fs.write(b,0,ch);
                   }
  }
}
}


OUTPUT



Snowman using Java Applet

import java.awt.*;
import java.applet.*;
public class appletimg extends Applet
{
public void paint(Graphics g)
{
setBackground(Color.red);
//setForeground(Color.white);
g.setColor(Color.white);
        g.fillOval(150,200,200,60);
        g.fillOval(175,150,150,53);
        g.fillOval(200,100,100,53);
        g.fillRect(200,100,100,1);
         g.setColor(Color.black);
        g.fillRect(210,50,80,51);
        g.setColor(Color.black);
g.fillRect(230,115,5,5);
g.fillRect(270,115,5,5);
g.fillRect(250,125,5,5);
g.drawArc(230,115,40,30,230,100);
}
}
/*<applet code="appletimg" width=500 height=500></applet>*/

OUTPUT

Saturday, March 8, 2014

Indian Flag using java applet

                       




/*How to make indian Flag using applet*/
import java.awt.*;
import java.applet.*;
public class Flag extends Applet
{
public void paint(Graphics g)
{
g.fillOval(60,450,120,50);
g.fillRect(110,60,10,400);
g.setColor(Color.red);
g.fillRect(120,80,150,30);
g.setColor(Color.white);
g.fillRect(120,110,150,30);
g.setColor(Color.green);
g.fillRect(120,140,150,30);
g.setColor(Color.black);
g.drawRect(120,80,150,90);
g.setColor(Color.blue);
g.drawOval(180,110,30,30);
int a=0;
int x=195,y=125;
double x1,y1;
double r=15;
double d;
for(int i=1;i<=24;i++)
{
d=(double)a*3.14/180.0;
x1=x+(double)r*Math.cos(d);
y1=y+(double)r*Math.sin(d);
g.drawLine(x,y,(int)x1,(int)y1);
a+=360/24;
}
}
}
/*<applet code ="Flag" width=1368 height=678></applet>*/



//credits : Priyanandan Alok , KIIT University

Sunday, March 2, 2014

Compare two strings in java

import java.util.Scanner;
class reg2{
public static void main(String []arg){
String a2 = null;
String b2 = null;

Scanner sr = new Scanner(System.in);
System.out.print("Enter first string :: ");
a2 = sr.nextLine();
System.out.print("Enter second string :: ");
b2 = sr.nextLine();

if(scheck(a2,b2)==1)
System.out.println("strings \""+a2+"\" and \""+b2+"\" were matched");
else System.out.println("sorry , strings \""+a2+"\" and \""+b2+"\" were unmatched");
}
static int scheck(String a,String b){
int a1 = a.length();
int b1 = b.length();
int i=0,j=0;

if(a1<b1){
String temp = a;
a = b ;
b = temp ;
int t = a1;
a1 = b1 ;
b1 = t ;
}

while(j!=b1){
while(i!=a1){
if(a.charAt(i)==b.charAt(j)){
i++;
j++;

if(j==b1){
return 1;
}
}
else {
i++;
j=0;
if(i==a1)
return 0;
}
}
j++;
}


return 0;
}
}




OUTPUT