10일차 Swing03 클래스 (메뉴 관련 객체 생성, 메뉴 액션리스너 추가)
2014학년도 겨울 심화학기/JAVA
Written by 긍지높은취객 on 2014. 12. 19. 16:01
import java.awt.event.*;
import javax.swing.*;
class MenuActionListener implements ActionListener
{
@Override
public void actionPerformed(ActionEvent e)
{
String cmd = e.getActionCommand();
System. out.println(cmd );
}
}
public class Swing03 extends JFrame
{
Swing03()
{
setTitle( "학사관리 시스템" );
setDefaultCloseOperation( JFrame. EXIT_ON_CLOSE);
JMenuBar bar = new JMenuBar();
JMenu M_student = new JMenu( "학생관리" ); // 학생관리 메뉴
bar.add( M_student); // 학생관리 메뉴 추가
JMenu M_book = new JMenu( "도서관리" ); // 도서관리 메뉴
bar.add( M_book); // 도서관리 메뉴 추가
JMenuItem MI_list = new JMenuItem( "학생목록" ); // 학생목록 세부메뉴
M_student.add( MI_list); // 학생목록 세부메뉴 추가
JMenuItem MI_insert = new JMenuItem("학생등록" ); // 학생등록 세부메뉴
M_student.add( MI_insert); // 학생등록 세부메뉴 추가
JMenuItem MI_update = new JMenuItem("학생수정" ); // 학생수정 세부메뉴
M_student.add( MI_update); // 학생수정 세부메뉴 추가
M_student.addSeparator(); // 구분선 추가
JMenuItem MI_status = new JMenuItem("학적변경" ); // 학적변경 세부메뉴
M_student.add( MI_status); // 학적변경 세부메뉴 추가
// 메뉴 아이템 이벤트 처리
MI_list.addActionListener( new MenuActionListener());
setJMenuBar( bar);
setSize(800, 600);
setVisible( true);
}
public static void main(String [] args)
{
new Swing03();
}
}
'2014학년도 겨울 심화학기 > JAVA' 카테고리의 다른 글
11일차 Student.sql (Swing03용 SQL작성) (0) | 2014.12.22 |
---|---|
11일차 Swing02 클래스 (Table로 출력) (0) | 2014.12.22 |
10일차 Student.sql (주소칼럼 추가) (0) | 2014.12.19 |
10일차 Swing02 클래스 (JDBC/Statement 연결 구문 위치변경, 주소칼럼 추가, 과제) (0) | 2014.12.19 |
9일차 Swing02 클래스 (DML 모두 구현, Alert Dialog / 확인창 구현) (0) | 2014.12.18 |