This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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...
"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
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).