package projetEntreprenariat;

import java.awt.EventQueue;
import java.awt.List;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JTextPane;
import java.awt.Button;
import java.awt.Component;

import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;

import java.awt.event.ActionEvent;
import javax.swing.JList;
import javax.swing.JScrollPane;
import java.awt.Color;

public class AppliSUlation {
	

	DefaultListModel listModel= new DefaultListModel();
	
	private JFrame frmMonfrigo;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					AppliSUlation window = new AppliSUlation();
					window.frmMonfrigo.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public AppliSUlation() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frmMonfrigo = new JFrame();
		frmMonfrigo.setTitle("MonFrigo");
		frmMonfrigo.setBounds(100, 100, 450, 300);
		frmMonfrigo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JPanel panel = new JPanel();
		frmMonfrigo.getContentPane().add(panel, BorderLayout.CENTER);
		panel.setLayout(null);
		
		JLabel lblIngredient = new JLabel("Ingredient:");
		lblIngredient.setBounds(39, 15, 96, 15);
		panel.add(lblIngredient);
		
		JComboBox ingredientComboBox = new JComboBox();
		ingredientComboBox.setModel(new DefaultComboBoxModel(new String[] {"Oeuf", "Farine", "Sucre", "Chocolat", "Fraise", "Cerise", "Citron"}));
		ingredientComboBox.setBounds(153, 15, 156, 20);
		panel.add(ingredientComboBox);
		
		JLabel lblRecette = new JLabel("Vos Recette:");
		lblRecette.setBounds(169, 148, 106, 15);
		panel.add(lblRecette);
		
		JList recetteList = new JList();
		recetteList.setBounds(129, 191, 180, 40);
		panel.add(recetteList);
		
		Button ajouterButton = new Button("Ajouter!");
		ajouterButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
			
				listModel.addElement((String) ingredientComboBox.getSelectedItem());
				//recetteList.ensureIndexIsVisible();
				
				
				
			}
		});
		ajouterButton.setBounds(340, 10, 86, 35);
		panel.add(ajouterButton);
		
		JScrollPane ingredientScrollPan = new JScrollPane();
		ingredientScrollPan.setBounds(129, 63, 180, 56);
		panel.add(ingredientScrollPan);
		

		JList ingredientList = new JList(listModel);
		ingredientList.setBackground(new Color(255, 255, 255));
		ingredientScrollPan.setViewportView(ingredientList);
		
		
	}
}
