Sunday, August 28, 2011

Getting IP Address using Java Code

Hello Fellaws,


Today in this i m providing you an API using which u can get the IP address of the system in which this API will be executed.


Let me provide you the API below is the link provided
Download Here


Lets begin with the programming

  • Import this JAR file in your project. I am using NetBeans to develop my demo code. Steps are provided to import API in your code using NetBeans
    • Right click on your project name present on left Pane of Netbeans (Under which you have your .java files etc.
    • Select Properties, in the Project Properties Frame select Libraries on left pane
    • Click on Add Jar/Folder and select the above JAR file
    • You are done with importing API in your project




  • Now comes the coding part, let me give a brief information about the code
    • In this code an object of class GetIPAddress is created
    • Using process() of GetIPAddress class IP address is extracted and printed
    • Below is the code




  • The output of this code is given below i have intentionally not provided my IP address :P




  • Congrats you just got your IP address using your own code :) 
Thats it for this post

Take Care

Peace




For Any Query mail me: ravjot.singh.28@gmail.com

Friday, August 26, 2011

Customized JTextField allowing only String or Integer to take as input

Hello Fellaws,


Hope you all doing good.


Today in this post I am providing you customized JTextFields which will allow users to input only String (Letters) or only Integer values.


Before we start below is the download link of the API
Download Here


