I have a JDeskTopPane which holds many JInternalFrames. I want to create a SystemTray for the JDeskTopPane and on this I want to show which internal windows I am using.

I have created a class which calls the SystemTray, and puts the systemTray in a Jpanel. I can add this JPanel to an Internal Window but if I try to add it to the JDesktopPane it does not show up. Please help.

This is my class for the SystemTray.

import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;
import javax.swing.JButton;
import javax.swing.JPanel;
import java.awt.Toolkit;

public class SysTray implements ActionListener
{
protected JButton buttonOne, buttonTwo;
private JPanel barPanel = new JPanel(new FlowLayout());

public void actionPerformed(ActionEvent e)
{
JButton button = (JButton)e.getSource();
String ac = button.getActionCommand();

// Another way to identify source component:
if(ac.equals("Trace"))
System.out.println("ActionEvent set by buttonDebugging Trace");

if(button == buttonOne)
System.out.println("Ok");
if(button == buttonTwo)
System.exit(0);
}


public JPanel getContent()
{
buttonOne = new JButton("Debugging Trace");
buttonOne.setActionCommand("Trace");
// Set the actions
buttonOne.addActionListener(this);

barPanel.add(buttonOne);
return barPanel;
}

public JPanel createPane2Button() {
buttonTwo = new JButton("Stepper");
buttonTwo.setActionCommand("Stepper");
// Set the actions
buttonTwo.addActionListener(this);

barPanel.add(buttonTwo);
return barPanel;
}

private void barPanel(JButton buttonOne2) {
// TODO Auto-generated method stub

}

public void initSystemTray()
{
final TrayIcon trayIcon;

if (SystemTray.isSupported())
{
SystemTray tray = SystemTray.getSystemTray();
Image image = Toolkit.getDefaultToolkit().getImage("cut.gif");
// .createImage("images/sysTray/logo.gif");

MouseListener mouseListener = new MouseListener()
{
public void mouseClicked(MouseEvent e)
{
System.out.println("Tray Icon - Mouse clicked!");
}
public void mouseEntered(MouseEvent e)
{
System.out.println("Tray Icon - Mouse entered!");
}
public void mouseExited(MouseEvent e)
{
System.out.println("Tray Icon - Mouse exited!");
}
public void mousePressed(MouseEvent e)
{
System.out.println("Tray Icon - Mouse pressed!");
}
public void mouseReleased(MouseEvent e)
{
System.out.println("Tray Icon - Mouse released!");
}
};

ActionListener exitListener = new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.out.println("Exiting...");
System.exit(0);
}
};

PopupMenu popup = new PopupMenu();
MenuItem defaultItem = new MenuItem("Exit");
defaultItem.addActionListener(exitListener);
popup.add(defaultItem);

trayIcon = new TrayIcon(image, "Tray Demo", popup);

ActionListener actionListener = new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
trayIcon.displayMessage("Action Event",
"An Action Event Has Been Peformed!",
TrayIcon.MessageType.INFO);
}
};

trayIcon.setImageAutoSize(true);
trayIcon.addActionListener(actionListener);
trayIcon.addMouseListener(mouseListener);

try
{
tray.add(trayIcon);
}
catch (AWTException e)
{
System.err.println("TrayIcon could not be added.");
}
}
else
{
System.err.println("System tray is currently not supported.");
}
}

public static void createAndShowGUI()
{

}



}
This is what I do in my main program when I try to add the systemtray.

SysTray sysTray = new SysTray();
sysTray.initSystemTray();

c1 = frame1.getContentPane();

JPanel barPanel = new JPanel(new BorderLayout());

barPanel.add(sysTray.getContent());

setDefaultCloseOperation( JInternalFrame.DISPOSE_ON_CLOSE );

frame1.pack();

// attach internal frame to desktop and show it
desktop.add(frame1);
desktop.add(barPanel,BorderLayout.SOUTH);

desktop.setVisible(true);
frame1.setVisible(true);


// show desktop

//setSize(1500,1000);
setSize(1000,700);
setVisible(true);