package ITUannotation;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JButton;

import java.awt.Component;
import java.awt.Rectangle;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.io.FileNotFoundException;
import java.io.FileNotFoundException;

import javax.swing.JLabel;
import javax.swing.BorderFactory;
import javax.swing.border.BevelBorder;

public class Main_Menu extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JButton BicimselCozumlemeBut = null;
	private JButton sozdizAnalizBut = null;
	private JButton EngBut = null;
	private JLabel iletisimLab = null;
	private JButton jButtonExit = null;
	private Language lang;

	/**
	 * This is the default constructor
	 */
	public Main_Menu() {
		super();
		lang=new Language(1);
		//LangIndex=1;
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		
		this.setSize(776, 240);
		this.setContentPane(getJContentPane());
		
		this.setTitle(lang.getLan(0,lang.getLangIndex()));//("İTÜ Türkçe Ağaç Yapılı Derlem Oluşturma Arayüzü");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
		this.setResizable(false);
	}

	
	
	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			iletisimLab = new JLabel();
			iletisimLab.setBounds(new Rectangle(5, 159, 492, 26));
			iletisimLab.setToolTipText("");
			iletisimLab.setText(lang.getLan(4,lang.getLangIndex())+": Gülşen Cebiroğlu Eryiğit (gulsenc@itu.edu.tr)");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
			jContentPane.add(getBicimselCozumlemeBut(), null);
			jContentPane.add(getSozdizAnalizBut(), null);
			jContentPane.add(getEngBut(), null);
			jContentPane.add(iletisimLab, null);
			jContentPane.add(getJButtonExit(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes BicimselCozumlemeBut	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getBicimselCozumlemeBut() {
		if (BicimselCozumlemeBut == null) {
			BicimselCozumlemeBut = new JButton();
			BicimselCozumlemeBut.setBounds(new Rectangle(108, 16, 560, 33));
			BicimselCozumlemeBut.setText(lang.getLan(1,lang.getLangIndex()));
		}
		
		BicimselCozumlemeBut.addActionListener(new ActionListener(){

			public void actionPerformed(ActionEvent e) {
				Morphological_Analysis_Interface form = new Morphological_Analysis_Interface(lang.getLangIndex());
				form.setVisible(true);
			}
			
			
		});
		return BicimselCozumlemeBut;
	}

	/**
	 * This method initializes sozdizAnalizBut	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getSozdizAnalizBut() {
		if (sozdizAnalizBut == null) {
			sozdizAnalizBut = new JButton();
			sozdizAnalizBut.setBounds(new Rectangle(108, 74, 560, 33));
			sozdizAnalizBut.setText(lang.getLan(2,lang.getLangIndex()));
			sozdizAnalizBut.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					//System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
					try {
						Syntactic_Analysis_Interface form2 = new Syntactic_Analysis_Interface(lang.getLangIndex());
						form2.setVisible(true);
					
					} catch (FileNotFoundException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
				
				}
			});
		}
		return sozdizAnalizBut;
	}

	/**
	 * This method initializes EngBut	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getEngBut() {
		if (EngBut == null) {
			EngBut = new JButton();
			EngBut.setBounds(new Rectangle(514, 163, 143, 20));
			EngBut.setText(lang.getLan(3,lang.getLangIndex()));
			EngBut.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					if(lang.getLangIndex()==0)
						lang.setLangIndex(1);
					else
						lang.setLangIndex(0);
				initialize();
				changeLan();
				}
			});
		}
		return EngBut;
	}

	/**
	 * This method initializes jButtonExit	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonExit() {
		if (jButtonExit == null) {
			jButtonExit = new JButton();
			jButtonExit.setBounds(new Rectangle(674, 163, 77, 20));
			jButtonExit.setText(lang.getLan(5,lang.getLangIndex()));
		}
		
		jButtonExit.addActionListener(new ActionListener(){

			public void actionPerformed(ActionEvent e) {
				System.exit(1);			
			}
			
		});
		
		return jButtonExit;
	}
	public void changeLan()
	{
		BicimselCozumlemeBut.setText(lang.getLan(1,lang.getLangIndex()));
		sozdizAnalizBut.setText(lang.getLan(2,lang.getLangIndex()));
		EngBut.setText(lang.getLan(3,lang.getLangIndex()));
		iletisimLab.setText(lang.getLan(4,lang.getLangIndex())+": Gülşen Cebrioğlu Eryiğit (gulsen.cebiroglu@itu.edu.tr)");
		jButtonExit.setText(lang.getLan(5,lang.getLangIndex()));
		
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
