How to do bitmap icon in front of menu-items in Java? what is the class for menu-item in Java?

G

gino

Hi all,
I have some menu-items in Java, they are "checked" menu-items... I want to
change that "check tick" in front of the menu items to other bitmap icon to
display some fancy bitmaps in front of the menu items...

HOw can I do that in Java? Which class in AWT does this menu-item belong to?
 
P

Paul Lutus

gino said:
Hi all,
I have some menu-items in Java, they are "checked" menu-items... I want to
change that "check tick" in front of the menu items to other bitmap icon
to display some fancy bitmaps in front of the menu items...

So write your own MenuItem class or extension.
HOw can I do that in Java? Which class in AWT does this menu-item belong
to?

Read the documentation.

http://java.sun.com/j2se/1.3/docs/api/java/awt/MenuItem.html

java.lang.Object , java.awt.MenuComponent, java.awt.MenuItem

Don't cross-post without a reason.
 
N

Nick Pomfret

I'm inclined to agree. In the past I've foundJMenus and menu items quite
limited (in terms of look and feel) and have been forced to implement my
own.
 
G

gino

Nick Pomfret said:
I'm inclined to agree. In the past I've foundJMenus and menu items quite
limited (in terms of look and feel) and have been forced to implement my
own.

--

** http://www.tabletoolkit.com **
Aggregate JTables to an arbitary level to create your own pivot tables


want
to

So write your own MenuItem class or extension.


Read the documentation.

http://java.sun.com/j2se/1.3/docs/api/java/awt/MenuItem.html

java.lang.Object , java.awt.MenuComponent, java.awt.MenuItem

Don't cross-post without a reason.

Hi how to write my own extension class?

I just found out they are belong the following class...

javax.swing.JPopupMenu

But what is the simplest way to do that?
 
P

Paul Lutus

gino said:
Nick Pomfret said:
I'm inclined to agree. In the past I've foundJMenus and menu items quite
limited (in terms of look and feel) and have been forced to implement my
own.

--

** http://www.tabletoolkit.com **
Aggregate JTables to an arbitary level to create your own pivot tables


want

Hi how to write my own extension class?

I just found out they are belong the following class...

javax.swing.JPopupMenu

But what is the simplest way to do that?

Just as it says in your Java textbook:

public class MyClass extends javax.swing.JPopupMenu
{
// your code here
}
 
G

gino

Just as it says in your Java textbook:

public class MyClass extends javax.swing.JPopupMenu
{
// your code here
}

It's not easy at all. I read the textbook. But where is the "bitmap icon"
property of this JPopupMenu that I can change?

Recall that I want to display my own bitmap icon on these menu-items...
 
P

Paul Lutus

gino said:
It's not easy at all. I read the textbook. But where is the "bitmap icon"
property of this JPopupMenu that I can change?

JPopupMenu is not a menu item object. Don't you want icons next to the menu
items in the popup menu? Look under JMenuItem, the objects that populate
your popup menu.
Recall that I want to display my own bitmap icon on these menu-items...

1. JPopupMenu is not a menu item.
2. JMenuItem is.
3. JMenuItem has a setIcon method.

This result required me to read the documentation for 15 seconds. Imagine
what you can accomplish if you read the documentation for an hour.

Why, reading the documentation might be more efficient than posting here
until you have a code problem that we can help you with.
 
G

gino

Paul Lutus said:
JPopupMenu is not a menu item object. Don't you want icons next to the menu
items in the popup menu? Look under JMenuItem, the objects that populate
your popup menu.


1. JPopupMenu is not a menu item.
2. JMenuItem is.
3. JMenuItem has a setIcon method.

This result required me to read the documentation for 15 seconds. Imagine
what you can accomplish if you read the documentation for an hour.

Why, reading the documentation might be more efficient than posting here
until you have a code problem that we can help you with.

Yes, yes, JPopupMenu is not a menu item, so what shall I do to put an bitmap
icon before it or after it?
 
P

Paul Lutus

gino wrote:

/ ...
Yes, yes, JPopupMenu is not a menu item, so what shall I do to put an
bitmap icon before it or after it?

Sorry for the last post -- it was posted inadvertently.

I repeat:

Time to read the documentation. JMenuItem.setIcon().
 
G

gino

Paul Lutus said:
I repeat:


Time to read the documentation. JMenuItem.setIcon().

I understood you perfectly. JMenuItem has a setIcon method that can allow me
to put a bitmap icon easily...

but JPopupMenu is not, so it does not have that setIcon() method, so I asked
what to do with this JPopupMenu...(I asked this part...)
 
P

Paul Lutus

gino said:
I understood you perfectly. JMenuItem has a setIcon method that can allow
me to put a bitmap icon easily...

but JPopupMenu is not, so it does not have that setIcon() method, so I
asked what to do with this JPopupMenu...(I asked this part...)

JPopupMenu is not a visible element of your program. Only its JMenuItems
are.
 
K

Keith Wansbrough

Paul Lutus said:
JPopupMenu is not a visible element of your program. Only its JMenuItems
are.

In other words: put the icon on the JMenuItem that causes your
JPopupMenu to appear, not on the JPopupMenu. This will have the
effect of showing an icon next to the entry with the right-pointing
triangle (or whatever) in the parent menu of the popup, which is what
we assume you want.

--KW :cool:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top