Thursday, May 28, 2009

Simple Java Tray Example

I am just putting below a sample code to create a simple tray icon using java awt.
Also I will demonstrate how to show a Error, Warn or Info balloon message and opening a browser on click of the balloon message.

Following is the sample code:

SystemTray tray = SystemTray.getSystemTray();
TrayIcon ti;
PopupMenu menu = null;
menu = new PopupMenu();

MenuItem menuItem = new MenuItem("Quit");
menuItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
String s = ((MenuItem) (e.getSource())).getLabel();
if (s.equalsIgnoreCase("Quit") {
System.exit(1);
}
s = null;
}
});
menu.add(menuItem);

Image i = new ImageIcon("imagenage.gif").getImage();
ti = new TrayIcon(i, "Tool Tip to be displayed on mouse hover",
menu);


This should create a tray icon with the selected image. The tool tip message is displayed whenever the mouse hovers over the tray icon. On click of the tray icon the Menu created by PopUpMenu shows, in the above code it just shows an exit menu.

Below we will add a balloon message to the tray.


ti.displayMessage("Message Title",
"Actual Message", MessageType.INFO);


Note: The Message Types can be INFO, ERROR or WARNING Or NONE

Lets say we want to open a broswer on click of the balloon message. TO achieve this first we have to add a action listener to the tray icon, as shown below:

ti.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

}
});



Now that we have added an action listener, we will see how to open the browser and browse a site on click of the balloon message. To achieve this, add the following code to the actionPerformed method.


Desktop.getDesktop().browse((new URI("www.google.com"));


Voila Done.


On Second thoughts--- This Tray Icon API is in Java 1.6. Forgot to mention that :)

Wednesday, May 20, 2009

Pictures Which Have a Meaning in Life

Images and Wording thanks to Rajiv Mathew



1957. The first day of Dorothy Counts at the Harry Harding High School in the United States . Counts was one of the first black students admitted in the school, and she was no longer able to stand the harassments after 4 days.



January 12, 1960. A second before the Japanese Socialist Party leader Asanuma was murdered by an opponent student.



1962. A soldier shot by a sniper hangs onto a priest in his last moments.




1963. Thich Quang Duc, the Buddhist priest in Southern Vietnam , burns himself to death protesting the government's torture policy against priests. Thich Quang Dug never made a sound or moved while he was burning.




1965. A mom and her children try to cross the river in South Vietnam in an attempt to run away from the American bombs.



1966. U.S. troops in South Vietnam are dragging a dead Vietcong soldier.



February 1, 1968. South Vietnam police chief Nguyen Ngoc Loan shoots a young man,whom he suspects to be a Viet Cong soldier..



1973. A few seconds before Chile 's elected president Salvador Allende is dead during the coup.



1975. A woman and a girl falling down after the fire escape collapses.



1980. A kid in Uganda about to die of hunger, and a missionary.



February 23, 1981. Colonel Molina ve military police seizes the Parliament building in Spain. The photographer did not expect the scene, and hid the films in his shoe.



1982. Palestinian refugees murdered in Beirut , Lebanon .




1987. A mother in South Korea apologizes and asks for forgiveness for his son who was arrested after attending a protest. He was protesting the alleged manipulations in the general elections.



1989. A young man in China stands before the tanks during protests for democratic reforms.



1992. A mother in Somalia holds the body of her child who died of hunger.



1994. A man who was tortured by the soldiers since he was suspected to have spoken with the Tutsi rebels.



1996. Kids who are shocked by the civil war in Angola .



2001. An Afghani refugee kid's body is being prepared for the funeral in Pakistan .



2002. Soldiers and villagers in IRan are digging graves for the victims of the earthquake.
A kid holds his father's pants before he is buried.




2003. An Iraqi prisoner of war tries to calm down his child.

Wednesday, May 13, 2009

In The Land of the Blind, A One Eyed Mouse is the King

If you carefully observe the title has a mistake. Instead of a One Eyed Man its a One Eyed Mouse. The actual statement by one Erasmus (of Rotterdam) goes like this "In the land of the blind the one eyed man is king".

Do you see the relevance of the above statement in the current day India? If you don't, I should say you are one of the "Normal Indians". One who is blind, deaf and dumb to everything except himself. Now, then whose the Mouse / Mice leading this land of the Blind ---- Without doubt our great Politicians.

While the blind go on about their daily lives these mice are stealing from us like the mice that steal food from our houses. The difference being these mice are bigger, badder and consume everything. Not just our food, money or clothing but also our life, our soul, our dignity and our very life.

Then there are other one eyed mice who say they want to do good to people and society. These are Intellectuals of the Society. What do these so called intelligent people do.... hold candles and march, start a pink chaddi campaign.. regarding pink chaddi, i will write some other time, but i just remember one thing that i read in some editorial... "According to these so called forward thinking women the dignity is between the legs". Totally Utterly Nonsense.

In the actual time of reckoning, when there is a chance to make a change, what do all these people do..... they just disappear like some freaking ghosts.

Well enough rants for the day. No one can do anything. Anyways just a parting thought.. watch a movie called Shaun of the Dead, its good watch.

Tuesday, May 05, 2009

Along Came An Angel

Every once in a while there comes a person into our lives who completes us. Who makes us feel perfect. Who makes us feel more alive then ever. Who makes us want to spend every moment of our life with them and every moment spent with them is cherished. Whose every thought puts a smile on our face.

I am lucky enough to have had experienced such a feeling once in such a short life of mine. I met this angel some years back. Before she came into my life I was happy in a different sort of way. My life was an antithesis to the saying "No Man is an Island". I was an Island, a rock and sand filled island. I didn't have anyone I could call as friends. I didn't have any romantic relations. I stayed aloof from my family also. In short I lived my life within myself only, interacting with others only if necessary.

Then one day like a storm she came into my life. Wrecking all the jails in which I had imprisoned emotions and setting them free to hunt me. I ran, as fast as I could but in front of those emotions it always looked like I was frozen in time and couldn't move. They caught me and imprisoned me. I tried to escape from this prison of emotions for a long time, every attempt ended in failure. Finally I had to give up and embrace them.

Now I was finally free of the prison but chained in relationships. I started seeing the world in a whole different colour. My Life became a lot more complicated than before. I started expecting things from people and people started expecting things from me. In a way I became what the world calls a "Normal Person" but deep inside me I still miss the the joy of loneliness, the freedom of being emotionally challenged, the freedom of no relationships and a lot simpler life.

I do not regret what happened neither do I resent my Angel for showing me this side of life. The problem with Angels is they dont stay with you. The world is too small a place for them.

Anyways, I have learnt one thing from this experience. I am happy being alone, I am happy being with people. Adios until next time.