• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

regarding popup menu!

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sir,
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("com.sun.java.swing.rose.RoseFactory", (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...
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

"mnsvPrasad"
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: http://www.javaranch.com/name.jsp
We appreciate your cooperation.
Thanks.
- satya
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
3.

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).
reply
    Bookmark Topic Watch Topic
  • New Topic