Scary Application in Java

This  is a scary application made using Java Swings.Will pop an image in front of the screen suddenly(Ghost,in this case) … 🙂

NOTE:This app  is made for fun .U r responsible for using..

Download the jar file and run it once-> myapp.jar.

Here is the  source code :-

Class 1:Base frame

import java.io.InputStream;
import java.io.PrintStream;
import javax.swing.JOptionPane;
import sun.audio.AudioPlayer;

public class base_frame
implements Runnable
{
      Thread t;
      img_frame fpanel;  //this is our image(JPanel type) class
      AudioPlayer ap;     //In-built Audioplayer class("import sun.audio.AudioPlayer ")
      InputStream is_scream = null; InputStream is_about = null;

      public base_frame()
      {
              this.t = new Thread(this, "Frame Thread");
              try
              {
                      this.is_scream = getClass().getResourceAsStream("s_0x00");
              }
              catch (Exception e)
             {
                       System.out.println("Error while loading audio file" + e);
                       System.exit(0);
             }

          this.fpanel = new img_frame();
      }

public static void main(String[] args)
 {
      base_frame frame = new base_frame();
      String[] choices = { "Yes,Its a cool OS!!", "No!!,I hate it!" };
      String[] second_choice = { "Hmmmm..Sorry,i clicked wrongly ", "YES!,I HATE Linux!!!!!" };
      int res1 = 10;

      res1 = JOptionPane.showOptionDialog(null,"What do think about Linux OS?????","Hello there!",0,2,null,choices,Integer.valueOf(0));

      int res2 = 10;
      if (res1 == 1)
     {
               System.out.println("User hates Linux.One more chance");
               res2 = JOptionPane.showOptionDialog(null, "Are you sure ?I am warning you!", "Dont like Linux and other                   opensource stuffs????", 0, 2, null, second_choice, Integer.valueOf(1));
     }
     else if (res1 == 0)
     {
             System.out.println("User likes Linux ");
             JOptionPane.showMessageDialog(null, "Very good ,See ya!!", "Great!                 App by \\m/", 1);
     }

    if (res2 == 1)
    {
             System.out.println("Show starts!!!");
             JOptionPane.showMessageDialog(null, "Ok,Goodbye!...You will regret soon", "Errr!", 1);
             frame.t.start();
     }
     else if (res2 == 0)
     {
             JOptionPane.showMessageDialog(null, "Hmmmmm,Ok,Dont tell that again...\nBye ", "ok ok---                App by \\m/", 1);
     }

if ((res1 == -1) || (res2 == -1))
{
            JOptionPane.showMessageDialog(null, "This program wont crash your PC!.\nRun again and choose one",  "Select a choice!!", 1);
}
System.out.println("Main finished");
}

public void run()
{
       try
      {
              Thread.sleep(30000L);
              this.fpanel.setVisible(true);
              AudioPlayer.player.start(this.is_scream);
              Thread.sleep(6000L);
      }
      catch (InterruptedException ie)
     {
              System.out.println("Error in thread!!" + ie);
              System.exit(0);
     }
System.out.println("Author:MaX \nThis program is not for weak hearted ppl.Be careful \\m/");
System.exit(0);
}
}

Class 2:Image Frame:


import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;
import javax.imageio.stream.ImageInputStream;
import javax.swing.*;
/*
* this class gets the screen res
* loads the image
* sets the frame based on the screen size
*
*
*
*/
public class img_frame extends JFrame
{
        //img_panel panel;
        JLabel label;

        //graphics device
	GraphicsDevice gdev;
	GraphicsEnvironment genv;

img_frame()
{
	label=new JLabel();
	InputStream f=null;
	ImageIcon icon=null;
	try{
		f= getClass().getResourceAsStream("rock1.gif");
		icon=new ImageIcon(ImageIO.read(f));
	}catch(Exception e)
	{
		System.out.println("error while loading image"+e);
		System.exit(0);
	}
        System.out.println("Image details(w,h):"+icon.getIconHeight()+","+icon.getIconHeight());

	//adding label to this frame
	label.setIcon(icon);
	this.add(label);

	//reading the screen res
	genv=GraphicsEnvironment.getLocalGraphicsEnvironment();
	//access the computer screen
	gdev=genv.getDefaultScreenDevice();
	System.out.println("Screen width:"+gdev.getDisplayMode().getWidth());
	System.out.println("Screen Height:"+gdev.getDisplayMode().getHeight());

        //image panel visual details
	setVisible(false);
	setSize(gdev.getDisplayMode().getWidth(),gdev.getDisplayMode().getWidth());
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setAlwaysOnTop(true);
	setUndecorated(true);
}
}

This is the output:-

This is the output shown in full screen

This is the output shown in full screen

Blurred here only

Note:
  • It also has a screaming audio.Beware ,not for weak ppl!