use of java.awt.Menu in project jdk8u_jdk by JetBrains.
the class RemoveHelpMenu method test4.
private static void test4(final MenuBar menuBar) {
final Menu helpMenu = new Menu("Help Menu");
menuBar.setHelpMenu(helpMenu);
checkCurrentMenu(menuBar, helpMenu);
checkMenuCount(menuBar, 1);
checkHelpMenu(helpMenu, true);
menuBar.setHelpMenu(null);
checkCurrentMenu(menuBar, null);
checkMenuCount(menuBar, 0);
checkHelpMenu(helpMenu, false);
}
use of java.awt.Menu in project jdk8u_jdk by JetBrains.
the class AWTInputMethodPopupMenu method addMenuItem.
void addMenuItem(Object targetMenu, String label, String command, String currentSelection) {
MenuItem menuItem;
if (isSelected(command, currentSelection)) {
menuItem = new CheckboxMenuItem(label, true);
} else {
menuItem = new MenuItem(label);
}
menuItem.setActionCommand(command);
menuItem.addActionListener(this);
menuItem.setEnabled(command != null);
((Menu) targetMenu).add(menuItem);
}
use of java.awt.Menu in project processdash by dtuma.
the class ScriptMenuReplicator method addMenuItems.
private void addMenuItems(Menu destMenu, List menuItems, int pos) {
for (Object item : menuItems) {
if (item instanceof String) {
String dataPath = (String) item;
destMenu.insert(new ScriptMenuSeparator(), ++pos);
destMenu.insert(new ScriptMenuHeader(dataPath), ++pos);
} else if (item instanceof ScriptID) {
ScriptID script = (ScriptID) item;
destMenu.insert(new ScriptMenuItem(script), ++pos);
} else if (item instanceof List) {
Menu submenu = new ScriptMenuSubmenu();
destMenu.insert(submenu, ++pos);
addMenuItems(submenu, (List) item, -1);
} else {
System.out.println("Warning! Unrecognized menu item type " + item);
}
}
}
use of java.awt.Menu in project litiengine by gurkenlabs.
the class Program method setupInterface.
private static void setupInterface() {
MenuBar menuBar = new MenuBar();
JFrame window = ((JFrame) Game.getScreenManager());
Game.onTerminating(s -> {
boolean terminate = notifyPendingChanges();
if (terminate) {
getUserPreferences().setFrameState(((JFrame) Game.getScreenManager()).getExtendedState());
}
return terminate;
});
window.setResizable(true);
window.setMenuBar(menuBar);
if (userPreferences.getWidth() != 0 && userPreferences.getHeight() != 0) {
window.setSize(userPreferences.getWidth(), userPreferences.getHeight());
}
if (userPreferences.getFrameState() != JFrame.ICONIFIED && userPreferences.getFrameState() != JFrame.NORMAL) {
window.setExtendedState(userPreferences.getFrameState());
}
Canvas canvas = Game.getScreenManager().getRenderComponent();
canvas.setFocusable(true);
canvas.setSize((int) (window.getSize().width * 0.75), window.getSize().height);
window.remove(canvas);
JPanel renderPane = new JPanel(new BorderLayout());
renderPane.add(canvas);
renderPane.setMinimumSize(new Dimension(300, 0));
initCanvasPopupMenu(canvas);
JPanel contentPane = new JPanel(new BorderLayout());
window.setContentPane(contentPane);
horizontalScroll = new JScrollBar(JScrollBar.HORIZONTAL);
renderPane.add(horizontalScroll, BorderLayout.SOUTH);
verticalScroll = new JScrollBar(JScrollBar.VERTICAL);
renderPane.add(verticalScroll, BorderLayout.EAST);
horizontalScroll.addAdjustmentListener(e -> {
if (EditorScreen.instance().getMapComponent().isLoading()) {
return;
}
Point2D newFocus = new Point2D.Double(horizontalScroll.getValue(), Game.getCamera().getFocus().getY());
Game.getCamera().setFocus(newFocus);
});
verticalScroll.addAdjustmentListener(e -> {
if (EditorScreen.instance().getMapComponent().isLoading()) {
return;
}
Point2D newFocus = new Point2D.Double(Game.getCamera().getFocus().getX(), verticalScroll.getValue());
Game.getCamera().setFocus(newFocus);
});
MapObjectPanel mapEditorPanel = new MapObjectPanel();
MapSelectionPanel mapSelectionPanel = new MapSelectionPanel();
JSplitPane mapWrap = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
mapWrap.setMinimumSize(new Dimension(300, 0));
mapWrap.setBottomComponent(mapEditorPanel);
mapWrap.setTopComponent(mapSelectionPanel);
mapWrap.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, evt -> userPreferences.setSelectionEditSplitter(mapWrap.getDividerLocation()));
if (userPreferences.getSelectionEditSplitter() != 0) {
mapWrap.setDividerLocation(userPreferences.getSelectionEditSplitter());
}
JPanel bottomPanel = new JPanel(new BorderLayout());
JTabbedPane bottomTab = new JTabbedPane();
bottomTab.addTab(Resources.get("assettree_assets"), initAssetsComponent());
bottomTab.addTab("Console", initConsole());
bottomTab.setIconAt(0, new ImageIcon(Resources.getImage("asset.png")));
bottomTab.setIconAt(1, new ImageIcon(Resources.getImage("console.png")));
bottomPanel.add(bottomTab, BorderLayout.CENTER);
statusBar = new JLabel("");
statusBar.setPreferredSize(new Dimension(0, 16));
statusBar.setFont(new Font(ConsoleLogHandler.CONSOLE_FONT, Font.PLAIN, 10));
bottomPanel.add(statusBar, BorderLayout.SOUTH);
EditorScreen.instance().getMapComponent().onSelectionChanged(selection -> {
if (selection.isEmpty()) {
statusBar.setText("");
} else {
statusBar.setText(" " + selection.size() + " selected objects");
}
});
JSplitPane rendersplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, renderPane, bottomPanel);
if (userPreferences.getBottomSplitter() != 0) {
rendersplit.setDividerLocation(userPreferences.getBottomSplitter());
} else {
rendersplit.setDividerLocation((int) (window.getSize().height * 0.75));
}
rendersplit.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, evt -> userPreferences.setBottomSplitter(rendersplit.getDividerLocation()));
rendersplit.setContinuousLayout(true);
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, rendersplit, mapWrap);
split.setContinuousLayout(true);
split.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
userPreferences.setWidth(window.getWidth());
userPreferences.setHeight(window.getHeight());
}
});
split.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, evt -> userPreferences.setMainSplitter(split.getDividerLocation()));
contentPane.add(split, BorderLayout.CENTER);
split.setDividerLocation(userPreferences.getMainSplitterPosition() != 0 ? userPreferences.getMainSplitterPosition() : (int) (window.getSize().width * 0.75));
JToolBar toolbar = initToolBar();
contentPane.add(toolbar, BorderLayout.NORTH);
EditorScreen.instance().setMapEditorPanel(mapEditorPanel);
EditorScreen.instance().setMapSelectionPanel(mapSelectionPanel);
Menu mnFile = initFileMenu();
menuBar.add(mnFile);
Menu mnView = initViewMenu();
menuBar.add(mnView);
Menu mnProject = initProjectMenu();
menuBar.add(mnProject);
Menu mnMap = initMapMenu();
menuBar.add(mnMap);
}
use of java.awt.Menu in project litiengine by gurkenlabs.
the class Program method initViewMenu.
private static Menu initViewMenu() {
Menu mnView = new Menu(Resources.get("menu_view"));
CheckboxMenuItem snapToGrid = new CheckboxMenuItem(Resources.get("menu_snapGrid"));
snapToGrid.setState(userPreferences.isSnapGrid());
EditorScreen.instance().getMapComponent().setSnapToGrid(snapToGrid.getState());
snapToGrid.addItemListener(e -> {
EditorScreen.instance().getMapComponent().setSnapToGrid(snapToGrid.getState());
userPreferences.setSnapGrid(snapToGrid.getState());
});
CheckboxMenuItem renderGrid = new CheckboxMenuItem(Resources.get("menu_renderGrid"));
renderGrid.setState(userPreferences.isShowGrid());
EditorScreen.instance().getMapComponent().setRenderGrid(renderGrid.getState());
renderGrid.setShortcut(new MenuShortcut(KeyEvent.VK_G));
renderGrid.addItemListener(e -> {
EditorScreen.instance().getMapComponent().setRenderGrid(renderGrid.getState());
userPreferences.setShowGrid(renderGrid.getState());
});
CheckboxMenuItem renderCollision = new CheckboxMenuItem(Resources.get("menu_renderCollisionBoxes"));
renderCollision.setState(userPreferences.isRenderBoundingBoxes());
EditorScreen.instance().getMapComponent().setRenderCollisionBoxes(renderCollision.getState());
renderCollision.setShortcut(new MenuShortcut(KeyEvent.VK_H));
renderCollision.addItemListener(e -> {
EditorScreen.instance().getMapComponent().setRenderCollisionBoxes(renderCollision.getState());
userPreferences.setRenderBoundingBoxes(renderCollision.getState());
});
MenuItem setGrid = new MenuItem(Resources.get("menu_gridSize"));
setGrid.addActionListener(a -> {
GridEditPanel panel = new GridEditPanel(EditorScreen.instance().getMapComponent().getGridSize());
int option = JOptionPane.showConfirmDialog(Game.getScreenManager().getRenderComponent(), panel, Resources.get("menu_gridSettings"), JOptionPane.DEFAULT_OPTION);
if (option == JOptionPane.OK_OPTION) {
EditorScreen.instance().getMapComponent().setGridSize(panel.getGridSize());
}
});
MenuItem zoomIn = new MenuItem(Resources.get("menu_zoomIn"));
zoomIn.setShortcut(new MenuShortcut(KeyEvent.VK_PLUS));
zoomIn.addActionListener(a -> EditorScreen.instance().getMapComponent().zoomIn());
MenuItem zoomOut = new MenuItem(Resources.get("menu_zoomOut"));
zoomOut.setShortcut(new MenuShortcut(KeyEvent.VK_MINUS));
zoomOut.addActionListener(a -> EditorScreen.instance().getMapComponent().zoomOut());
mnView.add(snapToGrid);
mnView.add(renderGrid);
mnView.add(renderCollision);
mnView.add(setGrid);
mnView.addSeparator();
mnView.add(zoomIn);
mnView.add(zoomOut);
return mnView;
}
Aggregations