Lets begin with the steps



  • Import this JAR file in your project. I am using NetBeans to develop my demo code. Steps are provided to import API in your code using NetBeans
    • Right click on your project name present on left Pane of Netbeans (Under which you have your .java files etc.
    • Select Properties, in the Project Properties Frame select Libraries on left pane
    • Click on Add Jar/Folder and select the above JAR file
    • You are done with importing API in your project




  • Now comes the code part. Let me provide you a brief information about the code content
    • The code creates a JFrame 
    • Creates objects of IntegerField  and StringField class
    • Adds the IntegerField and StringField in JFrame
    • Below is the code




  • Congrats you just created two customized JTextField which takes only String or only Integer.


Thats it for this post


Take Care


Peace



For Any Query mail me: ravjot.singh.28@gmail.com

Wednesday, August 24, 2011

Encoding and Decoding Strings using Base64 Encoder-Decoder

Hellow Fellaws,


Today in this post I will provide you an API which will make easy for you all to encode or decode the text using the famous Base64 Algorithm.


The API download link is provided below
Download Here


Lets begin to encode and decode the text


Lets Start



  • Import this JAR file in your project. I am using NetBeans to develop my demo code. Steps are provided to import API in your code using NetBeans
    • Right click on your project name present on left Pane of Netbeans (Under which you have your .java files etc.
    • Select Properties, in the Project Properties Frame select Libraries on left pane
    • Click on Add Jar/Folder and select the above JAR file
    • You are done with importing API in your project



  • Now comes the code part. Let me provide you details of the code 
    • The code first encodes the String "Testing My API" 
    • Then it prints the encoded text
    • This encoded text is then decoded back to original text
    • This decoded text is printed again
    • Below is the code with comments go through the code and try it yourself.



  • The output of the code is given below



  • Congrats, you just encoded and decoded your string using Base64 Algorithm

Thats it for this post


Take Care


Peace



For Any Query mail me: ravjot.singh.28@gmail.com

Friday, August 19, 2011

Making JButton Draggable

Hello Fellaws,


Today in this post we will try to add a feature in JButtons which will make them draggable in  any container i.e. JPanel,JFrame,JDialog etc.


Below is the download link of the API that will help you to add this feature in your project/code.
Download Here


Lets begin the procedure to add this feature in your code


Let us Start



  • Import this JAR file in your project. I am using NetBeans to develop my demo code. Steps are provided to import API in your code using NetBeans
    • Right click on your project name present on left Pane of Netbeans (Under which you have your .java files etc.
    • Select Properties, in the Project Properties Frame select Libraries on left pane
    • Click on Add Jar/Folder and select the above JAR file
    • You are done with importing API in your project




  • Now comes the code part, I am providing you the code below. Let me give you some details about the code.
    • The code contains JFrame which contains 2 JButtons
    • Now, MouseMotionListener is added in the JButtons passing an object of RavDragHandler class.
    • This will make your JButton Draggable :)




  • Congrats you have just added the Draggable JButton in your project :) 

Thats it for this Post.


Take Care


Peace



For Any Query mail me: ravjot.singh.28@gmail.com

Sunday, August 14, 2011

Making Undecorated JFrame or Without Title bar JFrame or Window draggable

Hello Fellaws,


Well we have developed many Java application with or without Title bar of JFrame.


Most of us use setUndecorated(true); for JFrame to make their application attractive.


Famous applications that use this type of styles are iTunes, Winamp etc.


But, the problem Java developer face is that we can not make our JFrame dragged which is an awful feature :(


To help you all I am providing you an API which you can import in your project and with 3 lines you can add this drag feature to your undecorated JFrames.


You can download the API from below link
Download Here


Let us begin with the steps



  • Import this JAR file in your project. I am using NetBeans to develop my demo code. Steps are provided to import API in your code using NetBeans
    • Right click on your project name present on left Pane of Netbeans (Under which you have your .java files etc.
    • Select Properties, in the Project Properties Frame select Libraries on left pane
    • Click on Add Jar/Folder and select the above JAR file
    • You are done with importing API in your project



  • Now comes the code part well let me give you brief detail about the code. 
    • I have developed a CustomJPanel class which extends JPanel and adds few JLabels, JButton and JTextField etc. 
    • It is simple GUI and this JPanel is added in JFrame.
    • This API will provide you MouseListener and MouseMotionListener which should be added to JPanel or the JComponent you add on you JFrame (which is undecorated).
    • For your reference I am providing you the CustomJPanel Code Download Here
  • The code creating an undecorated JFrame and with CustomJPanel object is given below




  • Congrats you have developed an undecorated JFrame which can now drag :)
Thats it for this Post.


Take Care


Peace



For Any Query mail me: ravjot.singh.28@gmail.com

Thursday, August 11, 2011

Getting Lyrics of Songs in Java in 2 line code

Hello Fellaws,


Hope you all are having fun with your favorite programming language JAVA <3 :)


Well today in this post I am providing you an API which will take Song Name and Singer's name as arguments and in response it will provide you the lyrics of that song.


Requirement is Internet Connection else it will respond empty String ("")


Below is the API download link
Download Here


Lets begin with demo

  • Import this JAR file in your project. I am using NetBeans to develop my demo code. Steps are provided to import API in your code using NetBeans
    • Right click on your project name present on left Pane of Netbeans (Under which you have your .java files etc.
    • Select Properties, in the Project Properties Frame select Libraries on left pane
    • Click on Add Jar/Folder and select the above JAR file
    • You are done with importing API in your project




  • Now comes the coding part below is the code, in this code I am providing the Song Name : Only You Can Love Me This Way and Singer Name : Keith Urban


Congrats in 2 line code you get your favorite song's lyrics


Thats it for this Post.


Take Care


Peace



For Any Query mail me: ravjot.singh.28@gmail.com

Executing any file or web site link using Java Code [Windows Only]

Hello Fellaws,


We as Java programmers love the flexibility of Java Language, and are enjoying the perks provided by the Java Language.


Today, I will provide u an API which will make your programming more efficient and it will extend your project's parameters.


Sometimes, as a programmer I feel that this external file should execute when my project executes or to get popularity we feel that there should be a magic JButton which can redirect the user to our profile page or our web site on the client's favorite web browser.




So, stop your searches because i am providing you an API which can execute almost every file in Windows Operating System.
P.S. I will add Linux and Mac support later.


Let me provide the API download Link
Downlaod Here


This Rav_AutoRun.jar is the API that will add magic in your projects :)


Let me provide you 3 demos using this API
Below is the list of files or web links i will open using this API


  1. Any .mp3 Song
  2. Any .docx File
  3. www.google.com
Lets Begin 

  • Import this JAR file in your project. I am using NetBeans to develop my demo code. Steps are provided to import API in your code using NetBeans
    • Right click on your project name present on left Pane of Netbeans (Under which you have your .java files etc.
    • Select Properties, in the Project Properties Frame select Libraries on left pane
    • Click on Add Jar/Folder and select the above JAR file
    • You are done with importing API in your project


  • Playing any Mp3 Song on the user's default media player using Rav_AutoRun.jar API, below is the code


P.S. I love Lucky (Jason Mraz) :P so i will execute that song ;)

  • Executing your docx file on user's default word processor using Rav_AutoRun.jar API, below is the code

  • Executing a web site link on user's default web browser using Rav_AutoRun.jar API, below is the code
Our favorite www.google.com :P 


So, Congrats now you can add this magic in your projects to increase the parameters of your project.

Thats it for this post.

Take Care

Peace

For Any Query mail me: ravjot.singh.28@gmail.com

Monday, August 8, 2011

Customized Progress Bar [ Apple Style :) ]

