Criação de telas e posicionamento de botões [RESOLVIDO]

23 respostas
hvivox

[color=blue][/color]Preciso de sua ajuda.

Tenho que cirar telas em java, mas, não posso utilizar editor visual, sei que para isso tenho que usar os gerenciadores de layout. Por isso pesso sua ajuda, vc pode contribuir mandando dicas ou exemplos prontos.

OBRIGADO PELA ATENÇÃO!

HERMOGENES SILVA E SILVA[u]

23 Respostas

M

Opa, beleza?
http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html

hvivox

Apesar de não ter um bom ingles, muito obrigado pela resposta, espero ter outras respostas.

OBRIGADO

maxguzenski

use o forms do jgoodies e seja feliz :slight_smile:

public JPanel buildPanel() {
    	FormLayout layout = new FormLayout("right:pref, 3dlu, max(pref;200dlu), 3dlu, pref", "pref, 3dlu, pref, 10dlu, pref, 20dlu, pref, 3dlu, pref");
    	DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    	builder.setDefaultDialogBorder();
    	CellConstraints cc = new CellConstraints();
    	
    	int row = 1;
    	builder.addLabel("Backup Path:", cc.xy(1, row));
    	builder.add(txtPathBck, cc.xy(3, row));
    	builder.add(btnFindBck, cc.xy(5, row));
    	
    	row += 2;
    	builder.addLabel("Restore Path:", cc.xy(1, row));
    	builder.add(txtRestore, cc.xy(3, row));
    	builder.add(btnFindRestore, cc.xy(5, row));
    	
    	row += 2;
    	builder.add(ButtonBarFactory.buildRightAlignedBar(btnIniciar), cc.xyw(1, row, 5));
    	
    	row += 2;
    	builder.add(pssProcesso, cc.xyw(1, row, 5));
    	
    	row += 2;
    	builder.add(ButtonBarFactory.buildRightAlignedBar(btnCancelar), cc.xyw(1, row, 5));
    	
    	return builder.getPanel();
	}
nezka.slogowickt

Se você quiser usar os gerenciadores do JDK, é bom você ler um pouco sobre o que faz cada um e como funciona.

FlowLayout
BorderLayout
GridLayout
GridBagLayout

O FlowLayout é o padrão e só posiciona os componentes lado a lado.
O BorderLayout você pode definir usando as posições Norte, Sul, Leste, Oeste e Centro.
O GridLayout define um layout que é tipo uma tabela, mas todos os campos tem o mesmo tamanho, que segue o do maior adicionado.
E o GridBagLayout, mesmo sendo o mais difícil de usar, é o mais flexível.
Ele cria, também, uma tabela, mas você pode definir quantos campos dessa tabela algum componente vai ocupar.

[]'s

aangreen

faz assim cara cria no JBuilder X as telas do jeito q vc quer com layout null, dai anota todas as cordenadas.........

Depois vc cria as telas manualmente com layout null e usa as cordenadas...
fica bem legal, ja fiz isso....

olha um ex:

package apresentacao;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.text.ParseException;

import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFormattedTextField;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.text.MaskFormatter;

import regranegocio.CClientes;
import controle.CControle;

public class CFrameCadastroCliente extends JInternalFrame implements
		ActionListener {

	private JLabel labelNome;

	private JFormattedTextField textoNome;

	private JLabel labelEnd;

	private JFormattedTextField textoEnd;

	private JLabel labelBairro;

	private JFormattedTextField textoBairro;

	private JLabel labelTel;

	private JFormattedTextField textoTel;

	private JLabel labelCidade;

	private JFormattedTextField textoCidade;

	private JLabel labelCompl;

	private JFormattedTextField textoCompl;

	private JLabel labelCel;

	private JLabel labelObservacao;
	private JTextField textoObservacao;
	
	private JFormattedTextField textoCel;

	private JLabel labelCpf;

	private JFormattedTextField textoCpf;

	private JLabel labelEmail;

	private JFormattedTextField textoEmail;

	private JLabel labelCep;

	private JFormattedTextField textoCep;

	private JLabel labelDependentes;

	private JRadioButton radioSim;

	private JLabel labelNumeroCasa;
	private JFormattedTextField textoNumeroCasa;
	
	private JRadioButton radioNao;

	private JButton botaoCadastrar;

	private JButton botaoFechar;

	private CControle controle;

	private boolean erro;
	
	private MaskFormatter formatonome;
	
	private MaskFormatter formatobairro;
	
	private MaskFormatter formatocidade;
	
	private MaskFormatter formatotelefone;
	
	private MaskFormatter formatocep;
	
	private MaskFormatter formatocpf;
	
	private MaskFormatter formatocel;
	
	private MaskFormatter formatonumero;
	
	private EventoCadastroCliente evento;

	public CFrameCadastroCliente() {
		super("Cadastro Cliente", true, true, true, true);
		// TODO Auto-generated constructor stub
		this.setSize(new Dimension(700, 370));
		
		evento = new EventoCadastroCliente();
		
		Container conteudo = getContentPane();
		conteudo.setLayout(null);

		labelNome = new JLabel("Nome");
		labelNome.setBounds(14, 18, 84, 19);
		textoNome = new JFormattedTextField();
		textoNome.setToolTipText("Teste!!!");
		textoNome.setBounds(70, 18, 578, 19);
		textoNome.requestFocus();
		textoNome.registerKeyboardAction(evento,
		        KeyStroke.getKeyStroke(KeyEvent.
		                VK_ENTER, 0), JComponent.WHEN_FOCUSED);
		textoNome.addActionListener(evento);
		
		labelEnd = new JLabel("Endereço");
		labelEnd.setBounds(14, 46, 84, 19);
		textoEnd = new JFormattedTextField();
		textoEnd.setBounds(70, 46, 372, 19);
		textoEnd.registerKeyboardAction(evento,
		        KeyStroke.getKeyStroke(KeyEvent.
		                VK_ENTER, 0), JComponent.WHEN_FOCUSED);
		textoEnd.addActionListener(evento);
		
		labelBairro = new JLabel("Bairro");
		labelBairro.setBounds(465, 46, 84, 19);
		textoBairro = new JFormattedTextField();
		textoBairro.setBounds(506, 46, 142, 19);
		textoBairro.registerKeyboardAction(evento,
		        KeyStroke.getKeyStroke(KeyEvent.
		                VK_ENTER, 0), JComponent.WHEN_FOCUSED);
		textoBairro.addActionListener(evento);

		labelTel = new JLabel("Telefone");
		labelTel.setBounds(14, 102, 84, 19);
		textoTel = new JFormattedTextField();
		textoTel.setBounds(70, 102, 105, 19);
		textoTel.registerKeyboardAction(evento,
		        KeyStroke.getKeyStroke(KeyEvent.
		                VK_ENTER, 0), JComponent.WHEN_FOCUSED);
		textoTel.addActionListener(evento);

		labelCidade = new JLabel("Cidade");
		labelCidade.setBounds(14, 74, 84, 19);
		textoCidade = new JFormattedTextField();
		textoCidade.setBounds(70, 74, 161, 19);
		textoCidade.registerKeyboardAction(evento,
		        KeyStroke.getKeyStroke(KeyEvent.
		                VK_ENTER, 0), JComponent.WHEN_FOCUSED);
		textoCidade.addActionListener(evento);

		labelCompl = new JLabel("Complemento");
		labelCompl.setBounds(267, 74, 84, 19);
		textoCompl = new JFormattedTextField();
		textoCompl.setBounds(349, 74, 105, 19);
		textoCompl.registerKeyboardAction(evento,
		        KeyStroke.getKeyStroke(KeyEvent.
		                VK_ENTER, 0), JComponent.WHEN_FOCUSED);
		textoCompl.addActionListener(evento);

		labelCel = new JLabel("Celular");
		labelCel.setBounds(242, 102, 84, 19);
		textoCel = new JFormattedTextField();
		textoCel.setBounds(289, 102, 105, 19);
		textoCel.registerKeyboardAction(evento,
		        KeyStroke.getKeyStroke(KeyEvent.
		                VK_ENTER, 0), JComponent.WHEN_FOCUSED);
		textoCel.addActionListener(evento);

		labelNumeroCasa = new JLabel("Número");
		labelNumeroCasa.setBounds(465, 102,84,19);
		textoNumeroCasa = new JFormattedTextField();
		textoNumeroCasa.setBounds(506,102,130,19);
		textoNumeroCasa.registerKeyboardAction(evento,
				KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
				JComponent.WHEN_FOCUSED);
		
		
		labelCpf = new JLabel("CPF");
		labelCpf.setBounds(267, 130, 84, 19);
		textoCpf = new JFormattedTextField();
		textoCpf.setBounds(302, 130, 120, 19);
		textoCpf.registerKeyboardAction(evento,
		        KeyStroke.getKeyStroke(KeyEvent.
		                VK_ENTER, 0), JComponent.WHEN_FOCUSED);
		textoCpf.addActionListener(evento);

		labelEmail = new JLabel("e-mail");
		labelEmail.setBounds(14, 158, 84, 19);
		textoEmail = new JFormattedTextField();
		textoEmail.setBounds(70, 158, 441, 19);
		textoEmail.registerKeyboardAction(evento,
		        KeyStroke.getKeyStroke(KeyEvent.
		                VK_ENTER, 0), JComponent.WHEN_FOCUSED);
		textoEmail.addActionListener(evento);

		labelCep = new JLabel("CEP");
		labelCep.setBounds(485, 74, 84, 19);
		textoCep = new JFormattedTextField();
		textoCep.setBounds(512, 74, 136, 19);
		textoCep.registerKeyboardAction(evento,
		        KeyStroke.getKeyStroke(KeyEvent.
		                VK_ENTER, 0), JComponent.WHEN_FOCUSED);
		textoCep.addActionListener(evento);
		
		labelObservacao = new JLabel("Observação:");
		labelObservacao.setBounds(14,186,100,19);
		textoObservacao = new JTextField();
		textoObservacao.setBounds(14,205,578,50);
		textoObservacao.registerKeyboardAction(evento,
		        KeyStroke.getKeyStroke(KeyEvent.
		                VK_ENTER, 0), JComponent.WHEN_FOCUSED);
		textoObservacao.addActionListener(evento);
		
		botaoCadastrar = new JButton("Cadastrar");
		botaoCadastrar.setBounds(361, 290, 127, 35);
		botaoCadastrar.setMnemonic('C');
		botaoCadastrar.registerKeyboardAction(evento,
		        KeyStroke.getKeyStroke(KeyEvent.
		                VK_ENTER, 0), JComponent.WHEN_FOCUSED);
		botaoCadastrar.addActionListener(evento);
		
		botaoFechar = new JButton("Fechar");
		botaoFechar.setBounds(518, 290, 127, 35);
		botaoFechar.setMnemonic('F');
		botaoFechar.registerKeyboardAction(evento,
		        KeyStroke.getKeyStroke(KeyEvent.
		                VK_ENTER, 0), JComponent.WHEN_FOCUSED);
		botaoFechar.addActionListener(evento);

		controle = new CControle();
		try {
		formatonome = new MaskFormatter("*****************************************************");
		formatobairro = new MaskFormatter("******************************************");
		formatocidade = new MaskFormatter("******************************************");
		formatotelefone = new MaskFormatter("########");
		formatocel = new MaskFormatter("########");
		formatocep = new MaskFormatter("#########");
		formatocpf = new MaskFormatter("###########");
		formatonumero = new MaskFormatter("#######");
		
		formatonome.setValidCharacters(" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
		formatonome.install(textoNome);
		formatobairro.setValidCharacters(" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
		formatobairro.install(textoBairro);
		formatocidade.setValidCharacters(" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
		formatocidade.install(textoCidade);
		formatocep.setValidCharacters("[telefone removido]");
		formatocep.install(textoCep);
		formatotelefone.setValidCharacters("[telefone removido]");
		formatotelefone.install(textoTel);
		formatocel.setValidCharacters("[telefone removido]");
		formatocel.install(textoCel);
		formatocpf.setValidCharacters("[telefone removido]");
		formatocpf.install(textoCpf);
		formatonumero.setValidCharacters("[telefone removido]");
		formatonumero.install(textoNumeroCasa);
		}
	    catch (ParseException e) {
	      System.out.print("Nao deu de novo");
	    }
	    
		conteudo.add(labelNome);
		conteudo.add(textoNome);
		conteudo.add(labelEnd);
		conteudo.add(textoEnd);
		conteudo.add(labelBairro);
		conteudo.add(textoBairro);
		conteudo.add(labelTel);
		conteudo.add(textoTel);
		conteudo.add(labelCidade);
		conteudo.add(textoCidade);
		conteudo.add(labelCompl);
		conteudo.add(textoCompl);
		conteudo.add(labelCel);
		conteudo.add(textoCel);
		conteudo.add(labelCpf);
		conteudo.add(textoCpf);
		conteudo.add(labelEmail);
		conteudo.add(textoEmail);
		conteudo.add(botaoCadastrar);
		conteudo.add(botaoFechar);
		conteudo.add(labelCep);
		conteudo.add(textoCep);
		conteudo.add(labelNumeroCasa);
		conteudo.add(textoNumeroCasa);
		conteudo.add(labelObservacao);
		conteudo.add(textoObservacao);
		
	}

	public boolean verificaTextos() {
		erro = true;
		while (erro) {
			if (textoNome.getText().trim().equals("")) {
				textoNome.requestFocus();
				JOptionPane.showMessageDialog(null,
						"Campo Nome não pode estar vazio!!!",
						"Locadora Video Force", 0);
				break;
			} else if (textoEnd.getText().trim().equals("")) {
				textoEnd.requestFocus();
				JOptionPane.showMessageDialog(null,
						"Campo Endereço não pode estar vazio!!!",
						"Locadora Video Force", 0);
				break;
			}else if (textoBairro.getText().trim().equals("")) {
				textoBairro.requestFocus();
				JOptionPane.showMessageDialog(null,
						"Campo Bairro não pode estar vazio!!!",
						"Locadora Video Force", 0);
				break;
			}else if (textoCidade.getText().trim().equals("")) {
				textoCidade.requestFocus();
				JOptionPane.showMessageDialog(null,
						"Campo Cidade não pode estar vazio!!!",
						"Locadora Video Force", 0);
				break;
			}else if (textoCep.getText().trim().equals("")) {
				textoCep.requestFocus();
				JOptionPane.showMessageDialog(null,
						"Campo CEP não pode estar vazio!!!",
						"Locadora Video Force", 0);
				break;
			}else if (textoCompl.getText().trim().equals("")) {
				textoCompl.requestFocus();
				JOptionPane.showMessageDialog(null,
						"Campo Complemento não pode estar vazio!!!",
						"Locadora Video Force", 0);
				break;
			}else if (textoTel.getText().trim().equals("")) {
				textoTel.requestFocus();
				JOptionPane.showMessageDialog(null,
						"Campo Telefone não pode estar vazio!!!",
						"Locadora Video Force", 0);
				break;
			}else if (textoCpf.getText().trim().equals("")) {
				textoCpf.requestFocus();
				JOptionPane.showMessageDialog(null,
						"Campo CPF não pode estar vazio!!!",
						"Locadora Video Force", 0);
				break;
			} else {
				erro = false;
			}
		}
		return erro;
	}
	class EventoCadastroCliente implements ActionListener {
		public void actionPerformed(ActionEvent evento) {
			if (evento.getSource() == textoNome) {
				textoEnd.requestFocus();
			}
			if (evento.getSource() == textoEnd) {
				textoBairro.requestFocus();
			}
			if (evento.getSource() == textoBairro) {
				textoCidade.requestFocus();
			}
			if (evento.getSource() == textoCidade) {
				textoCompl.requestFocus();
			}
			if (evento.getSource() == textoCep) {
				textoTel.requestFocus();
			}
			if (evento.getSource() == textoCompl) {
				textoCep.requestFocus();
			}
			if (evento.getSource() == textoTel) {
				textoCel.requestFocus();
			}
			if (evento.getSource() == textoCel) {
				textoNumeroCasa.requestFocus();
			}
			if (evento.getSource() == textoNumeroCasa) {
				textoCpf.requestFocus();
			}
			if (evento.getSource() == textoEmail) {
				textoObservacao.requestFocus();
			}
			if (evento.getSource() == textoCpf) {
				textoEmail.requestFocus();
			}
			if (evento.getSource() == textoObservacao) {
				botaoCadastrar.requestFocus();
			}
			if (evento.getSource() == botaoCadastrar) {
				CClientes temp = new CClientes();
				verificaTextos();

				if (erro == false) {
					temp.setNome(textoNome.getText());
					temp.setEndereco(textoEnd.getText());
					temp.setBairro(textoBairro.getText());
					temp.setCidade(textoCidade.getText());
					temp.setCep(Integer.parseInt(textoCep.getText().trim()));
					temp.setComplemento(textoCompl.getText());
					temp.setTel(Integer.parseInt(textoTel.getText().trim()));
					if (!textoCel.getText().trim().equals("")){ 
						
						temp.setCelular(Integer.parseInt(textoCel.getText().trim()));
					}else {temp.setCelular(0);}
					temp.setEmail(textoEmail.getText());
					temp.setCpf(Long.parseLong(textoCpf.getText().trim()));
					temp.setNumerocasa(Long.parseLong(textoNumeroCasa.getText().trim()));
					temp.setObservacao(textoObservacao.getText());
					try {
						controle.cadastrarCliente(temp);

					} catch (Exception e) {
						e.printStackTrace();
					}
					textoNome.setText("");
					textoEnd.setText("");
					textoBairro.setText("");
					textoCidade.setText("");
					textoCep.setText("");
					textoCompl.setText("");
					textoTel.setText("");
					textoCel.setText("");
					textoEmail.setText("");
					textoCpf.setText("");
					textoNumeroCasa.setText("");
					textoObservacao.setText("");
					textoNome.requestFocus();
				}

			}
			if (evento.getSource() == botaoFechar) {
				dispose();
			}
			if (evento.getSource() == radioSim) {
				radioNao.setSelected(false);
			}
			if (evento.getSource() == radioNao) {
				radioSim.setSelected(false);
			}

		}
	}
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
	}

}
hvivox

Obrigado pela ajuda, estou com dicudade em rodar sua tela, pois, essas bibliotecas estao dando erro! vc pode me envialas por favor

import regranegocio.CClientes;
import controle.CControle;

M

ola

para criar a interface grafica da minha aplicacao uso spring layout veja neste site
http://java.sun.com/docs/books/tutorial/uiswing/layout/spring.html

tem uns exemplos bem interessantes

hvivox

Obrigado pela ajuda, gostaria de ter sua colaboração mais vez. Se vc poder contribuir um pouco mais ficarei muito agradecido.

H

Você poderia postar o codigo fonte das classes:

import regranegocio.CClientes;
import controle.CControle;

para q eu possa testar o seu exemplo…

Grato…

hvivox

Mesmo com toda a ajuda recebida não cosequi atingir meu objetiovo.
Estou esperando a sua contribuição e agradeço toda ajuda dos parceiros.

diego2005

Você quer fazer uma interface específica ou quer aprender a usar os gerenciadores de layout???

hvivox

As duas coisas, vc pode me ajudar? Estou precisando urgentemente de contribuições.

hvivox

Quero pedir encorecidamente mais contribuções para ajudar não só a mim mas uma série de desenvolvedores que carecem de conhecimentos.

OBRIGADO!

hvivox

Fala, moçada ainda estou esperando respostas

OBRIGADO

hvivox

//Estou montando telas para uma locadora, esta é a tela de login

import java.awt.<em>;

import java.awt.event.</em>;

import javax.swing.<em>;

import javax.swing.event.</em>;

class ExIntGrafica13 extends JFrame implements ActionListener{

JLabel L1, L2;

JTextField T1, T2;

JButton B1, B2;
public static void main(String args[]) {

JFrame janela = new ExIntGrafica13(); //declaracao e inicializacao do objeto janela

janela.show(); //mostra a janela na tela

WindowListener x = new WindowAdapter(){

public void windowClosing(WindowEvent e){

System.exit(0);

}

};

janela.addWindowListener(x);

}
ExIntGrafica13(){ //construtor

setBackground(new Color (190,190,190));

setSize(220, 300);

setTitle(Locadora - Login); //titulo da janela

getContentPane().setLayout(new GridLayout(10, 1, 5, 0));
L1 = new JLabel(Usuário,JLabel.LEFT);

L1.setForeground(Color.BLACK);

L2 = new JLabel(Login,JLabel.LEFT);

L2.setForeground(Color.BLACK);

T1 = new JTextField("",10);//(Rotulo padrao, tamanho da caixa de texto
T2 = new JTextField("",10);

B1 = new JButton(“OK”);

B1.addActionListener(this);

B1.setToolTipText(“Clique para validar login”);

B1.setMnemonic(KeyEvent.VK_O);
B2 = new JButton(Cancelar);

B2.addActionListener(this);

B2.setToolTipText(Clique para não salvar as alterações);

B2.setMnemonic(KeyEvent.VK_C);
getContentPane().add(L1);

getContentPane().add(T1);

getContentPane().add(L2);

getContentPane().add(T2);

getContentPane().add(B1);

getContentPane().add(B2);

}
public void actionPerformed (ActionEvent e){

String resp = JOptionPane.showInputDialog(null,Qual é o seu nome?,Login no sistema,JOptionPane.QUESTION_MESSAGE);

if(!(resp == null|| resp.equals("")))

L1.setText("Seja bem vindo "+ resp + !!);

else
L1.setText("");

}
}

cassio

É só digitar “Java Swing” no google e colocar páginas em português :slight_smile:

Aparece um monte de tutorial em português meu caro…

Abraço!

hvivox

fala moçada estou esperando novidades

hvivox

fala galera

leandroluchinil

olá

quem poder ajudar da uma dica,

eu tambem estou com alguns problemas com isso

ajuda

Grato

Leandro

Ermin

cara experimenta usar o netBeans, se precisar vc
usa umas bibliotecas externas!
flw!

Marky.Vasconcelos

O que voce espera da gente?

O que eu posso fazer é te indicar a usar o MigLayout.

Esse tópico é de 2006 por que alguem ressucitou? Nem tinha percebido.

hvivox

Abri esse topico quando era java baby,

agora estou em outra, estou me especializando em web. Mas… o q posso deixar para resolver o problema é recomendar a utilização da UI GIGLOO

ajudou mto e vai ajudar mtos também.

aTt.

hvivox

hvivox:
//Estou montando telas para uma locadora, esta é a tela de login

import java.awt.<em>;

import java.awt.event.</em>;

import javax.swing.<em>;

import javax.swing.event.</em>;

class ExIntGrafica13 extends JFrame implements ActionListener{

JLabel L1, L2;

JTextField T1, T2;

JButton B1, B2;
public static void main(String args[]) {

JFrame janela = new ExIntGrafica13(); //declaracao e inicializacao do objeto janela

janela.show(); //mostra a janela na tela

WindowListener x = new WindowAdapter(){

public void windowClosing(WindowEvent e){

System.exit(0);

}

};

janela.addWindowListener(x);

}
ExIntGrafica13(){ //construtor

setBackground(new Color (190,190,190));

setSize(220, 300);

setTitle(Locadora - Login); //titulo da janela

getContentPane().setLayout(new GridLayout(10, 1, 5, 0));
L1 = new JLabel(Usuário,JLabel.LEFT);

L1.setForeground(Color.BLACK);

L2 = new JLabel(Login,JLabel.LEFT);

L2.setForeground(Color.BLACK);

T1 = new JTextField("",10);//(Rotulo padrao, tamanho da caixa de texto
T2 = new JTextField("",10);

B1 = new JButton(“OK”);

B1.addActionListener(this);

B1.setToolTipText(“Clique para validar login”);

B1.setMnemonic(KeyEvent.VK_O);
B2 = new JButton(Cancelar);

B2.addActionListener(this);

B2.setToolTipText(Clique para não salvar as alterações);

B2.setMnemonic(KeyEvent.VK_C);
getContentPane().add(L1);

getContentPane().add(T1);

getContentPane().add(L2);

getContentPane().add(T2);

getContentPane().add(B1);

getContentPane().add(B2);

}
public void actionPerformed (ActionEvent e){

String resp = JOptionPane.showInputDialog(null,Qual é o seu nome?,Login no sistema,JOptionPane.QUESTION_MESSAGE);

if(!(resp == null|| resp.equals("")))

L1.setText("Seja bem vindo "+ resp + !!);

else
L1.setText("");

}
}

Criado 20 de setembro de 2006
Ultima resposta 17 de jul. de 2010
Respostas 23
Participantes 12