Hi,
Is this possible to implement on either JFrame or JApplet?
Having multiple JMenuBar (like toolbars of Microsoft Office 2003) wherein you could set images as a menu.
Thanks,
Cyril H.
Printable View
Hi,
Is this possible to implement on either JFrame or JApplet?
Having multiple JMenuBar (like toolbars of Microsoft Office 2003) wherein you could set images as a menu.
Thanks,
Cyril H.
You *can* add more than one JMenuBar to a parent JMenuBar after setting an appropriate layout -- possibly GridLayout(0, 1) -- and set the parent JMenuBar to a JFrame.
db
Maybe you are looking to use a JToolBar?
JToolBar (Java 2 Platform SE v1.4.2)
dbCode:import java.awt.GridLayout;
import javax.swing.*;
public class NestedMenuBar {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new NestedMenuBar().makeUI();
}
});
}
public void makeUI() {
JMenuBar outerBar = new JMenuBar();
outerBar.setLayout(new GridLayout(0, 1));
for (int i = 0; i < 2; i++) {
JMenu menu = new JMenu("Menu " + i);
menu.add(new JMenuItem("Item " + i));
JMenuBar innerBar = new JMenuBar();
innerBar.add(menu);
outerBar.add(innerBar);
}
JFrame frame = new JFrame();
frame.setJMenuBar(outerBar);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 400);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
Please don't post links to Java API for old versions that are already EOL.
JToolBar (Java Platform SE 6)
db
Either solution of Darryl.Burke and StormyWaters solved this thread.
Thanks.
Cyril H.