eu tava tentando fazer sózinho, mas tem algo q ta dando errado ainda!!
Se alguem souber oq é, porfavor me mande respostas!!
Obrigado!
import javax.swing.JFrame;
import javax.swing.;
import java.awt.event.;
import java.awt.;
import java.applet.;
import java.io.;
import java.lang.;
public class Senha extends JFrame {
private GridBagLayout layout;
private GridBagConstraints constraints;
public Senha() {
super( “Registro” );
layout = new GridBagLayout();
constraints = new GridBagConstraints();
setLayout( layout );
JLabel texto1 = new JLabel("Digite o Nome");
JLabel texto2 = new JLabel("Digite a Senha");
JPasswordField nome = new JPasswordField( "Digite aqui" );
JPasswordField senha = new JPasswordField( "00000000000" );
JButton botao1 = new JButton( " Ok " );
JButton botao2 = new JButton( "Cancelar" );
constraints.weightx = 0;
constraints.weighty = 0;
addComponent( texto1, 1, 1, 1, 1 );
addComponent( texto2, 2, 1, 1, 1 );
addComponent( nome, 1, 2, 1, 1 );
addComponent( senha, 2, 2, 1, 1 );
addComponent( botao1, 4, 1, 1, 1 );
addComponent( botao2, 4, 2, 1, 1 );
senha.setEchoChar('*');
senha.addActionListener(this);
botao1.addActionListener(this);
}
private void addComponent( Component component,
int row, int column, int width, int height ) {
constraints.gridy = row;
constraints.gridx = column;
constraints.gridwidth = width;
constraints.gridheight = height;
layout.setConstraints( component, constraints );
add( component );
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource().equals(botao2));
System.exit(0);
// else
}
public static void main( String args[] )
{
Senha gridBagFrame = new Senha();
gridBagFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
gridBagFrame.setBackground(new Color(236,233,216));
gridBagFrame.setSize( 200, 100 );
gridBagFrame.setVisible( true );
}
}