package client;
import java.awt.*;
import javax.swing.*;

public class Graph extends JFrame{
	
	public JPanel panel1;
	public JPanel panel2;
	public JPanel panel3;
	public JLabel showtext=new JLabel();
	public JLabel showgraph=new JLabel();
	
	public JButton Dbutton[] = new JButton[16];
	public JButton Sbutton[] = new JButton[36];
	public JButton Cbutton[] = new JButton[18];
	public JButton sure=new  JButton("確定");
	public JButton cancel=new  JButton("取消");

	private String dynamicname="dynamicimage\\dy_abaon";
	private String silentname="silentimage\\";
	private String cartonname="cartonimage\\";
	
	public Icon Dynamicimage[]=new Icon[16];
	public Icon Silentimage[]=new Icon[36];	
	public Icon Cartonimage[]=new Icon[18];
	
	public String repre="";

	Container c;
    	
	public Graph(){
		super("請選擇圖片");
		c=getContentPane();
		c.setLayout(null);
		setBounds(100, 100, 500, 630);
		
		panel1=new JPanel();
		panel1.setLayout(new GridLayout(3,12));
		
		panel2=new JPanel();
		panel2.setLayout(new GridLayout(2,8));	
		
		panel3=new JPanel();
		panel3.setLayout(new GridLayout(3,6));
		
		
		showgraph.setLayout(null);
		showtext.setLayout(null);
		
		for(int i=0;i<36;i++)
			Silentimage[i]=new ImageIcon(silentname+i+".gif");
		for(int i=0;i<16;i++)
			Dynamicimage[i]=new ImageIcon(dynamicname+i+".gif");		
		for(int i=0;i<18;i++)
			Cartonimage[i]=new ImageIcon(cartonname+i+".gif");
//		buttonaction action=new buttonaction();
		
		for(int i=0;i<36;i++){
			Sbutton[i]=new JButton();
			Sbutton[i].setIcon(Silentimage[i]);
//			Sbutton[i].addActionListener(action);
			panel1.add(Sbutton[i]);
		}
		for(int i=0;i<16;i++){
			Dbutton[i]=new JButton();
			Dbutton[i].setIcon(Dynamicimage[i]);
//			Dbutton[i].addActionListener(action);
			panel2.add(Dbutton[i]);
		}
		for(int i=0;i<18;i++){
			Cbutton[i]=new JButton();
			Cbutton[i].setIcon(Cartonimage[i]);
//			Cbutton[i].addActionListener(action);
			panel3.add(Cbutton[i]);
		}

		panel1.setBorder(BorderFactory.createTitledBorder("靜態"));
		panel1.setBounds(5,5,480,128);
		c.add(panel1);

		panel2.setBorder(BorderFactory.createTitledBorder("動態"));
		panel2.setBounds(5,135,480,135);
		c.add(panel2);
		
		panel3.setBorder(BorderFactory.createTitledBorder("卡通"));
		panel3.setBounds(5,272,480,220);
		c.add(panel3);
		
		showgraph.setBounds(5,492,100,90);
		showgraph.setBorder(BorderFactory.createTitledBorder("顯示圖片"));
		c.add(showgraph);
		
		showtext.setBounds(120,492,200,90);
		showtext.setBorder(BorderFactory.createTitledBorder("顯示快速鍵(前後記得加空白鍵)"));
		c.add(showtext);
		
		
		sure.setBounds(350,500,130,30);
//		sure.addActionListener(new ActionListener(){
//				public void actionPerformed(ActionEvent e) {
//					setVisible(false);
//						
//				}	
//		}
//		);
		cancel.setBounds(350,540,130,30);
//		sure.addActionListener(new ActionListener() {
//			public void actionPerformed(ActionEvent e) {
//				setVisible(false);
//				
//			}
//		});
		c.add(sure);
		c.add(cancel);
		
		setResizable(false);
		setLocation(100,100);
		setVisible(false);
	}
//	private class buttonaction implements ActionListener{
//		public void actionPerformed(ActionEvent e) {
//			String t="";
//			for(int i=0;i<36;i++){
//				if(e.getSource()==Sbutton[i]){
//					t=" S"+i+" ";
//					showgraph.setIcon(Sbutton[i].getIcon());
//					showtext.setText(t);
//					pressed=true;
////					set_graph_text(t);
//
//				}
//			}
//			for(int i=0;i<16;i++){
//				if(e.getSource()==Dbutton[i]){
//					t=" D"+i+" ";
////					set_graph_text(t);
//					showgraph.setIcon(Dbutton[i].getIcon());
//					showtext.setText(t);
//					pressed=true;
//				}
//			}
//			for(int i=0;i<18;i++){
//				if(e.getSource()==Cbutton[i]){
//					t=" C"+i+" ";
////					set_graph_text(t);
//					showtext.setText(t);
//					showgraph.setIcon(Cbutton[i].getIcon());
//					pressed=true;
//				}
//			}			
//		}
//	}

}