반응형
package Swing; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JOptionPane; public class MenuTest extends JFrame { public MenuTest(){ setTitle("Menu && PopUp"); setBounds(150,150,350,350); setVisible(true); // 메뉴 바생성 JMenuBar mu= new JMenuBar(); JMenu menu1 = new JMenu("대화상자(P)"); menu1.setMnemonic('p'); JMenuItem item1 = new JMenuItem("Open"); item1.setMnemonic('o'); // item1.addActionListener(new ActionListener() { // // public void actionPerformed(ActionEvent arg0) { // JOptionPane.showMessageDialog(self,"열기를누룸","Open",JOptionPane.INFORMATION_MESSAGE); // // } // }); menu1.add(item1); JMenuItem item2 = new JMenuItem("Save"); item1.setMnemonic('s'); menu1.add(item2); this.addMouseListener(new MouseAdapter(){ public void mousePressed(MouseEvent e){ //마우스 오른쪽 누르는것을 확인하는것 // if(e.isPopupTrigger()) } }); mu.add(menu1); // 프레임에 부착 setJMenuBar(mu); } }
'JAVA > Java' 카테고리의 다른 글
[JAVA] swing Frame (0) | 2014.11.18 |
---|---|
[JAVA] swing Table 만들기 (2) | 2014.11.18 |
[JAVA] swing (0) | 2014.11.18 |
[JAVA] swing ImageButton 만들기 (0) | 2014.11.18 |
[JAVA] Serializable 사용하기 (0) | 2014.11.18 |