public class TestToolbar extends AbstractMDIApplication { public TestToolbar() { super("Test ToolBar"); this.initConfiguration(); mfactory = new SimpleMenuFactory(); super.preparePanels(4, true, true, mfactory); this.setSize(500, 500); } public static void main(String[] args) { TestToolbar mdi = new TestToolbar(); mdi.setVisible(true); } private class SimpleMenuFactory extends AbstractMDIMenuFactory { private final JMenu filemenu = new JMenu("File"); private int count = 1; public SimpleMenuFactory() { } @Override protected void initMenus() { JMenuItem exitItem = new JMenuItem(getDefaultExitAction("Exit")); filemenu.add(exitItem); Mbar.add(filemenu); JToolBar tbar = new JToolBar("Tools"); AbstractAction action = new AbstractAction("Action") { @Override public void actionPerformed(ActionEvent e) { getStatusBar().setMessage("Performed Action " + count); count++; } }; tbar.add(action); this.getToolBarPanel().add(tbar); } } }
Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences