Guest User

Untitled

a guest
Dec 13th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. import javax.swing.*;
  2. import javax.swing.event.*;
  3. import java.awt.*;
  4. import java.awt.event.*;
  5.  
  6. public class Ev_2 extends Ev_1 implements ListSelectionListener
  7. {
  8. JLabel La;
  9. ImageIcon Im1;
  10.  
  11. public Ev_2()
  12. {
  13. setTitle("Acrescentando EVENTO a Lista de Seleção ");
  14. lista.addElement(".");
  15. lista.addElement(".");
  16. lista.addElement("Sair");
  17. cardapio.addListSelectionListener(this);
  18. Im1 = new ImageIcon(" ");
  19. La = new JLabel(Im1);
  20. La.setLocation(10,10);
  21. La.setVisible(true);
  22. P2.add(La,BorderLayout.CENTER);
  23. }
  24. public static void main(String[] args)
  25. {
  26. NFrame fx = new Ev_2();
  27. fx.setVisible(true);
  28.  
  29. }
  30. public void valueChanged(ListSelectionEvent e)
  31. {
  32. if(cardapio.getSelectedValue().equals("Hot Dog"))
  33. {
  34. Im1 = new ImageIcon("C:/Documents and Settings/eclipse/Meus documentos/Hot_Dog_2.gif");
  35. P2.setBackground(new Color(102,204,255));
  36. La.setIcon(Im1);
  37. }
  38. if(cardapio.getSelectedValue().equals("Churrasco"))
  39. {
  40. Im1 = new ImageIcon("C:/Documents and Settings/eclipse/Meus documentos/Churrasco_2.gif");
  41. P2.setBackground(new Color(102,204,204));
  42. La.setIcon(Im1);
  43. }
  44. if(cardapio.getSelectedValue().equals("Bauru"))
  45. {
  46. Im1 = new ImageIcon("C:/Documents and Settings/eclipse/Meus documentos/Bauru_2.gif");
  47. P2.setBackground(new Color(102,204,255));
  48. La.setIcon(Im1);
  49. }
  50.  
  51. if(cardapio.getSelectedValue().equals("X-Egg"))
  52. {
  53. Im1 = new ImageIcon("C:/Documents and Settings/eclipse/Meus documentos/Egg_2.gif");
  54. P2.setBackground(new Color(149,154,218));
  55. La.setIcon(Im1);
  56. }
  57. if(cardapio.getSelectedValue().equals("X-Salada"))
  58. {
  59. Im1 = new ImageIcon("C:/Documents and Settings/eclipse/Meus documentos/Salada_2.gif");
  60. P2.setBackground(Color.red);
  61. La.setIcon(Im1);
  62. }
  63. if(cardapio.getSelectedValue().equals("Calabresa"))
  64. {
  65. Im1 = new ImageIcon("C:/Documents and Settings/eclipse/Meus documentos/Calabresa_2.gif");
  66. P2.setBackground(new Color(102,204,204));
  67. La.setIcon(Im1);
  68. }
  69. if(cardapio.getSelectedValue().equals("."))
  70. {
  71. Im1 = new ImageIcon(".");
  72. P2.setBackground(new Color(102,204,204));
  73. La.setIcon(Im1);
  74. }
  75. if(cardapio.getSelectedValue().equals("Sair"))
  76. {
  77. System.exit(0);
  78. }
  79. }
  80. }
Add Comment
Please, Sign In to add comment