관리 메뉴

moozi

3/23 haksa 본문

TIS_2021/인공지능2021_1기

3/23 haksa

moozi 2021. 3. 23. 11:23
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class Haksa extends JFrame{

	JTextField tfId=null;
	JTextField tfName=null;
	JTextField tfDepartment=null;
	JTextField tfAddress=null;
	
	JTextArea taList=null;
	
	JButton btnInsert=null;
	JButton btnSelect=null;
	JButton btnUpdate=null;
	JButton btnDelete=null;
	
	public Haksa() {
		this.setTitle("학사관리");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		Container c=this.getContentPane();
		c.setLayout(new FlowLayout());
		
		c.add(new JLabel("학번"));
		this.tfId=new JTextField(20);
		c.add(this.tfId);
		
		c.add(new JLabel("이름"));
		this.tfName=new JTextField(20);
		c.add(this.tfName);
		
		c.add(new JLabel("학과"));
		this.tfDepartment=new JTextField(20);
		c.add(this.tfDepartment);
		
		c.add(new JLabel("주소"));
		this.tfAddress=new JTextField(20);
		c.add(this.tfAddress);
		
		this.taList=new JTextArea(10,23);
		c.add(new JScrollPane(this.taList));
		
		this.btnInsert=new JButton("등록");
		c.add(this.btnInsert);
		this.btnInsert.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				//DB연동. 데이터를 insert				
				JOptionPane.showMessageDialog(null, "등록되었습니다");
				
			}});
		
		this.btnSelect=new JButton("목록");
		c.add(this.btnSelect);
		
		this.btnUpdate=new JButton("수정");
		c.add(this.btnUpdate);
		
		this.btnDelete=new JButton("삭제");
		c.add(this.btnDelete);
		this.btnDelete.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				int result=JOptionPane.showConfirmDialog(null, "삭제하시겠습니까?","알림",JOptionPane.YES_NO_OPTION);
				System.out.println(result);
				if(result==JOptionPane.YES_OPTION) {
					//삭제처리
					
				}
			}});
		
		this.setSize(300, 500);
		this.setVisible(true);
	}
	public static void main(String[] args) {
		new Haksa();
	}

}

'TIS_2021 > 인공지능2021_1기' 카테고리의 다른 글

년도,상품별 판매갯수합계 판매되지 않은 상품도 출력하기  (0) 2021.03.31
자바연습문제풀이  (0) 2021.03.29
Haksa  (0) 2021.03.18
for each  (0) 2021.03.09
HelloWorld  (0) 2021.03.04
Comments