Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How can I set icon on MenuItem?

Posted on 2010-09-01
7
Medium Priority
?
479 Views
Last Modified: 2013-12-29

I have created PopupMenu for SystemTray and added
MenuItem. Now I want to set Icon on MenuItem.
How can I resolve this?
0
Comment
Question by:mihir_amreli
6 Comments
 
LVL 26

Expert Comment

by:ksivananth
ID: 33584225
menuItem = new JMenuItem("Both text and icon",
                         new ImageIcon("images/middle.gif"));
0
 

Author Comment

by:mihir_amreli
ID: 33584422

I know how to set icon on JMenuItem
but i need to set on MenuItem

bcoz,
if i use JMenuItem I cant add it into PopupMenu which only can be set on SystemTray!!!
0
 

Accepted Solution

by:
littlegiraffe earned 672 total points
ID: 34097707
I think you will have to create a JPopupmenu and populate it with JMenuitem(s).

I don't think menuItem supports Icons
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Assisted Solution

by:Ghyths
Ghyths earned 664 total points
ID: 34342028
Hi Littlegirafee,


I think this is what you are looking for
http://java2s.com/Code/Java/Swing-JFC/Asimpleexampleofconstructingandusingmenus.htm

Regards
G
0
 
LVL 5

Assisted Solution

by:aciuica
aciuica earned 664 total points
ID: 34738345
You can try JDIC library. They provide a similar interface wich support API with SystemTray and TryIcon wich allow JPopupMenu and you can use icons in JMenuItem. I checked in Windows Vista and is working. It seems to work on other platforms too. See: https://jdic.dev.java.net/
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 37126827
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question