Guest User

Untitled

a guest
Dec 13th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 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_1 extends NFrame
  7. {
  8. JLabel L2;
  9. DefaultListModel lista ;
  10. JList cardapio;
  11. JPanel P1, P2 ;
  12.  
  13. public Ev_1()
  14. {
  15.  
  16.  
  17. // Altera o titulo da pagina
  18.  
  19. setTitle("Acrescentando uma LISTA DE SELEÇÃO ao Frame ");
  20.  
  21. // acrescenta um rotulo para a caixa de seleção
  22.  
  23. L2 = new JLabel("Escolha seu sanduiche :");
  24. L2.setSize(300,20);
  25. L2.setLocation(10,20);
  26. L2.setForeground(Color.black);
  27.  
  28.  
  29. // Acrescenta o objeto lista de seleção
  30.  
  31. lista = new DefaultListModel();
  32.  
  33. lista.addElement("Hot Dog");
  34. lista.addElement("Churrasco");
  35. lista.addElement("Bauru");
  36. lista.addElement("X-Egg");
  37. lista.addElement("X-Salada");
  38. lista.addElement("Calabresa");
  39.  
  40.  
  41. cardapio = new JList(lista);
  42. cardapio.setSize(140,190);
  43. cardapio.setLocation(5,10);
  44. cardapio.setBackground(new Color(208,255,255));
  45.  
  46.  
  47. P1 = new JPanel();
  48. P1.setBounds(20,50,150,230);
  49. P1.setBackground(new Color(208,255,255));
  50. P1.setBorder(BorderFactory.createLineBorder(Color.black,2));
  51. P1.setLayout(null);
  52. P1.add(cardapio);
  53.  
  54. P2 = new JPanel();
  55. P2.setBounds(220,50,300,230);
  56. P2.setBackground(new Color(208,255,255));
  57. P2.setBorder(BorderFactory.createLineBorder(Color.black,2));
  58.  
  59.  
  60.  
  61.  
  62. getContentPane().setBackground(Color.yellow);
  63. getContentPane().setLayout(null);
  64. getContentPane().add(L2);
  65. getContentPane().add(P1);
  66. getContentPane().add(P2);
  67.  
  68. }
  69. public static void main(String[] args)
  70. {
  71. new Ev_1().setVisible(true);
  72.  
  73. }
  74. }
Add Comment
Please, Sign In to add comment