Skip to main content

Posts

Showing posts from May, 2017

Java 3D:- Creating a 3d ball using java

Quoted from Wikipedia  Java 3D is a scene graph based 3D application programming interface (API) for the Java platform . It ran atop either OpenGL or Direct3D until the version 1.6.0 which runs at the top of JOGL . Since version 1.2, Java 3D has been developed under the Java Community Process . A Java 3D scene graph is a directed acyclic graph (DAG). Compared to other solutions, Java 3D is not only a wrapper around these graphics APIs, but an interface that encapsulates the graphics programming using a true object-oriented approach. Here a scene is constructed using a scene graph that is a representation of the objects that have to be shown. This scene graph is structured as a tree containing several elements that are necessary to display the objects. Additionally, Java 3D offers extensive spatialized sound support. Java 3D and its documentation are available for download separately. They are not part of the Java Development Kit (JDK). Download Java 3d

Capturing Screen Shot using java

Here i will tell you how to write a program using java which is capable of capturing screenshots(either whole or partial).And save it as an image. Which java API ? The java.awt.Robot class provides a useful method for capturing a screenshot.Here is the method prototype. BufferedImage createScreenCapture(Rectangle screenRect) It is clear from the prototype that this function returns a BufferedImage and takes a Rectangle class object (portion of the screen to capture) as the argument.The BufferedImage which is returned could be saved using ImageIO class write method.Lets begin with the program. 1) Capturing full screen In order to capture full screen using  createScreenCapture(Rectangle screenRect) screenRect should have the full screen size and in order to do that we will use Toolkit class of java. Rectangle screenRect =  new Rectangle( Toolkit.getDefaultToolkit().getScreenSize() ); Now here begins the whole program. /* ***************

Open any external file using java

So if you are here it is sure you need a piece of code which could help you to open any external file using java.And this article will tell you how you could do that. java.awt.Desktop The Desktop class of awt package allows java programs to launch any  file in its default editor.Means if the file is .txt it might open in Notepad if it is .pdf then it will open in adobe reader and if it is (.html) then it will open in your default web browser. NOTE:- If we will try to open a file which does not exists then it will throw                                            java.lang.IllegalArgumentException So here is the whole source code openIt.java  import java.util.Scanner; public class OpeIt { public static void main ( String [] args ) throws IOException { System.out.print(" Enter the path of the file to open "); String path=sc.nextLine(); File file = new File (path ); //fir

Creating a text dictator using java

Want to create your own reader for your .txt files using java .If yes then you are on the right track.Here you see how to use Free TTS ,A free  API written entirely using Java TM . Requirements In order to create this reader app you need Free TTS 1.2.2 API you could download it from here What the program do ? The program given below will prompt you to enter the path of a .txt file in your computer and then it will read the file in a natural human voice for you . Reader.java import java.io.File ; import java.io.FileInputStream ; import java.io.FileNotFoundException ; import java.util.Scanner ; import com.sun.speech.freetts.Voice ; import com.sun.speech.freetts.VoiceManager ; public class Reader { // Some available voices are (kevin, kevin16, alan) private static final String VOICE_NAME_KEVIN = "kevi" ; private final Voice voice; public Reader () { VoiceManager vm = VoiceManager . getInstance();

Decimal to binary and vice versa program in java

1)Decimal to binary conversion program import java.util.Scanner ; public class Deci2Bin { public static void main ( String [] args ) { int n; String x; Scanner s = new Scanner ( System . in); System . out . print( "Enter any decimal number:" ); n = s . nextInt(); Deci2Bin obj = new Deci2Bin (); x = obj . inBinary(n); System . out . println( "Binary number:" + x); } String inBinary ( int y ) { int a; if (y > 0 ) { a = y % 2 ; return (binary(y / 2 ) + "" + a); } return "" ; } } 2)Binary to decimal conversion Program import java.util.Scanner ; public class BinToDeci { public int getDecimalFromBinary ( int binary ){ int decimal = 0 ; int power = 0 ; while ( true ){ if (binary == 0 ){

Hijack Clipboard using java

What is Clipboard? The clipboard is a special location in your computer's memory that temporarily stores data that has been cut or copied from a document. This data can then be pasted to a new location. The clipboard will typically hold its information until you cut or copy something else, or log out of the computer. For example, a user may copy information from a word processor and paste that information into an e-mail message. What is Clipboard Hijack? A clipboard hijacking is an exploit in which the attacker gains control of the victim'sclipboard and replaces its contents with their own data, such as a link to a malicious Web site.For more details see  here . Hacking clipboard using java. Our java code will repeatedly change clipboard text with the hackers text, may be a irritating line ,or a URL to your site. We will use the Toolkit class to get the system clipboard and then we will use the Clipboard class to change the content of clipboard.