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_1 extends NFrame
- {
- JLabel L2;
- DefaultListModel lista ;
- JList cardapio;
- JPanel P1, P2 ;
- public Ev_1()
- {
- // Altera o titulo da pagina
- setTitle("Acrescentando uma LISTA DE SELEÇÃO ao Frame ");
- // acrescenta um rotulo para a caixa de seleção
- L2 = new JLabel("Escolha seu sanduiche :");
- L2.setSize(300,20);
- L2.setLocation(10,20);
- L2.setForeground(Color.black);
- // Acrescenta o objeto lista de seleção
- lista = new DefaultListModel();
- lista.addElement("Hot Dog");
- lista.addElement("Churrasco");
- lista.addElement("Bauru");
- lista.addElement("X-Egg");
- lista.addElement("X-Salada");
- lista.addElement("Calabresa");
- cardapio = new JList(lista);
- cardapio.setSize(140,190);
- cardapio.setLocation(5,10);
- cardapio.setBackground(new Color(208,255,255));
- P1 = new JPanel();
- P1.setBounds(20,50,150,230);
- P1.setBackground(new Color(208,255,255));
- P1.setBorder(BorderFactory.createLineBorder(Color.black,2));
- P1.setLayout(null);
- P1.add(cardapio);
- P2 = new JPanel();
- P2.setBounds(220,50,300,230);
- P2.setBackground(new Color(208,255,255));
- P2.setBorder(BorderFactory.createLineBorder(Color.black,2));
- getContentPane().setBackground(Color.yellow);
- getContentPane().setLayout(null);
- getContentPane().add(L2);
- getContentPane().add(P1);
- getContentPane().add(P2);
- }
- public static void main(String[] args)
- {
- new Ev_1().setVisible(true);
- }
- }
Add Comment
Please, Sign In to add comment