Ola meus amigos , Sou novo no GUJ e também no java , e gostaria de uma ajuda de vcs !!
Meu problema é o seguinte, fiz uma tela usando Swing, é a tela inicial do programa, a resolução do
meu monitor é 1024 x 768 , em minha maquina , a tela abre beleza , configurada da forma que foi
programada, porém , em outra máquina , com uma resolução superior a essa , o programa abre desconfigurado,
ou seja , os textos e caixa de texto e também os botões abre em canto diferente onde deveria! Creio eu que não estou
sabendo usar um gerenciador de Layout.
Abaixo segue o código.
[code]
package PowerDataSystem.View;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class TelaInicial extends JFrame {
public JLabel imagemFundo;
public JPanel painel = new JPanel();
public JLabel usuario;
public JLabel senha;
public JTextField usuarioTextF;
public JTextField loginTextF;
public JButton botaoSair;
public JButton botaoEntrar;
public JPasswordField caixaSenha;
public TelaInicial (){
super("Power Data System");
this.setLayout(new BorderLayout());
Container tela = getContentPane();
botaoSair = new JButton("SAIR");
botaoEntrar = new JButton("OK");
caixaSenha = new JPasswordField(6);
usuarioTextF = new JTextField();
senha = new JLabel("SENHA");
usuario = new JLabel("USUARIO");
tela.add(usuarioTextF);
tela.add(caixaSenha);
tela.add(botaoSair);
tela.add(botaoEntrar);
tela.add(senha);
tela.add(usuario);
usuarioTextF.setBounds(495, 350, 150, 20);
caixaSenha.setBounds(495, 380, 150, 20);
botaoSair.setBounds(575, 410, 70, 20);
botaoEntrar.setBounds(495, 410, 70, 20);
senha.setBounds(450, 379,50 ,20);
usuario.setBounds(436,350, 60, 20);
//*********** Evento do botão sair *******************************
botaoSair.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
//****************************************************************
painel.setOpaque(false);
//tela.setLayout(new BorderLayout());
ImageIcon fundo = new ImageIcon("imagem1.JPG");
imagemFundo = new JLabel(fundo);
tela.add(imagemFundo,BorderLayout.CENTER);
setSize(800,600);
setVisible(true);
setExtendedState(MAXIMIZED_BOTH);
}
public static void main (String [] args){
TelaInicial tela1 = new TelaInicial();
tela1.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}[/code]
Desde de já muiiiito obrigado!