//
// MainFrame.java
//

package imagej.gui;

import imagej.plugin.api.PluginEntry;
import imagej.plugin.api.PluginUtils;
import imagej.plugin.gui.ShadowMenu;
import imagej.plugin.gui.swing.JMenuBarCreator;

import java.awt.BorderLayout;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;

/** A simple and dumb Swing-based main window for ImageJ2. */
public class MainFrame {

	private JPanel mainPanel;
	private StatusBar statusBar;

	/** Creates a new ImageJ frame that runs as an application. */
	public MainFrame() {
		final JFrame frame = new JFrame("ImageJ");
		frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		createContentPane(frame);
		createMenuBar(frame);
		frame.pack();
		frame.setVisible(true);
	}

	private void createContentPane(JFrame frame) {
		final JPanel pane = new JPanel();
		frame.setContentPane(pane);
		pane.setLayout(new BorderLayout());

		mainPanel = new JPanel();
		mainPanel.setBorder(new EmptyBorder(15, 15, 15, 15));
		pane.add(mainPanel, BorderLayout.CENTER);

		statusBar = new StatusBar();
		pane.add(statusBar, BorderLayout.SOUTH);
	}

	private void createMenuBar(JFrame frame) {
		final List<PluginEntry<?>> entries = PluginUtils.findPlugins();
		statusBar.setText("Discovered " + entries.size() + " plugins");
		final ShadowMenu rootMenu = new ShadowMenu(entries);
		final JMenuBar menuBar = new JMenuBar();
		new JMenuBarCreator().createMenus(rootMenu, menuBar);
		frame.setJMenuBar(menuBar);
	}

	public static void main(String[] args) {
		new MainFrame();
	}

}

@@ -231,16 +231,43 @@
 Layout;%0A
+import java.awt.Dimension;%0A
 import j
@@ -281,16 +281,16 @@
 l.List;%0A
-
 %0Aimport 
@@ -365,16 +365,45 @@
 JPanel;%0A
+import javax.swing.JToolBar;%0A
 import j
@@ -433,47 +433,8 @@
 nts;
-%0Aimport javax.swing.border.EmptyBorder;
 %0A%0A/*
@@ -533,23 +533,23 @@
 te J
-Panel mainPanel
+ToolBar toolBar
 ;%0A%09p
@@ -659,24 +659,84 @@
 inFrame() %7B%0A
+%09%09System.setProperty(%22apple.laf.useScreenMenuBar%22, %22true%22);%0A
 %09%09final JFra
@@ -1090,89 +1090,95 @@
 %0A%0A%09%09
-mainPanel = new JPanel();%0A%09%09mainPanel.setBorder(new EmptyBorder(15, 15, 15, 15));
+toolBar = new JToolBar();%0A%09%09toolBar.setPreferredSize(new Dimension(26 * 21, 26));//TEMP
 %0A%09%09p
@@ -1189,17 +1189,15 @@
 add(
-mainPanel
+toolBar
 , Bo
@@ -1211,14 +1211,13 @@
 out.
-CENTER
+NORTH
 );%0A%0A

Add toolbar to main frame, and use screen menu bar on Macs.