List of usage examples for javax.swing JMenu add
public JMenuItem add(Action a)
From source file:ScreenCapture.java
public ScreenCapture(String title) { super(title); setDefaultCloseOperation(EXIT_ON_CLOSE); JMenuBar mb = new JMenuBar(); JMenu menu = new JMenu("File"); ActionListener al;/*w ww. j a v a 2 s .com*/ JMenuItem mi = new JMenuItem("Save"); al = new ActionListener() { public void actionPerformed(ActionEvent e) { save(); } }; mi.addActionListener(al); menu.add(mi); mb.add(menu); menu = new JMenu("Capture"); mi = new JMenuItem("Capture"); al = new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); BufferedImage biScreen = robot.createScreenCapture(rectScreenSize); setVisible(true); ia.setImage(biScreen); jsp.getHorizontalScrollBar().setValue(0); jsp.getVerticalScrollBar().setValue(0); } }; mi.addActionListener(al); menu.add(mi); mb.add(menu); mi = new JMenuItem("Crop"); al = new ActionListener() { public void actionPerformed(ActionEvent e) { if (ia.crop()) { jsp.getHorizontalScrollBar().setValue(0); jsp.getVerticalScrollBar().setValue(0); } } }; mi.addActionListener(al); menu.add(mi); mb.add(menu); setJMenuBar(mb); getContentPane().add(jsp = new JScrollPane(ia)); setVisible(true); }
From source file:misc.ActionDemo.java
public JMenuBar createMenuBar() { JMenuItem menuItem = null;// www. j a v a2s .c o m JMenuBar menuBar; //Create the menu bar. menuBar = new JMenuBar(); //Create the first menu. JMenu mainMenu = new JMenu("Menu"); Action[] actions = { leftAction, middleAction, rightAction }; for (int i = 0; i < actions.length; i++) { menuItem = new JMenuItem(actions[i]); menuItem.setIcon(null); //arbitrarily chose not to use icon mainMenu.add(menuItem); } //Set up the menu bar. menuBar.add(mainMenu); menuBar.add(createAbleMenu()); return menuBar; }
From source file:de.huberlin.cuneiform.compiler.debug.DebugDispatcher.java
private void addMenu() { JMenuBar menuBar;/*from www .ja va 2s . c om*/ JMenu fileMenu; JMenu helpMenu; JMenuItem aboutItem; menuBar = new JMenuBar(); frame.setJMenuBar(menuBar); fileMenu = new JMenu("File"); menuBar.add(fileMenu); openItem = new JMenuItem("Open File ..."); fileMenu.add(openItem); exitItem = new JMenuItem("Exit"); exitItem.addActionListener(this); fileMenu.add(exitItem); helpMenu = new JMenu("Help"); menuBar.add(helpMenu); aboutItem = new JMenuItem("About Cuneiform"); helpMenu.add(aboutItem); }
From source file:de.burrotinto.jKabel.dispalyAS.DisplayK.java
@Bean(name = "trommeln") public JMenu allTrommel(IDBWrapper db) { JMenu m = new JMenu("Trommeln"); db.getAllKabeltypen().forEach(new Consumer<IKabeltypE>() { @Override//from ww w. j a v a 2 s . c om public void accept(IKabeltypE iKabeltypE) { iKabeltypE.getTrommeln().forEach(new Consumer<ITrommelE>() { @Override public void accept(ITrommelE iTrommelE) { m.add(iTrommelE.getId() + " " + iTrommelE.getTrommelnummer()); } }); } }); return m; }
From source file:MenuExample.java
public MenuExample() { menuBar = new JMenuBar(); JMenu formatMenu = new JMenu("Justify"); formatMenu.setMnemonic('J'); MenuAction leftJustifyAction = new MenuAction("Left", new ImageIcon("1.gif")); MenuAction rightJustifyAction = new MenuAction("Right", new ImageIcon("2.gif")); MenuAction centerJustifyAction = new MenuAction("Center", new ImageIcon("3.gif")); MenuAction fullJustifyAction = new MenuAction("Full", new ImageIcon("4.gif")); JMenuItem item;/* w w w .j a va 2s. c om*/ item = formatMenu.add(leftJustifyAction); item.setMnemonic('L'); item = formatMenu.add(rightJustifyAction); item.setMnemonic('R'); item = formatMenu.add(centerJustifyAction); item.setMnemonic('C'); item = formatMenu.add(fullJustifyAction); item.setMnemonic('F'); menuBar.add(formatMenu); menuBar.setBorder(new BevelBorder(BevelBorder.RAISED)); }
From source file:ImageProcessingTest.java
public ImageProcessingFrame() { setTitle("ImageProcessingTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); add(new JComponent() { public void paintComponent(Graphics g) { if (image != null) g.drawImage(image, 0, 0, null); }// w ww . ja v a 2 s . c om }); JMenu fileMenu = new JMenu("File"); JMenuItem openItem = new JMenuItem("Open"); openItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { openFile(); } }); fileMenu.add(openItem); JMenuItem exitItem = new JMenuItem("Exit"); exitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0); } }); fileMenu.add(exitItem); JMenu editMenu = new JMenu("Edit"); JMenuItem blurItem = new JMenuItem("Blur"); blurItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { float weight = 1.0f / 9.0f; float[] elements = new float[9]; for (int i = 0; i < 9; i++) elements[i] = weight; convolve(elements); } }); editMenu.add(blurItem); JMenuItem sharpenItem = new JMenuItem("Sharpen"); sharpenItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { float[] elements = { 0.0f, -1.0f, 0.0f, -1.0f, 5.f, -1.0f, 0.0f, -1.0f, 0.0f }; convolve(elements); } }); editMenu.add(sharpenItem); JMenuItem brightenItem = new JMenuItem("Brighten"); brightenItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { float a = 1.1f; // float b = 20.0f; float b = 0; RescaleOp op = new RescaleOp(a, b, null); filter(op); } }); editMenu.add(brightenItem); JMenuItem edgeDetectItem = new JMenuItem("Edge detect"); edgeDetectItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { float[] elements = { 0.0f, -1.0f, 0.0f, -1.0f, 4.f, -1.0f, 0.0f, -1.0f, 0.0f }; convolve(elements); } }); editMenu.add(edgeDetectItem); JMenuItem negativeItem = new JMenuItem("Negative"); negativeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { short[] negative = new short[256 * 1]; for (int i = 0; i < 256; i++) negative[i] = (short) (255 - i); ShortLookupTable table = new ShortLookupTable(0, negative); LookupOp op = new LookupOp(table, null); filter(op); } }); editMenu.add(negativeItem); JMenuItem rotateItem = new JMenuItem("Rotate"); rotateItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { if (image == null) return; AffineTransform transform = AffineTransform.getRotateInstance(Math.toRadians(5), image.getWidth() / 2, image.getHeight() / 2); AffineTransformOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_BICUBIC); filter(op); } }); editMenu.add(rotateItem); JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(editMenu); setJMenuBar(menuBar); }
From source file:MainClass.java
public MainClass() { menuBar = new JMenuBar(); JMenu formatMenu = new JMenu("Justify"); formatMenu.setMnemonic('J'); MenuAction leftJustifyAction = new MenuAction("Left", new ImageIcon("left.gif")); MenuAction rightJustifyAction = new MenuAction("Right", new ImageIcon("right.gif")); MenuAction centerJustifyAction = new MenuAction("Center", new ImageIcon("center.gif")); MenuAction fullJustifyAction = new MenuAction("Full", new ImageIcon("full.gif")); JMenuItem item;//from w w w . jav a 2s. co m item = formatMenu.add(leftJustifyAction); item.setMnemonic('L'); item = formatMenu.add(rightJustifyAction); item.setMnemonic('R'); item = formatMenu.add(centerJustifyAction); item.setMnemonic('C'); item = formatMenu.add(fullJustifyAction); item.setMnemonic('F'); menuBar.add(formatMenu); menuBar.setBorder(new BevelBorder(BevelBorder.RAISED)); }
From source file:it.unibas.spicygui.vista.QueryTabbedPane.java
public void creaPopUp() { this.popUpMenu = new JPopupMenu(); this.popUpMenu.add(new ActionIncreaseFont(textArea)); this.popUpMenu.add(new ActionDecreaseFont(textArea)); this.popUpMenu.add(new ActionExportQuery(textArea)); if (xQuery) { MappingTask mappingTask = scenario.getMappingTask(); if (mappingTask.getSourceProxy().getType().equalsIgnoreCase(SpicyEngineConstants.TYPE_XML)) { JMenu jMenu = new JMenu(NbBundle.getMessage(Costanti.class, Costanti.ACTION_EXECUTE_XQUERY)); this.popUpMenu.add(jMenu); List<String> sourceInstancesName = (List<String>) mappingTask.getSourceProxy() .getAnnotation(SpicyEngineConstants.XML_INSTANCE_FILE_LIST); for (String instance : sourceInstancesName) { jMenu.add(new ActionExecuteXQuery(instance, scenario.getMappingTask())); }//www .j av a 2 s.co m } } else { this.popUpMenu.add(new ActionExecuteSql(textArea, scenario.getMappingTask())); } this.textArea.addMouseListener(new PopUpListener()); }
From source file:ca.phon.app.session.editor.view.session_information.SessionInfoEditorView.java
@Override public JMenu getMenu() { final JMenu menu = new JMenu(); menu.add(new BrowseForMediaAction(getEditor(), this)); menu.addSeparator();//w w w .j a v a 2s . c o m final Session session = getEditor().getSession(); for (Participant p : session.getParticipants()) { final JMenu speakerMenu = new JMenu(p.getName()); speakerMenu.add(new EditParticipantAction(getEditor(), this, p)); speakerMenu.add(new DeleteParticipantAction(getEditor(), this, p)); menu.add(speakerMenu); } menu.add(new NewParticipantAction(getEditor(), this)); return menu; }
From source file:daylightchart.gui.DaylightChartGui.java
private void createHelpMenu(final JMenuBar menuBar, final JToolBar toolBar) { final GuiAction onlineHelp = new OnlineHelpAction(); final GuiAction about = new AboutAction(DaylightChartGui.this); final JMenu menuHelp = new JMenu(Messages.getString("DaylightChartGui.Menu.Help")); //$NON-NLS-1$ menuHelp.setMnemonic('H'); menuHelp.add(onlineHelp); menuHelp.add(about);/*from w w w.j a va2 s . co m*/ menuBar.add(menuHelp); toolBar.addSeparator(); toolBar.add(onlineHelp); }