Aqui dejo mi codigo para ver si pueden ayudarme, de antemano gracias.
Código:
import java.awt.Button; import java.awt.Color; import java.awt.Component; import java.awt.Frame; import java.awt.Label; import java.awt.Panel; import java.awt.TextField; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPasswordField; public class FramePassword extends JFrame{ static TextField Ps; static Label La1,La2; static Button BU; static JPasswordField TF1; static Frame R =new Frame(); static Panel P; public static void main(String[] args) { FramePassword FP =new FramePassword(); FP.setLayout(null); P=new Panel(); TF1=new JPasswordField(28); Ps=new TextField(40); La1=new Label("Usuario"); La2=new Label("Contraseña"); BU=new Button("Entrar"); //P.setLayout(null); Ps.setLocation(400,150); La1.setLocation(530, 100); La1.setForeground( Color.white ); TF1.setLocation(400,300); La2.setLocation(530,250); La2.setForeground( Color.white ); BU.setLocation(530, 400); P.setSize(1000, 650); P.setBackground(new Color(25,0,25)); P.add(Ps); P.add(TF1); P.add(La1); P.add(La2); P.add(BU); FP.add(P); BU.addActionListener(new ActionListener(){ private Component parentComponent; public void actionPerformed(ActionEvent e) { if (Ps.getText().equals("a")&&TF1.getText().equals("a")) { System.out.println("Buajaja"); } else { JOptionPane.showMessageDialog(parentComponent, "Los Datos Introducidos Es Incorrecta \n Verifique Su Usuario/Contraseña", "Error!", JOptionPane.ERROR_MESSAGE); } }}); FP.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.runFinalizersOnExit(true); }}); FP.pack(); FP.setVisible(true); FP.setSize(1000, 650); FP.setBackground(new Color(25,0,25)); FP.setResizable(false); } }