package Interfaz;

import estaticas.estaticas;
import java.awt.Color;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

/**
 *
 * @author Jose
 */
public class MainPanelBluetooth extends JPanel{

    public MainPanelBluetooth() {
        setLayout(new GridBagLayout());
        init();
    }

    private void init() {
        defaultListModel = new DefaultListModel();        

        list = new JList(defaultListModel);
        list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
        list.setSelectedIndex(1);
        list.setCellRenderer(new MyCellRendererBluetooth());

        button1 = new JButton("Agregar");
        textArea = new JTextArea();
        textArea.setEnabled(false);
        textArea.setBackground(Color.BLACK);

        add(new JLabel("Lista de equipos :"), estaticas.createConstraints(0, 0, 1, 1, 0.0, 0.0,
                GridBagConstraints.ABOVE_BASELINE_TRAILING, GridBagConstraints.BOTH));
        /*add(button1, estaticas.createConstraints(2, 0, 1, 1, 1.0, 0.0,
                GridBagConstraints.ABOVE_BASELINE_TRAILING, GridBagConstraints.NONE));
        add(button2, estaticas.createConstraints(3, 0, 1, 1, 0.0, 0.0,
                GridBagConstraints.ABOVE_BASELINE_TRAILING, GridBagConstraints.NONE));*/
        add(new JScrollPane(list), estaticas.createConstraints(0, 1, 4, 1, 1.0, 1.0,
                GridBagConstraints.ABOVE_BASELINE, GridBagConstraints.BOTH));
        add(new JScrollPane(textArea), estaticas.createConstraints(4, 0, 1, 2, 1.0, 1.0,
                GridBagConstraints.ABOVE_BASELINE, GridBagConstraints.BOTH));

    }

    JList list;
    public DefaultListModel defaultListModel;
    JButton button1;
    public JTextArea textArea;
}
class MyCellRendererBluetooth extends JLabel implements ListCellRenderer {

    final static ImageIcon Icon = new ImageIcon("bluetooth icon.png");

    public MyCellRendererBluetooth() {
        setOpaque(true);
    }

    public Component getListCellRendererComponent(
            JList list,
            Object value,
            int index,
            boolean isSelected,
            boolean cellHasFocus) {
       
        setText(value.toString());
        setIcon(Icon);
        setBackground(isSelected ? Color.LIGHT_GRAY : Color.white);
        setForeground(isSelected ? Color.white : Color.black);
        return this;
    }
}


