Advertisement
Ximbola

Exemplos de funçoes.

Nov 20th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.98 KB | None | 0 0
  1. package aula;
  2. import java.awt.*;
  3. import javax.swing.*;
  4. public class Form extends JFrame
  5. {      
  6.     private static final long serialVersionUID = 1L;
  7.     JLabel lb_titulo, lb_autor,_lb_logo,_lb_fruta;
  8.     JButton bt_cadastro,bt_sair;
  9.     ImageIcon imagem_logo;
  10.     JComboBox jcb_familia;
  11.     JList jl_frutas;
  12.     JTextField tf_nome;
  13.     JLabel lb_logo;
  14.         //1
  15.     static JRadioButton jrb_masc;
  16.     static JRadioButton jrb_fem;
  17.     //2
  18.     static ButtonGroup grupo_sexo;
  19.     //static JPasswordField tf_senha;
  20.         public Form()
  21.     {
  22.         setTitle("Aprendendo Orientacao a Objetos");
  23.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  24.         setResizable(false);                            }
  25.        
  26.     public static void main(String[] args)
  27.     {                  
  28.          JFrame obj = new JFrame();      
  29.          JLabel lb_titulo = new JLabel();
  30.          obj.setResizable(true);
  31.            
  32.          obj.setTitle("Aprendendo Orientacao a Objetos");        
  33.          ImageIcon imagem_logo = new ImageIcon("C:/Users/...");
  34.          obj.getContentPane().setBackground(Color.gray);         
  35.              
  36.          JButton bt_cadastro = new JButton("Casdastro");
  37.          JButton  bt_sair = new JButton("Sair");
  38.          lb_titulo = new JLabel("AULA JAVA");
  39.          JLabel lb_autor = new JLabel("Capitao");      
  40.          JLabel lb_logo = new JLabel(imagem_logo);
  41.          //1
  42.          jrb_masc = new JRadioButton("Masculino");
  43.          jrb_fem = new JRadioButton("Feminino");
  44.         //2
  45.          grupo_sexo = new ButtonGroup();
  46.          grupo_sexo.add(jrb_masc);
  47.          grupo_sexo.add(jrb_fem);
  48.          
  49.          String frutas[] = {"Abacaxi", "Uva", "Manga", "Goiaba"};
  50.                  
  51.          JList jl_frutas = new JList(frutas);        
  52.          JTextField tf_nome = new JTextField(10);
  53.          //4
  54.          //JPasswordField tf_senha = new JPasswordField();
  55.          //tf_senha.setEchoChar('*');
  56.              
  57.          JComboBox jcb_familia = new JComboBox();              
  58.          obj.getContentPane().setLayout(null);
  59.        
  60.          obj.setSize(600,600); 
  61.          obj.setLocation(70,70);
  62.          obj.getContentPane().add("North",lb_titulo);
  63.          obj.getContentPane().add("South",lb_autor);       
  64.          obj.getContentPane().add("West",bt_cadastro);
  65.          obj.getContentPane().add("East",bt_sair);             
  66.          obj.getContentPane().add("North",tf_nome);
  67.          obj.getContentPane().add("Center",lb_logo);
  68.         //1
  69.          obj.getContentPane().add(jrb_masc);
  70.          obj.getContentPane().add(jrb_fem);
  71.          //obj.getContentPane().add(grupo_sexo);
  72.          //4
  73.          //obj.getContentPane().add(tf_senha);
  74.          
  75.          lb_titulo.setBounds(250,10,700,40);           
  76.          lb_logo.setBounds(60,50,500,200); 
  77.          bt_cadastro.setBounds(3,50,150,50);
  78.          bt_sair.setBounds(3,110,150,50);  
  79.          lb_autor.setBounds(10,0,200,70);          
  80.          tf_nome.setBounds(0,230,100,20);  
  81.          jcb_familia.setBounds(3,170,150,30);
  82.         //1
  83.          jrb_masc.setBounds(0,290,100,25);
  84.          jrb_fem.setBounds(0,340,100,25);
  85.          //2
  86.          //grupo_sexo.setBounds(600,50,100,50);
  87.          //4
  88.          //tf_senha.setBounds(0,260,100,20);
  89.          
  90.          
  91.          obj.getContentPane().add("North",tf_nome);
  92.          obj.getContentPane().add("South",jcb_familia);
  93.          jcb_familia.addItem("ANA");
  94.          jcb_familia.addItem("PAULA");
  95.          jcb_familia.addItem("JOAO");
  96.          jcb_familia.addItem("ANDRE");
  97.          //obj.pack();
  98.          obj.setVisible(true);
  99.             }
  100.    
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement