Re: Drop-Down-Menu in JToolbar
- From: Andrew Thompson <andrewthommo@xxxxxxxxx>
- Date: Tue, 27 May 2008 00:48:54 -0700 (PDT)
On May 26, 9:13 pm, Thorsten Kiefer <thorstenkie...@xxxxxx> wrote:
...
...It's not possible to add JPopupMenu to JToolbar.
Which Java are you using?
Or perhaps I should ask, which JavaDocs are you
*failing* to use?
<sscce>
import javax.swing.*;
class ToolBarWithPopupMenu {
public static void main(String[] args) {
Runnable r = new Runnable() {
public void run() {
JFrame f = new JFrame();
JToolBar tb = new JToolBar();
JPopupMenu popup = new JPopupMenu();
tb.setComponentPopupMenu( popup );
for (int ii=0; ii<4; ii++) {
tb.add( new JButton("" + ii) );
popup.add( "" + ii);
}
f.add( tb );
f.pack();
f.setVisible(true);
}
};
java.awt.EventQueue.invokeLater(r);
}
}
</sscce>
--
Andrew T.
PhySci.org
.
- References:
- Drop-Down-Menu in JToolbar
- From: Thorsten Kiefer
- Drop-Down-Menu in JToolbar
- Prev by Date: Re: Drop-Down-Menu in JToolbar
- Next by Date: Using two JFrames with one always mimicking the other
- Previous by thread: Re: Drop-Down-Menu in JToolbar
- Next by thread: Using two JFrames with one always mimicking the other
- Index(es):