Easy to Learn Java: Programming Articles, Examples and Tips

Start with Java in a few days with Java Lessons or Lectures

Home

Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips

Books

Submit News
Search the site here...
Search...
 
Search the JavaFAQ.nu
1000 Java Tips ebook

1000 Java Tips - Click here for the high resolution copy!1000 Java Tips - Click here for the high resolution copy!

Java Screensaver, take it here

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java programming articles and tips. Please take your copy here.

Take your copy of free "Java Technology Screensaver"!.

Icon in taskbar for my Java Application? Read here answer.

JavaFAQ Home » Swing, AWT Go to all tips in Swing, AWT


Bookmark and Share

Question: I need to open my JFrame from icon in taskbar (like date and time properties window). Which class offers this option.

Probably many Java developers noticed that there is no built-in way in Java to put an icon in a system taskbar beside to system clock. There were different tricks and tips how to go around with some external code, like Visual Basic, but I will point you more elegant way.

JDIC will let your Java application to have functionality as usual binary applications has when run from within the native desktop. JDIC contains a collection of Java tools and packages. With JDIC you get support of variety of features such as launching the desktop applications, embedding the native browser, creating tray icons on the desktop, registering file type associations, creating JNLP installer packages, etc.

You can find JDIC components implemented for Linux, Solaris and Windows.

Look at this code snippet. It creates the tray icon, it is such easy!

Code:

final TrayIcon trayIcon =
   new TrayIcon(getTrayIcon(), "Tray Demo", getPopupMenu());

trayIcon.setIconAutoSize(true);
trayIcon.addActionListener(new ActionListener(){
   public void actionPerformed(ActionEvent e) {
      setVisible(true);
   }
});
</div>

The good news for you with JDIC tray support is that you use existing Swing code - javax.swing.JPopupMenu and the corresponding menu classes and event listeners, in addition to javax.swing.Icon.).

Another good feature in JDIC is Native File Support.

As you know, Java applications can not use default applications to open files. For example, a Java application can't open a .psd file in Photoshop or .doc file in Microsoft Word. Java applications have no info on where default (for certain file type) application resides on each machine. Also there's no easy way to print this .doc file from a Java application.

To solve this problem use the Desktop class. This class will let your Java application interact with system applications, which are built into the OS, because only the OS has a knowledge how .doc file can be opened and handled.

 


 Printer Friendly Page  Printer Friendly Page
 Send to a Friend  Send to a Friend

.. Bookmark and Share

Search here again if you need more info!
Custom Search



Home Code Examples Java Forum All Java Tips Books Submit News, Code... Search... Offshore Software Tech Doodling

RSS feed Java FAQ RSS feed Java FAQ News     

    RSS feed Java Forums RSS feed Java Forums

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.

Interactive software released under GNU GPL, Code Credits, Privacy Policy