Adding icons to desktop

Hello,
i can't figure out how to add icons to a desktop pane. I've tried it like this but didnt work.
JDesktopPane desktop = new JDesktopPane();
desktop.add(new Label(new ImageIcon("Images/star.gif"), new Integer(1), 1));
Can anybody correct me? Any help will be appreciated.
Thanx

thanks, but i think u got it wrong.
ok here's the whole code.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class CyruxOSInterface {
JFrame mainFrame;
JDesktopPane desktop;
public CyruxOSInterface() {
mainFrame = new JFrame("Cyrux OS");
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
mainFrame.setBounds(0, 0, screenSize.width, screenSize.height- 20);
ImageIcon star, fav;
star = new ImageIcon("Images/Pro_orb.ico");
fav = new ImageIcon("Images/favicon[1].ico");
mainFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
JOptionPane.showConfirmDialog(mainFrame,
"Are you sure you wnat to exit Cyrux OS?",
"Exit Cyrux OS", JOptionPane.YES_NO_CANCEL_OPTION);
System.exit(0);
desktop = new JDesktopPane();
mainFrame.getContentPane().add(desktop);
desktop.add(new JLabel(star), new Integer(0), 1);
desktop.add(new JLabel(fav), new Integer(2), 2);
desktop.setIcon(true);
mainFrame.setJMenuBar(createMenuBar());
mainFrame.setVisible(true);
public JMenuBar createMenuBar() {
JMenuBar mb = new JMenuBar();
JMenu mstart, mprog, mdoc, mset, mfind, mhelp;
mstart = new JMenu("Start");
mstart.setMnemonic(KeyEvent.VK_S);
JMenuItem mexit, mlaunch;
mprog = new JMenu("Programs");
mdoc = new JMenu("Documents");
mset = new JMenu("Settings");
mfind = new JMenu("Find");
mhelp = new JMenu("Help");
ImageIcon launchico = new ImageIcon("Images/middle.gif");
mlaunch = new JMenuItem("Launch Frame", launchico);
mlaunch.setMnemonic(KeyEvent.VK_L);
mprog.setMnemonic(KeyEvent.VK_P);
mprog.add("Task Manager");
mprog.add("Cyrus Edit");
mprog.add("World View");
mprog.add("Java Web Start");
mprog.add("Net ConneXion");
mprog.add("Calculator");
mprog.add("Ping Socket");
mprog.add(mlaunch);
mprog.add("FuNCtion X");
mprog.add("Games");
mdoc.setMnemonic(KeyEvent.VK_D);
mdoc.add("Local Documents");
mdoc.addSeparator();
mdoc.add("Intranet Dox");
mdoc.add("Internet Dox");
mfind = new JMenu("Find");
mfind.setMnemonic(KeyEvent.VK_F);
mfind.add("Files and Folders");
mfind.add("On the Internet");
mfind.add("On local network");
mhelp = new JMenu("Help");
mhelp.setMnemonic(KeyEvent.VK_H);
mexit = new JMenuItem("Exit", new ImageIcon("Images/middle.gif"));
mexit.setMnemonic(KeyEvent.VK_X);
mexit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showConfirmDialog(mainFrame,
"Are you sure you wnat to exit Cyrux OS?",
"Exit Cyrux OS", JOptionPane.YES_NO_CANCEL_OPTION);
mainFrame.setVisible(false);
System.exit(0);
mlaunch.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
launchFrame();
mstart.add(mprog);
mstart.add(mdoc);
mstart.add(mset);
mstart.add(mfind);
mstart.add(mhelp);
mstart.addSeparator();
mstart.add(mexit);
mb.add(mstart);
return mb;
public JInternalFrame launchFrame() {
JInternalFrame frame = new JInternalFrame("Editor", true,
true, true, true);
JEditorPane ep = new JEditorPane();
JScrollPane sp = new JScrollPane(ep);
frame.getContentPane().add(sp);
frame.setSize(360, 300);
//frame.setLocation(
frame.setVisible(true);
desktop.add(frame);
return frame;
public static void main(String[] args) {
CyruxOSInterface Os1 = new CyruxOSInterface();
Make any corrections to it.
thanks again.
cyrus

Similar Messages

  • Adding icons to desktop - urgent

    Hello,
    i can't figure out how to add icons to a desktop pane. I've tried it like this but didnt work.
    JDesktopPane desktop = new JDesktopPane();
    desktop.add(new Label(new ImageIcon("Images/star.gif"), new Integer(1), 1));
    Can anybody correct me? Any help will be appreciated.
    Thanks

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class CyruxOSInterface {
    JFrame mainFrame;
    JDesktopPane desktop;
    public CyruxOSInterface() {
    mainFrame = new JFrame("Cyrux OS");
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    mainFrame.setBounds(0, 0, screenSize.width, screenSize.height- 20);
    ImageIcon star, fav;
    star = new ImageIcon("Images/Pro_orb.ico");
    fav = new ImageIcon("Images/favicon[1].ico");
    mainFrame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    JOptionPane.showConfirmDialog(mainFrame,
    "Are you sure you wnat to exit Cyrux OS?",
    "Exit Cyrux OS", JOptionPane.YES_NO_CANCEL_OPTION);
    System.exit(0);
    desktop = new JDesktopPane();
    mainFrame.getContentPane().add(desktop);
    desktop.add(new JLabel(star), new Integer(0), 1);
    desktop.add(new JLabel(fav), new Integer(2), 2);
    desktop.setIcon(true);
    mainFrame.setJMenuBar(createMenuBar());
    mainFrame.setVisible(true);
    public JMenuBar createMenuBar() {
    JMenuBar mb = new JMenuBar();
    JMenu mstart, mprog, mdoc, mset, mfind, mhelp;
    mstart = new JMenu("Start");
    mstart.setMnemonic(KeyEvent.VK_S);
    JMenuItem mexit, mlaunch;
    mprog = new JMenu("Programs");
    mdoc = new JMenu("Documents");
    mset = new JMenu("Settings");
    mfind = new JMenu("Find");
    mhelp = new JMenu("Help");
    ImageIcon launchico = new ImageIcon("Images/middle.gif");
    mlaunch = new JMenuItem("Launch Frame", launchico);
    mlaunch.setMnemonic(KeyEvent.VK_L);
    mprog.setMnemonic(KeyEvent.VK_P);
    mprog.add("Task Manager");
    mprog.add("Cyrus Edit");
    mprog.add("World View");
    mprog.add("Java Web Start");
    mprog.add("Net ConneXion");
    mprog.add("Calculator");
    mprog.add("Ping Socket");
    mprog.add(mlaunch);
    mprog.add("FuNCtion X");
    mprog.add("Games");
    mdoc.setMnemonic(KeyEvent.VK_D);
    mdoc.add("Local Documents");
    mdoc.addSeparator();
    mdoc.add("Intranet Dox");
    mdoc.add("Internet Dox");
    mfind = new JMenu("Find");
    mfind.setMnemonic(KeyEvent.VK_F);
    mfind.add("Files and Folders");
    mfind.add("On the Internet");
    mfind.add("On local network");
    mhelp = new JMenu("Help");
    mhelp.setMnemonic(KeyEvent.VK_H);
    mexit = new JMenuItem("Exit", new ImageIcon("Images/middle.gif"));
    mexit.setMnemonic(KeyEvent.VK_X);
    mexit.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    JOptionPane.showConfirmDialog(mainFrame,
    "Are you sure you wnat to exit Cyrux OS?",
    "Exit Cyrux OS", JOptionPane.YES_NO_CANCEL_OPTION);
    mainFrame.setVisible(false);
    System.exit(0);
    mlaunch.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    launchFrame();
    mstart.add(mprog);
    mstart.add(mdoc);
    mstart.add(mset);
    mstart.add(mfind);
    mstart.add(mhelp);
    mstart.addSeparator();
    mstart.add(mexit);
    mb.add(mstart);
    return mb;
    public JInternalFrame launchFrame() {
    JInternalFrame frame = new JInternalFrame("Editor", true,
    true, true, true);
    JEditorPane ep = new JEditorPane();
    JScrollPane sp = new JScrollPane(ep);
    frame.getContentPane().add(sp);
    frame.setSize(360, 300);
    //frame.setLocation(
    frame.setVisible(true);
    desktop.add(frame);
    return frame;
    public static void main(String[] args) {
    CyruxOSInterface Os1 = new CyruxOSInterface();
    This should help you understand it bettter. make any corrections to it.
    thanks again.

  • Ask your question.please help itunes will not launch on my computer the icon on desktop has changed to a white folder no error message appears and it appears but then disappears in task manager when the programme will not open quick time is working

    please help i need to fix my itunes it will not launch on my computer . no error message appears it simply will not run. the icon on desktop has changed to a white folder and it still appears in programmes in start menu but will not open. it appears in task manager but disappears when the programme will not open

    You music etc should not be affected by problems with the iTunes program, nevertheless it is always a good idea to backup your data.
    You haven't said if there was any error message when you tried to start iTunes. If  there was one please give it in full.
    Also check to see if QuickTime works, iTunes can not work without it. If QuickTime doesn't work, it has to be fixed before worrying about iTunes.
    Then restart your PC and open your Task manger and select the Processes tab.
    Try to start iTunes, does iTunes.exe appear on the processes tab? If so does it disappear again or remain although the programs does not open?

  • How can I put a hard drive icon on desktop?

    how can I put a hard drive icon on desktop?

    Click on the Desktop. Select Preferences from the Finder's menu. Click on the General icon in the toolbar. Check the appropriate boxes.

  • Blackberry Desktop Software installed, but not on start menu or icons on desktop

    Blackberry Desktop Software installed, but not on start menu or icons on desktop
    I got a new laptop Windows 7.  I installed Blackberry Desktop apparently successfully.  However, doesn't appear on start menu nor desktop.

    Hey tgcraighead,
    Welcome to the BlackBerry Support Community Forums.
    Thanks for the question.
    After the installation did you restart the computer?  If you go into Control Panel>Programs and Features do you see BlackBerry Desktop Software listed in the applications?
    Did you have a previous version of BlackBerry Desktop Software installed?
    I look forward to your reply.
    Cheers.
    -ViciousFerret
    Come follow your BlackBerry Technical Team on Twitter! @BlackBerryHelp
    Be sure to click Like! for those who have helped you.
    Click  Accept as Solution for posts that have solved your issue(s)!

  • Email icon on desktop always opens in webmail instead of email.

    When I click on email icon on desktop it goes to my internet provider's web page and the only way I can my emails is to sign into webmail. I am using Thunderbird.
    I have a second email on the desktop but it won't open at all.
    Any suggestions would be appreciated.

    Thunderbird is a desktop application. That email thingy on that ugly blocky screen will never open Thunderbird.
    Use the Thunderbird item, not email.

  • How can i force eject a cd from mac pro no icon on desktop or in finder, how can i force eject a cd from mac pro no icon on desktop or in finder

    how can i force eject a cd from mac pro no icon on desktop or in finder, how can i force eject a cd from mac pro no icon on desktop or in finder

    Restart the computer and hold down the trackpad down.
    It will take a while.

  • Loaded updated no icons on desktop and windows load offscreen ***

    Loaded updated no icons on desktop and windows load offscreen ***

    Nobody has any thoughts or has had the same issue on this one? Any thoughts are greatly appreciated!
    Thank you!

  • All icons on desktops keep flashing

    I have a 500GB transcend external hard drive. It used to work totally fine with Mac OS X Snow Leopard until a few days ago. When I plugged the hard drive in, all icons on desktop keep flashing every 3 seconds. When I open my hard drive, it disappeared automatically after the flash. I thought it might be a problem with my hard drive, but it works fine with when I plug into Windows 7. So, it must be the OS X that caused this problem. Please help!

    I have not see this issue before. Did a Playbook reset help?
    on Playbook press power button and both Vol + - buttons for 10 seconds to reboot it.
    Click here to Backup the data on your BlackBerry Device! It's important, and FREE!
    Click "Accept as Solution" if your problem is solved. To give thanks, click thumbs up
    Click to search the Knowledge Base at BTSC and click to Read The Fabulous Manuals
    BESAdmin's, please make a signature with your BES environment info.
    SIM Free BlackBerry Unlocking FAQ
    Follow me on Twitter @knottyrope
    Want to thank me? Buy my KnottyRope App here
    BES 12 and BES 5.0.4 with Exchange 2010 and SQL 2012 Hyper V

  • [svn:osmf:] 10017: Adding a style sheet, adding a backdrop to the examples list, adding icons to play and pause icons.

    Revision: 10017
    Author:   [email protected]
    Date:     2009-09-04 06:43:44 -0700 (Fri, 04 Sep 2009)
    Log Message:
    Adding a style sheet, adding a backdrop to the examples list, adding icons to play and pause icons. Setting theme color to red.
    Modified Paths:
        osmf/trunk/apps/samples/framework/ExamplePlayer/ExamplePlayer.mxml
        osmf/trunk/apps/samples/framework/ExamplePlayer/org/openvideoplayer/view/MainWindowLayout .mxml
    Added Paths:
        osmf/trunk/apps/samples/framework/ExamplePlayer/assets/
        osmf/trunk/apps/samples/framework/ExamplePlayer/assets/ExamplePlayer.css
        osmf/trunk/apps/samples/framework/ExamplePlayer/assets/assets.swf

    Revision: 10017
    Author:   [email protected]
    Date:     2009-09-04 06:43:44 -0700 (Fri, 04 Sep 2009)
    Log Message:
    Adding a style sheet, adding a backdrop to the examples list, adding icons to play and pause icons. Setting theme color to red.
    Modified Paths:
        osmf/trunk/apps/samples/framework/ExamplePlayer/ExamplePlayer.mxml
        osmf/trunk/apps/samples/framework/ExamplePlayer/org/openvideoplayer/view/MainWindowLayout .mxml
    Added Paths:
        osmf/trunk/apps/samples/framework/ExamplePlayer/assets/
        osmf/trunk/apps/samples/framework/ExamplePlayer/assets/ExamplePlayer.css
        osmf/trunk/apps/samples/framework/ExamplePlayer/assets/assets.swf

  • Can't get rid of itunes icon on desktop

    Already have iTunes showing on dock on bottom of display and now have iTunes icon on desktop display as well. Tried dragging it into trash but then I can't open iTunes from the dock without dragging desktop icon out of trash to and back to the desktop. Tried dragging desktop icon onto dock and into already existing iTunes icon already on the dock. Nothing i've tried seems to work. How to I get rid of this desktop icon?

    Hi bkbl?
    Welcome to Apple Discussions
    First check in Applications to see if there is an iTunes icon there?
    If so then just drag the one on your Desktop to the dock, make sure it works and then drag the old one off.
    Dennis

  • External devices (HD's, digital cameras) do not appear as icons on desktop

    This is, I think, exactly the same question asked by Byron B.
    That is: external devices (Hard Drives, digital cameras) do not appear as icons on desktop. They used to, but not anymore. I can access them through the finder windows, but no icons on the desktop.
    What causes this? More importantly, how do I rectify this?
    All help and wisdom much appreciated.
    Thanks so much!
    Geno
    Powerbook G4 12"   Mac OS X (10.4.8)   1G PowerPC

    Awesome! Thank you, Terence!
    I can't believe it was that easy. I never even knew that option was there.
    Thanks again, happy holidaze!
    Geno
    Macbook Pro Mac OS X (10.4.7) Intel, FCP 5.0.4

  • My mail window won't come up when I click the mail icon in desktop.  Mac Book Pro

    My Mail window won't come up when I click the mail icon in desktop.  My Accounts both show as marked in accounts.

    Try clicking GO in the menu bar/Go to folder in the pane enter  ~/Library/Preferences/com,apple.mail.plist
    Another way is to hold the OPTION key click GO in the menu bar>Library>Preferences, locate the the file com.apple.mail.plist
    Drag this file to the trash (do not empty)
    Quit Mail log out and reboot, see if that helps, if it does not you can drag the file from the trash and and replace it where it was. (it will probably give you a this file already exists, click replace)
    Post back there may another thing to check.
    ATB

  • How to get rid of Icons on Desktop?

    I have Documents and Pictures folders in Macintosh HD and as icons on the Desktop. When I clean up the Desktop by dragging the icons to Trash in the dock, that works OK. But later when I try to access anything via Documents or Pictures on the HD I get a message that it can't be opened because it's in Trash, and I must drag it out of Trash. How can I get rid of the icons on Desktop and still access stuff in Documents and Pictures?

    Drag the icons on the desktop to the folder in the Finder's sidebar with the house icon, renaming folders as needed.
    (25313)

  • Time machine icon does not rotate and back up icon on desktop does not show during backup session.

    Time machine icon does not rotate and back up icon on desktop does not show during backup session since I installed Maverick.  Why? How do I fix it?

    That's the new look of it. No way to change it other than file a complaint with Apple. If ENOUGH people do thst they may "fix it".
    http://www.apple.com/feedback/macosx.html

Maybe you are looking for