import javax.swing.*;
import java.awt.*;
import java.awt.*;
public class Formulario extends JFrame
{
public Formulario()
{
super("FORMULARIO DO FUNCIONARIO");
setResizable(false);
add(new PainelCentro(), BorderLayout.CENTER);
add(new PainelBotao(), BorderLayout.SOUTH);
setSize(450,200);
setLocationRelativeTo(null);
setVisible(true);
}
{
public Formulario()
{
super("FORMULARIO DO FUNCIONARIO");
setResizable(false);
add(new PainelCentro(), BorderLayout.CENTER);
add(new PainelBotao(), BorderLayout.SOUTH);
setSize(450,200);
setLocationRelativeTo(null);
setVisible(true);
}
public class PainelBotao extends JPanel
{
JButton guardar,limpar,cancelar;
GridLayout arrumador;
public PainelBotao()
{
arrumador = new GridLayout(1,3);
setLayout(arrumador);
{
JButton guardar,limpar,cancelar;
GridLayout arrumador;
public PainelBotao()
{
arrumador = new GridLayout(1,3);
setLayout(arrumador);
guardar = new JButton("GUARDAR");
guardar.setBackground(Color.white);
guardar.setForeground(Color.red);
add(guardar);
limpar = new JButton("LIMPAR");
limpar.setBackground(Color.white);
limpar.setForeground(Color.red);
add(limpar);
cancelar = new JButton("CANCELAR");
cancelar.setBackground(Color.white);
cancelar.setForeground(Color.red);
add(cancelar);
}
}
public class PainelSexo extends JPanel
{
JRadioButton masculinoRB, femeninoRB;
ButtonGroup grupoSexo;
GridLayout arrumador;
public PainelSexo()
{
arrumador = new GridLayout(1,2);
setLayout(arrumador);
masculinoRB = new JRadioButton("Masculino",false);
femeninoRB = new JRadioButton("Femenino",false);
add(masculinoRB);
add(femeninoRB);
grupoSexo = new ButtonGroup();
grupoSexo.add(masculinoRB);
grupoSexo.add(femeninoRB);
}
}
public class PainelEmail extends JPanel
{
JTextField c1;
JList lista;
String email[] = {"@hotmail.com","@yahoo.com","@gmail.com"};
GridLayout arrumador;
public PainelEmail()
{
arrumador = new GridLayout(1,2);
setLayout(arrumador);
c1 = new JTextField(20);
lista =new JList(email);
lista.setVisibleRowCount(1);
add(c1);
add(lista);
add(new JScrollPane(lista));
}
}
public class PainelLinguagem extends JPanel
{
JCheckBox c, java;
GridLayout arrumador;
public PainelLinguagem()
{
arrumador = new GridLayout(1,2);
setLayout(arrumador);
c = new JCheckBox("C++",false);
java = new JCheckBox("Java",false);
add(c);
add(java);
}
}
public class PainelCentro extends JPanel
{
String nomesLabels [] = {"Nome","Email","Estado Civil","Sexo","Linguagem de Programacao"};
String estadoCivil[] = {"--Selecione--","Solteiro(a)","Casado(a)"} ;
JLabel labels[] = new JLabel[nomesLabels.length];
JComboBox estadoCivilCB;
GridLayout arrumador;
public PainelCentro()
{
arrumador = new GridLayout(6,5);
setLayout(arrumador);
for (int i=0; i<5;i++)
{
labels[i] = new JLabel(nomesLabels[i]);
add(labels[i]);
switch(i)
{
case 0:
add(new JTextField(20));
break;
case 1:
add(new PainelEmail());
break;
case 2:
estadoCivilCB = new JComboBox(estadoCivil);
add(estadoCivilCB);
break;
case 3:
add(new PainelSexo());
break;
case 4:
add(new PainelLinguagem());
break;
}
}
}
}
public static void main(String args[])
{
new Formulario();
}
}
}
}
public static void main(String args[])
{
new Formulario();
}
}