관리 메뉴

moozi

Haksa 샘플 본문

TIS_2017/응용sw_2기

Haksa 샘플

moozi 2017. 7. 6. 15:43

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.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class Haksa extends JFrame {
 Container contentPane;
 String[] language={"영어","중국어","일본어","기타"};
 
 Haksa(){
  this.setTitle("학사관리");
  this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
  this.contentPane=getContentPane();
  this.contentPane.setLayout(new FlowLayout());
  
  this.contentPane.add(new JLabel("이름"));
  this.contentPane.add(new JTextField(10));
  
  this.contentPane.add(new JLabel("학번"));
  this.contentPane.add(new JTextField(12));
  
  this.contentPane.add(new JLabel("학과"));
  this.contentPane.add(new JTextField(25));
  
  this.contentPane.add(new JLabel("주소"));
  this.contentPane.add(new JTextField(25));
  
  this.contentPane.add(new JLabel("외국어"));
  JComboBox cb1=new JComboBox(language);
  cb1.addActionListener(new ActionListener(){
   @Override
   public void actionPerformed(ActionEvent arg0) {
    JComboBox cb=(JComboBox)arg0.getSource();
    System.out.println(cb.getSelectedIndex());
    System.out.println(language[cb.getSelectedIndex()]);
   }});
  this.contentPane.add(cb1);
  
  this.contentPane.add(new JScrollPane(new JTextArea(10,28)));
  
  this.contentPane.add(new JButton("입력"));
  this.contentPane.add(new JButton("수정"));
  this.contentPane.add(new JButton("삭제"));
  this.contentPane.add(new JButton("목록"));
  
  this.setSize(350,400);
  this.setVisible(true);
 }

 
 public static void main(String[] args) {
  new Haksa();

 }

}

'TIS_2017 > 응용sw_2기' 카테고리의 다른 글

자바연습문제14  (0) 2017.07.10
자바연습문제13  (0) 2017.07.07
자바연습문제12  (0) 2017.07.06
자바연습문제11  (0) 2017.07.05
자바연습문제01풀이  (0) 2017.07.05
Comments