Advertisement
gtw7375

JAVA INTERFACE GRAFICAS UHUU

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