Dynamic Tooltip in Java
Tuesday, 1 April 2014
Tooltip is helpful for every software users it displays the use of that feature of a software and also it make it easy for the user to work with that software.
In this project we will develop a project with Tooltip Functionality,It is developed with the help of Netbeans Ide It is a Graphical User Interface application.
Now,Open up Netbeans Ide
Go to ,
- File--->New Project
- Categories—>java
- Project—>Java Desktop Application
Click Next and then Finish
Now switch to design view add a jbutton from palatte
Now swtch to source view
Import the following package.
import com.sun.media.ui.ToolTip;
Declare ToolTip as class level variable like that
ToolTip tip=new ToolTip("set your text here");
find this function and write this code below it initComponents();
tip.setLocationRelativeTo(jButton1); //displays tooltip below jbutton
tip.setSize(200,50);
That’s it.
Now right click jbutton in design view and got to
Events—>Mouse—>MouseEntered
You will see the code like this
private void jButton1MouseEntered(java.awt.event.MouseEvent evt) {
tip.setVisible(true); //setting visible tooltip
}Now again go to design view and right click jbutton
Events—>Mouse—>MouseExited
You will see the code like this
private void jButton1MouseExited(java.awt.event.MouseEvent evt) {
tip.setVisible(false); //setting invisible tooltip
}All done compile and run move cursor to jbutton and see the tooltip.
Simple Play Mp3 Files In Java
Thursday, 23 January 2014
First of all we need to download The Java Media Framework and install on our machine here is the link
Java Media Framework (JMF)
now import the packages.
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.media.Time;
Now Put that code on button click event
try
{
MediaLocator ml=new MediaLocator("File address here ex; c:/xyz.mp3”);
player=Manager.createPlayer(ml);
player.realize();
player.start();
}
catch(Exception yxz)
{
System.out.println(""+yxz);
}
