ola pessoal, td bem. Eu estou tendo um problema com os JinternalFrames.
Quando eu adiciono o JinternalFrame no JFrame, ele vem com a borda cortada.
Quando clica dentro do JInternalFrame ele volta ao normal, mas isso é meio chato e eu nao sei pq isso acontece.
as duas classes:
package Frames;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
public class Principal extends JFrame
{
private static final long serialVersionUID = 1L;
JMenuBar menu;
JMenu alunos,
professores,
financeiro,
frequecia;
JMenuItem cadastrarAluno,
alterarAluno,
removerAluno,
consultarAlunos;
public Principal()
{
setSize(100,100);
setExtendedState(Principal.MAXIMIZED_BOTH);
setLocation(0,0);
getContentPane().setLayout(null);
setDefaultCloseOperation(Principal.EXIT_ON_CLOSE);
menu = new JMenuBar();
menu.setVisible(true);
setJMenuBar(menu);
alunos = new JMenu("Alunos");
alunos.setVisible(true);
menu.add(alunos);
cadastrarAluno = new JMenuItem("Cadastrar Aluno");
cadastrarAluno.setVisible(true);
alunos.add(cadastrarAluno);
cadastrarAluno.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0){
CadastrarAlunos cadastrarAlunos = new CadastrarAlunos();
getContentPane().add(cadastrarAlunos.internalFrameCadastrarAluno);
}});
consultarAlunos = new JMenuItem("Consultar Aluno");
consultarAlunos.setVisible(true);
alunos.add(consultarAlunos);
alterarAluno = new JMenuItem("Alterar Aluno");
alterarAluno.setVisible(true);
alunos.add(alterarAluno);
removerAluno = new JMenuItem("Remover Aluno");
removerAluno.setVisible(true);
alunos.add(removerAluno);
professores = new JMenu("Professores");
professores.setVisible(true);
menu.add(professores);
financeiro = new JMenu("Financeiro");
financeiro.setVisible(true);
menu.add(financeiro);
}
public static void main(String[] args)
{
new Principal().setVisible(true);
}
}
//
package Frames;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.SpinnerNumberModel;
import com.toedter.calendar.JDateChooser;
import util.FrameUtil;
import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel;
public class CadastrarAlunos extends JInternalFrame
{
private static final long serialVersionUID = 1L;
FrameUtil util = new FrameUtil();
//------------------------ Componetes do InternalFrame ------------------------//
JInternalFrame internalFrameCadastrarAluno;
public static JButton btnIniciarCam,
btnAdicionarFoto;
JTextField txtCodAluno,
txtNome;
static JLabel labelFoto;
static byte[] fotoEmByte;
//---------------------------------------------------- ------------------------//
/**
*
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public CadastrarAlunos()
{
//setSize(700,700);
//setLocation(100,100);
//getContentPane().setLayout(null);
//setDefaultCloseOperation(CadastrarAlunos.DISPOSE_ON_CLOSE);
Font font =new Font("Lucida Console", Font.BOLD,13);
internalFrameCadastrarAluno = new JInternalFrame();
internalFrameCadastrarAluno.setSize(650,600);
internalFrameCadastrarAluno.setLocation(0, 0);
internalFrameCadastrarAluno.getContentPane().setLayout(null);
internalFrameCadastrarAluno.getContentPane().setBackground(Color.LIGHT_GRAY);
internalFrameCadastrarAluno.setVisible(true);
getContentPane().add(internalFrameCadastrarAluno);
JPanel panelFotoArea= new JPanel();
panelFotoArea.setSize(200,250);
panelFotoArea.setLocation(10,10);
panelFotoArea.setLayout(null);
panelFotoArea.setBackground(Color.LIGHT_GRAY);
panelFotoArea.setBorder(util.criarBorda("Foto", 2, 2, 1));
internalFrameCadastrarAluno.getContentPane().add(panelFotoArea);
labelFoto = new JLabel();
labelFoto.setSize(180,190);
labelFoto.setLocation(10,20);
labelFoto.setOpaque(true);
labelFoto.setVisible(true);
labelFoto.setIcon(util.inputImageIcon("Imagens/imgSemFoto.png", null, 180, 190));
labelFoto.setBorder(util.criarBorda(null,null,null, 2));
panelFotoArea.add(labelFoto);
btnIniciarCam = new JButton();
btnIniciarCam.setToolTipText("Tirar Foto");
btnIniciarCam.setSize(30,30);
btnIniciarCam.setLocation(150,213);
btnIniciarCam.setBackground(Color.CYAN);
btnIniciarCam.setIcon(new ImageIcon("Imagens/imgTirarFoto.png"));
panelFotoArea.add(btnIniciarCam);
btnIniciarCam.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0)
{
new Thread()
{
public void run()
{
new FrameWebCam().setVisible(true);
}
}.start();
}});
btnAdicionarFoto = new JButton();
btnAdicionarFoto.setToolTipText("Adicionar Foto");
btnAdicionarFoto.setSize(30,30);
btnAdicionarFoto.setLocation(20,213);
btnAdicionarFoto.setBackground(Color.CYAN);
btnAdicionarFoto.setIcon(new ImageIcon("Imagens/imgAdicionarFoto.png"));
panelFotoArea.add(btnAdicionarFoto);
btnAdicionarFoto.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
new FrameFileSearch("aluno").setVisible(true);
}});
JButton btnRemoverFoto = new JButton();
btnRemoverFoto.setToolTipText("Remover Foto");
btnRemoverFoto.setSize(30,30);
btnRemoverFoto.setLocation(85,213);
btnRemoverFoto.setBackground(Color.CYAN);
btnRemoverFoto.setIcon(new ImageIcon("Imagens/imgRemoverFoto.png"));
panelFotoArea.add(btnRemoverFoto);
btnRemoverFoto.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0)
{
labelFoto.setIcon(util.inputImageIcon("Imagens/imgSemFoto.png", null, 180, 190));
fotoEmByte=null;
}});
//================================================================================================= INFO DE CADASTRO
JPanel panelInfoCadastro = new JPanel();
panelInfoCadastro.setSize(370,85);
panelInfoCadastro.setLocation(235,10);
panelInfoCadastro.setLayout(null);
panelInfoCadastro.setBackground(Color.LIGHT_GRAY);
panelInfoCadastro.setBorder(util.criarBorda("Info Cadastro", 1, 2, 1));
internalFrameCadastrarAluno.getContentPane().add(panelInfoCadastro);
JLabel lblCodAluno = new JLabel("Código do Aluno:");
lblCodAluno.setSize(95,15);
lblCodAluno.setLocation(10,15);
panelInfoCadastro.add(lblCodAluno);
txtCodAluno = new JTextField();
txtCodAluno.setSize(100,17);
txtCodAluno.setLocation(110,15);
txtCodAluno.setFont(font);
txtCodAluno.setEditable(false);
panelInfoCadastro.add(txtCodAluno);
JLabel lblDataDeCadastro = new JLabel("Data De Cadastro:");
lblDataDeCadastro.setSize(105,15);
lblDataDeCadastro.setLocation(10,50);
panelInfoCadastro.add(lblDataDeCadastro);
JFormattedTextField txtDataDeCadastro = new JFormattedTextField("30/12/1999");
txtDataDeCadastro.setSize(110,20);
txtDataDeCadastro.setLocation(115,50);
txtDataDeCadastro.setEditable(false);
txtDataDeCadastro.setFont(new Font("Lucida Console", Font.BOLD, 13));
Date date = new Date();
SimpleDateFormat dataFormatada = new SimpleDateFormat("dd/MM/YYYY");
txtDataDeCadastro.setText(dataFormatada.format(date));
panelInfoCadastro.add(txtDataDeCadastro);
JLabel lblSituacao = new JLabel("Situação");
lblSituacao.setSize(70,14);
lblSituacao.setLocation(290, 15);
panelInfoCadastro.add(lblSituacao);
ButtonGroup jCheckBoxGroup = new ButtonGroup();
JCheckBox boxAtivo = new JCheckBox("Ativo");
boxAtivo.setSize(60,14);
boxAtivo.setBackground(Color.LIGHT_GRAY);
boxAtivo.setLocation(290, 35);
boxAtivo.setSelected(true);
jCheckBoxGroup.add(boxAtivo);
panelInfoCadastro.add(boxAtivo);
JCheckBox boxInativo = new JCheckBox("Inativo");
boxInativo.setSize(70,14);
boxInativo.setBackground(Color.LIGHT_GRAY);
boxInativo.setLocation(290, 55);
jCheckBoxGroup.add(boxInativo);
panelInfoCadastro.add(boxInativo);
//================================================================================================= DADOS
JPanel panelDadosPessoais = new JPanel();
panelDadosPessoais.setSize(370,138);
panelDadosPessoais.setLocation(235,120);
panelDadosPessoais.setLayout(null);
panelDadosPessoais.setBackground(Color.LIGHT_GRAY);
panelDadosPessoais.setBorder(util.criarBorda("Dados Pessoais", 1, 2, 1));
internalFrameCadastrarAluno.getContentPane().add(panelDadosPessoais);
JLabel lblNome = new JLabel("Nome:");
lblNome.setSize(40,20);
lblNome.setLocation(20,20);
panelDadosPessoais.add(lblNome);
txtNome = new JTextField();
txtNome.setSize(300,17);
txtNome.setLocation(60,23);
txtNome.setFont(font);
panelDadosPessoais.add(txtNome);
JLabel lblIdade = new JLabel("Idade:");
lblIdade.setSize(35,15);
lblIdade.setLocation(20,50);
panelDadosPessoais.add(lblIdade);
JSpinner spinIdade = new JSpinner();
spinIdade.setModel(new SpinnerNumberModel(1,1,null,1));
spinIdade.setSize(50,20);
spinIdade.setLocation(60,48);
panelDadosPessoais.add(spinIdade);
JLabel lblDataNascimento = new JLabel("Data de Nascimento:");
lblDataNascimento.setSize(120,15);
lblDataNascimento.setLocation(120,50);
panelDadosPessoais.add(lblDataNascimento);
JDateChooser dateDeNacimento = new JDateChooser();
dateDeNacimento.setFont(new Font("Lucida Console", Font.BOLD,13));
dateDeNacimento.setSize(120,20);
dateDeNacimento.setLocation(240,48);
panelDadosPessoais.add(dateDeNacimento);
JLabel lblSexo = new JLabel("Sexo:");
lblSexo.setSize(35,14);
lblSexo.setLocation(20, 80);
panelDadosPessoais.add(lblSexo);
JComboBox<?> boxSexo = new JComboBox();
boxSexo.setModel(new DefaultComboBoxModel(new String[] {"Masculino", "Feminino","..."}));
boxSexo.setSize(120, 20);
boxSexo.setLocation(60,78);
boxSexo.setFont(font);
panelDadosPessoais.add(boxSexo);
JLabel lblCPF = new JLabel("CPF:");
lblCPF.setSize(25, 14);
lblCPF.setLocation(20,110);
panelDadosPessoais.add(lblCPF);
JFormattedTextField txtCPF = new JFormattedTextField();
txtCPF.setSize(132,20);
txtCPF.setLocation(50, 110);
txtCPF.setFont(font);
panelDadosPessoais.add(txtCPF);
JLabel lblRG = new JLabel("RG:");
lblRG.setSize(20, 14);
lblRG.setLocation(200, 80);
panelDadosPessoais.add(lblRG);
JFormattedTextField txtRG = new JFormattedTextField();
txtRG.setSize(132,20);
txtRG.setLocation(225, 77);
txtRG.setFont(font);
panelDadosPessoais.add(txtRG);
//================================================================================================= ENDERECO
JPanel panelEndereco = new JPanel();
panelEndereco.setBackground(Color.LIGHT_GRAY);
panelEndereco.setSize(595,129);
panelEndereco.setLocation(10,285);
panelEndereco.setLayout(null);
panelEndereco.setBorder(util.criarBorda("Endereço", 1, 2, 1));
internalFrameCadastrarAluno.getContentPane().add(panelEndereco);
JLabel lblEstado = new JLabel("Estado:");
lblEstado.setSize(45,14);
lblEstado.setLocation(200,30);
panelEndereco.add(lblEstado);
JComboBox boxEstado = new JComboBox();
boxEstado.setModel(new DefaultComboBoxModel(new String[] {"AC", "AL", "AP", "AM", "BA", "CE", "ES", "GO", "MA", "MT", "MS", "MG", "PA", "PB", "PR", "PE", "PI", "RJ", "RN", "RS", "RO", "RR", "SC", "SP", "SE", "TO", "DF"}));
boxEstado.setSize(50,20);
boxEstado.setLocation(245,28);
boxEstado.setSelectedIndex(23);
panelEndereco.add(boxEstado);
JLabel lblCidade = new JLabel("Cidade:");
lblCidade.setSize(45,14);
lblCidade.setLocation(310,30);
panelEndereco.add(lblCidade);
JTextField txtCidade = new JTextField();
txtCidade.setSize(215,20);
txtCidade.setLocation(360,27);
txtCidade.setFont(font);
panelEndereco.add(txtCidade);
JLabel lblBairro = new JLabel("Bairro:");
lblBairro.setSize(40,14);
lblBairro.setLocation(20,70);
panelEndereco.add(lblBairro);
JTextField txtBairro = new JTextField();
txtBairro.setSize(150,20);
txtBairro.setLocation(65,67);
txtBairro.setFont(font);
panelEndereco.add(txtBairro);
JLabel lblLogradouro = new JLabel("Logradouro:");
lblLogradouro.setSize(70,14);
lblLogradouro.setLocation(220,70);
panelEndereco.add(lblLogradouro);
JTextField txtLogradouro = new JTextField();
txtLogradouro.setSize(280,20);
txtLogradouro.setLocation(295,67);
txtLogradouro.setFont(font);
panelEndereco.add(txtLogradouro);
JLabel lblNumero = new JLabel("Número:");
lblNumero.setSize(50,14);
lblNumero.setLocation(20,100);
panelEndereco.add(lblNumero);
JTextField txtNumero = new JTextField();
txtNumero.setSize(70,20);
txtNumero.setLocation(74,97);
panelEndereco.add(txtNumero);
JLabel lblComplemento = new JLabel("Complemento:");
lblComplemento.setSize(85,14);
lblComplemento.setLocation(155,100);
panelEndereco.add(lblComplemento);
JTextField txtComplemento = new JTextField();
txtComplemento.setSize(285,20);
txtComplemento.setLocation(243,97);
txtComplemento.setFont(font);
panelEndereco.add(txtComplemento);
JPanel panelCEP = new JPanel();
panelCEP.setBackground(Color.lightGray);
panelCEP.setSize(155,36);
panelCEP.setLocation(20,20);
panelCEP.setLayout(null);
panelCEP.setBorder(util.criarBorda(null,0,0,0));
panelEndereco.add(panelCEP);
JLabel lblCEP = new JLabel("CEP:");
lblCEP.setSize(27,14);
lblCEP.setLocation(10,10);
panelCEP.add(lblCEP);
JFormattedTextField txtCEP = new JFormattedTextField("09851-631");
txtCEP.setSize(70,20);
txtCEP.setLocation(40,7);
panelCEP.add(txtCEP);
JButton btnProcurarCEP = new JButton();
btnProcurarCEP.setSize(25,25);
btnProcurarCEP.setLocation(115,5);
btnProcurarCEP.setIcon((util.redimensionarIcon(20,20, "Imagens/imgPesquisar.png")));
btnProcurarCEP.setBackground(Color.CYAN);
panelCEP.add(btnProcurarCEP);
btnProcurarCEP.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
String[] endereco = util.buscaCep(txtCEP.getText());
if (endereco!=null)
{
txtLogradouro.setText(endereco[0]);
txtComplemento.setText(endereco[1]);
txtBairro.setText(endereco[2]);
txtCidade.setText(endereco[3]);
for (int i = 0; i <boxEstado.getModel().getSize(); i++)
{
if (endereco[4].equals(boxEstado.getItemAt(i)))
{
boxEstado.setSelectedIndex(i);
}
}
}
}});
}
}

