QUOTE
i feel u can post your answer in the "Tips and Tricks" subforums and help other members (including myself LOL
) on how to write a component like that. It wud be of tremendous benefit.
here is the so-so code to make this DropDownMenuButton (it really isnt anything special or hard to do, but it makes your GUI's look even better)
First off you need to have initialized your components including at least 1 JButton and 1 JPopupMenu Also do not forget to add elements to your JPopupMenu
CODE
myJPopupMenu = new javax.swing.JPopupMenu();
myJButton = new javax.swing.JButton();
myJLabel = new javax.swing.JLabel("Inside PopupMenu");
//Add elements to the popupmenu
myJPopupMenu.add(myJLabel);
//Add more elements at your disposal
/*Next you need to add a mouseListener to myJButton that will be using the popupmenu
*
*Next comes the code for the mouseListener (which is really only one line of code unless you want more
*Restrictions on it
*
*NOTE if you want just left click to work for this, you could just used actionPerformed on the button instead
*/
myJButton.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(java.awt.event.MouseEvent evt)
{
myJPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
}
});
//Add all the other stuff you want
myJButton = new javax.swing.JButton();
myJLabel = new javax.swing.JLabel("Inside PopupMenu");
//Add elements to the popupmenu
myJPopupMenu.add(myJLabel);
//Add more elements at your disposal
/*Next you need to add a mouseListener to myJButton that will be using the popupmenu
*
*Next comes the code for the mouseListener (which is really only one line of code unless you want more
*Restrictions on it
*
*NOTE if you want just left click to work for this, you could just used actionPerformed on the button instead
*/
myJButton.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(java.awt.event.MouseEvent evt)
{
myJPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
}
});
//Add all the other stuff you want
Thats all there is to display what I was wondering about. If you want the elements within the JPopupMenu to do something when you click on them, just use actionPerformed method on the element.
I hope this helps someone (and hopefully what I have here makes sense);












