package extractor.ui.servletUI;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;

import java.util.*;

public class ServletNameTFUI extends JPanel implements ActionListener
{
	JPanel textGroupPane;
	JTextArea nameField;
	JScrollPane nameFieldPane;
	JTextArea deleteField;
	JScrollPane deleteFieldPane;
	JTextArea addField;
	JScrollPane addFieldPane;
	JTextArea resultField;
	JScrollPane resultFieldPane;
	
	JButton okBtn;
	JPanel btnPane;
	
	public ServletNameTFUI()
	{
		setLayout(new BorderLayout());
		
		textGroupPane = new JPanel(new GridLayout(4, 0, 10, 10));		
		textGroupPane.setBorder(BorderFactory.createTitledBorder("서블릿 이름을 바꿉니다"));		
		
		nameField = new JTextArea();
		nameFieldPane = new JScrollPane(nameField);
		nameFieldPane.setBorder(BorderFactory.createTitledBorder("자바 클래스 이름 : "));				


		deleteField = new JTextArea();
		deleteFieldPane = new JScrollPane(deleteField);
		deleteFieldPane.setBorder(BorderFactory.createTitledBorder("삭제할 코드 : "));				
		
		addField = new JTextArea();
		addFieldPane = new JScrollPane(addField);
		addFieldPane.setBorder(BorderFactory.createTitledBorder("추가할 코드 : "));			
		
		resultField = new JTextArea();		
		resultFieldPane = new JScrollPane(resultField);
		resultFieldPane.setBorder(BorderFactory.createTitledBorder("변환 결과 : "));			
		
		textGroupPane.add(nameFieldPane);
		textGroupPane.add(deleteFieldPane);
		textGroupPane.add(addFieldPane);
		//textGroupPane.add(resultFieldPane);
		
		btnPane = new JPanel();
		okBtn = new JButton("OK");
		okBtn.addActionListener(this);
		btnPane.add(okBtn);
		
		add(textGroupPane, BorderLayout.CENTER);		
		//add(btnPane, BorderLayout.SOUTH);
		
		setSize(100, 50);
	}

	public void actionPerformed(ActionEvent e) 
	{
		Object obj = e.getSource();
		if(obj == okBtn)
		{
			System.out.println("I'm an ok button.");
			this.removeAll();
			this.add(new ServletVariableTFUI(), BorderLayout.CENTER);			
			this.validate();	
		}
	}
	
	public static void main(String[] arg)
	{
		JFrame f = new JFrame();
		ServletNameTFUI sName = new ServletNameTFUI();
		f.getContentPane().add(sName);
		f.setVisible(true);
		f.pack();
	}
	
}