Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java: How to Ue system tray

Java: How to Ue system tray

import java.awt.Image;
import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
public class SystemTray{
  public static void main(String[] args)throws Exception {
    if (!SystemTray.isSupported()) {
      System.out.println("SystemTray Exception");
    SystemTray tray = SystemTray.getSystemTray();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Image image = toolkit.getImage("icon.jpg");
    PopupMenu menu = new PopupMenu();
    MenuItem message = new MenuItem("your message");
    message.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        JOptionPane.showMessageDialog(null, "Thank you");
    MenuItem fermer = new MenuItem("Close");
    fermer.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
    TrayIcon icon = new TrayIcon(image, "Example", menu);

Users who found this page were searching for:

  • java get systray object import

No comments yet.

Leave a Comment