Hello Fellaws


Well today we will try our hands on customized progress bar which you can use in your JFrames without any separate Progress Bar coming out to show the progress :)


Well let me provide you a screenshot of this Customized Progress Bar




In the above screenshot the JFrame's Components gets inactive and this appears above the JFrame
NOTE: Here Mouse Clicks are inactive in the JFrame till the Progress Bar in active


Let me provide you demo code of the above GUI, which will make easy to you understand and implement it in your projects


Lets begin ;)


Ahh, but before that download the API below is the link to download the API
Download API Here


Steps are as follows 



  • Import these JAR files in your project. I am using NetBeans to develop my demo code. Steps are provided to import APIs in your code using NetBeans
    • Right click on your project name present on left Pane of Netbeans (Under which you have your .java files etc.
    • Select Properties, in the Project Properties Frame select Libraries on left pane
    • Click on Add Jar/Folder and select the above 2 JAR files
    • You are done with importing API in your project





  • Now comes the code well i am providing you screenshot of the code and below the screenshot will be details of the API


Now details about the API

  1. You can pass a String in 3 different ways
    1. InfiniteProgressPanel() -> This will display 14 bars circle without any text below it
    2. InfiniteProgressPanel(String text)  -> This will display 14 bars circle with the text below it
    3. InfiniteProgressPanel(String text, int barsCount) -> This will display barsCount bars circle with text below it
  2. ipp.stop() -> will deactivate the Progress Bar
  3. You can dynamically change the Text below the circle, by below statements
    • ipp.setText("XYZ");
    •  ipp.repaint();

Congrats now you can add customized Apple Style Progress Bar in your project :)


Thats it for this Post


Take Care


Peace



For Any Query mail me: ravjot.singh.28@gmail.com

Friday, August 5, 2011

Playing any Mp3 and stopping it using 2 line code ;)

Hello Fellaws,


Hope you are enjoying your java codes ;) :P


Well today i will provide you APIs to play mp3 songs using your own code ;)


I know it feels great playing your fav. songs using your code ;) ;) ;) <3


So lets begin below is the zip file containing 2 APIs
Download Here


This RavMp3APIs.zip contains 2 JAR files
1. RavMp3.jar   -> Contains the core code to play Mp3 Songs
2. RavMp3Support.jar   -> Contains Supporting files


So, just download this zip file and read the below steps to play Mp3 files ;)


Steps are as follows

  • Import these JAR files in your project. I am using NetBeans to develop my demo code. Steps are provided to import APIs in your code using NetBeans
    • Right click on your project name present on left Pane of Netbeans (Under which you have your .java files etc.
    • Select Properties, in the Project Properties Frame select Libraries on left pane
    • Click on Add Jar/Folder and select the above 2 JAR files
    • You are done with importing API in your project




  • Now Comes the code section, well to make it easy for you all. I have tried my level best to make the code short for you :) 
    • So, to play a Mp3 file you have to do 2 line coding
      • 1st Line -> PlayMp3 pm = new PlayMp3();     // Create PlayMp3 Object 
      • 2nd Line -> pm.playSong("D:\\Music\\Songs\\English Songs\\Lucky.mp3");   //call playSong(String son) method. NOTE: this methods take song's path as argument.
      • Optional Line -> pm.stopSong(); //to stop the song any time the user want 
    • Let me provide you a code with GUI that will make more clear about this API 



  • Congratulations, you developed your own Mp3 Player. Enjoy and Listen to your favorite Songs. :)


Thats it for this post


Take Care


Peace



For Any Query mail me: ravjot.singh.28@gmail.com