File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes regarding popup menu! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "regarding popup menu!" Watch "regarding popup menu!" New topic

regarding popup menu!


Joined: Feb 16, 2001
Posts: 7
I want some clarifications..
1.In Sun Examples he is given the setUIFactory method in UIManager, but in JavaDoc i cont able to find the above method in the class. and there is no package named as 'rose' in swing. this i need for the setting UIFactory to RoseFactory to get the L&F. So, Plese kindly Help me in this regard. In the Example he is given like this
UIManager.setUIFactory("", (Container)frame);
2. How i Can put the KeyAccelerator to a Button or CheckBox or RadioButton etc.. to access them from the keyboard. I have tried with the "button.setKeyAccelerator('a')", but compilar is saying that there is no method like that and I was verified the JavaDoc and i con't find such method.
3. How i can add a PopUp menu to a frame and that should be shown in a button action and that is to be displayed on the top of the button like
| MenuItem1 |
| MenuItem2 |
| MenuItem2 |
| GoTo |
here Goto is the Button and on Click-event of the Button has to Display the PopUp menu.
i am using the "Forte for Java2" IDE to developing the Applications.
So Kindly plese Help me...
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

javaranch has a lot of users everyday and some of them
surprisingly similar names. Hence we request our users
to register with name which look more like a professional
name. Could you please take a moment and re-register yourself
after selecting a name according to the following guidelines:
We appreciate your cooperation.
- satya

Take a Minute, Donate an Hour, Change a Life
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

1. No idea.
2. I had trouble finding this. You must look all the way up to Abstract Button to find a *different* method called setMnemonic. This will work for buttons, checkboxes and radio buttons. (since those are all descended from Abstract Button). Perhaps it would work for MenuItems (which is where setAccelerator() comes from), since MenuItems are also descendants of Abstract Button.

Well, this is a solution that works, sort-of. I'm having a difficult time with the getX, getY and getHeight to work the way I think they should. eg: getX/getY only return the coordinates of the component, based upon a 0,0 origin at the top left of their container, not of the Frame.
Also, it's a bit flakey, because the *first* time you click the button, popupMenu's values don't seem to all be 'ready'? Because on subsequent clicks, everything works "as expected", but still not very well.

Example: simply uncomment the two lines that are currently commented, and comment the lines directly below those... and re-run. you'll see that the button's Y value is based on it's container, and not the frame. Maybe if you added everything directly to a frame, but then how would you lay things out? Don't even get me started about GridBags (shudder).

Does anyone have any ideas on how to improve the code above, or what is wrong with that 'first click' behaviour?

Another idea that occurs to me, is subclass JComboBox. When it's at the bottom of the screen, combo boxes go up... "Just" override the paint method to make it paint like a button. (or maybe it's not that simple).
Don't get me started about those stupid light bulbs.
subject: regarding popup menu!
It's not a secret anymore!