All pastes #58178 Raw Edit

Miscellany

public java v1 · immutable
#58178 ·published 2006-05-22 22:09 UTC
rendered paste body
import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Edit extends JFrame implements ActionListener {				public static JMenuItem menuItem(String label, int mnemonic, 			int acceleratorKey, String actionCommand) 	{ 		JMenuItem item = new JMenuItem(label); 		if (mnemonic != 0) item.setMnemonic(mnemonic); 		if (acceleratorKey != 0)			item.setAccelerator(KeyStroke.getKeyStroke(acceleratorKey, 					java.awt.Event.CTRL_MASK));		item.setActionCommand(actionCommand);		return item; 	} 		public void actionPerformed(ActionEvent evt)	{					String menuAdd = evt.getActionCommand();											if (menuAdd.equals("New")){				System.out.println("GOGO");			}			else if (menuAdd == "Quit") System.exit(0);		}			public Edit () 	{				JFrame frame = new JFrame();				JMenu file = new JMenu();								JMenuItem itemFile;		itemFile = new JMenuItem("New");		file.add(itemFile);		itemFile.addActionListener(this);						//file.add(menuItem("New", 'N', KeyEvent.VK_N, "New"));		file.add(menuItem("Open", 'O', KeyEvent.VK_O, "Open"));		file.addActionListener(this);		file.add(menuItem("Save", 'S', KeyEvent.VK_S, "Save")); 		file.add(menuItem("Save As", 'U', KeyEvent.VK_U, "Save As"));		file.add(menuItem("Print", 'P', KeyEvent.VK_P, "Print"));		file.add(menuItem("Quit", 'Q', KeyEvent.VK_Q, "Quit"));    		JMenu edit = new JMenu("Edit");		edit.setMnemonic('E');		edit.add(menuItem("Copy", 0, KeyEvent.VK_X, "Copy"));		edit.add(menuItem("Cut", 'C', KeyEvent.VK_C, "Cut")); 		edit.add(menuItem("Paste", 0, KeyEvent.VK_V, "Paste"));		edit.add(menuItem("Select All", 0, KeyEvent.VK_A, "Select All"));		edit.add(menuItem("Search", 0, KeyEvent.VK_F, "Search"));		edit.add(menuItem("Options", 0, 0, "Options"));    		JMenu help = new JMenu("Help");		help.setMnemonic('H');		help.add(menuItem("About", 'A', 0, "About"));		//JOptionPane.showMessageDialog(frame, 		//		"Programm: Da Jetta \n Version: 0.00000000000000001 \n Autoren: Robert Popovici, Jochen Schilling, Florian Kratschman, Dennis Stratmann");			JMenuBar menuBar = new JMenuBar();			menuBar.add(file);		menuBar.add(edit);		menuBar.add(help);				//file.addActionListener(this);		edit.addActionListener(this);		help.addActionListener(this);			Container contentPane = frame.getContentPane();		contentPane.setLayout(new BorderLayout());			frame.setJMenuBar(menuBar);			JTextArea text = new JTextArea();		contentPane.add(text, "Center");			JPanel s = new JPanel();		contentPane.add(s, "North");		s.setLayout( new FlowLayout());		JButton neu = new JButton("New");		JButton open = new JButton("Open");		JButton save = new JButton("Save");		JButton save_as = new JButton("Save As");		s.add(neu);		s.add(open);		s.add(save);		s.add(save_as);			JPanel status = new JPanel();		contentPane.add(status, "South");		JLabel statusLabel = new JLabel("Filename");		status.add(statusLabel);			frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );		frame.setSize(450, 300); 		frame.setVisible(true);	}}