Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import javax.swing.event.*;
- import java.awt.*;
- import java.awt.event.*;
- public class Ev_2 extends Ev_1 implements ListSelectionListener
- {
- JLabel La;
- ImageIcon Im1;
- public Ev_2()
- {
- setTitle("Acrescentando EVENTO a Lista de Seleção ");
- lista.addElement(".");
- lista.addElement(".");
- lista.addElement("Sair");
- cardapio.addListSelectionListener(this);
- Im1 = new ImageIcon(" ");
- La = new JLabel(Im1);
- La.setLocation(10,10);
- La.setVisible(true);
- P2.add(La,BorderLayout.CENTER);
- }
- public static void main(String[] args)
- {
- NFrame fx = new Ev_2();
- fx.setVisible(true);
- }
- public void valueChanged(ListSelectionEvent e)
- {
- if(cardapio.getSelectedValue().equals("Hot Dog"))
- {
- Im1 = new ImageIcon("C:/Documents and Settings/eclipse/Meus documentos/Hot_Dog_2.gif");
- P2.setBackground(new Color(102,204,255));
- La.setIcon(Im1);
- }
- if(cardapio.getSelectedValue().equals("Churrasco"))
- {
- Im1 = new ImageIcon("C:/Documents and Settings/eclipse/Meus documentos/Churrasco_2.gif");
- P2.setBackground(new Color(102,204,204));
- La.setIcon(Im1);
- }
- if(cardapio.getSelectedValue().equals("Bauru"))
- {
- Im1 = new ImageIcon("C:/Documents and Settings/eclipse/Meus documentos/Bauru_2.gif");
- P2.setBackground(new Color(102,204,255));
- La.setIcon(Im1);
- }
- if(cardapio.getSelectedValue().equals("X-Egg"))
- {
- Im1 = new ImageIcon("C:/Documents and Settings/eclipse/Meus documentos/Egg_2.gif");
- P2.setBackground(new Color(149,154,218));
- La.setIcon(Im1);
- }
- if(cardapio.getSelectedValue().equals("X-Salada"))
- {
- Im1 = new ImageIcon("C:/Documents and Settings/eclipse/Meus documentos/Salada_2.gif");
- P2.setBackground(Color.red);
- La.setIcon(Im1);
- }
- if(cardapio.getSelectedValue().equals("Calabresa"))
- {
- Im1 = new ImageIcon("C:/Documents and Settings/eclipse/Meus documentos/Calabresa_2.gif");
- P2.setBackground(new Color(102,204,204));
- La.setIcon(Im1);
- }
- if(cardapio.getSelectedValue().equals("."))
- {
- Im1 = new ImageIcon(".");
- P2.setBackground(new Color(102,204,204));
- La.setIcon(Im1);
- }
- if(cardapio.getSelectedValue().equals("Sair"))
- {
- System.exit(0);
- }
- }
- }
Add Comment
Please, Sign In to add comment