Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/07/2010, 09:07
vrmad
 
Fecha de Ingreso: julio-2010
Mensajes: 1
Antigüedad: 13 años, 9 meses
Puntos: 0
Pregunta Duda con netbeans 6.9 y contraseña

Hola, me presento en este foro con una duda, estoy haciendo un proyecto que consista en una ventana que te pregunte nombre y cotnraseña, con un boton de salida y otro para aceptar, tengo el metodo main sin tocar y el jframe con :
[
Código PHP:
package contraseña;

/**
 *
 * @author peter
 */
public class NewJFrame extends javax.swing.JFrame {

    
/** Creates new form NewJFrame */
    
public NewJFrame() {
        
initComponents();
    }

    
/** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    
@SuppressWarnings("unchecked")
    
// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    
private void initComponents() {

        
jPanel1 = new javax.swing.JPanel();
        
jLabel1 = new javax.swing.JLabel();
        
jLabel2 = new javax.swing.JLabel();
        
jTextField1 = new javax.swing.JTextField();
        
jPasswordField1 = new javax.swing.JPasswordField();
        
jButton1 = new javax.swing.JButton();
        
jButton2 = new javax.swing.JButton();

        
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        
jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        
jLabel1.setText("Nombre:");

        
jLabel2.setText("Contraseña:");

        
jButton1.setText("Ok");

        
jButton2.setText("Salir");
        
jButton2.addActionListener(new java.awt.event.ActionListener() {
            public 
void actionPerformed(java.awt.event.ActionEvent evt) {
                
jButton2ActionPerformed(evt);
            }
        });

        
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        
jPanel1.setLayout(jPanel1Layout);
        
jPanel1Layout.setHorizontalGroup(
            
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .
addGroup(jPanel1Layout.createSequentialGroup()
                .
addContainerGap()
                .
addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADINGfalse)
                    .
addGroup(jPanel1Layout.createSequentialGroup()
                        .
addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .
addComponent(jLabel1)
                            .
addComponent(jLabel2))
                        .
addGap(139139139)
                        .
addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADINGfalse)
                            .
addComponent(jTextField1)
                            .
addComponent(jPasswordField1javax.swing.GroupLayout.DEFAULT_SIZE95Short.MAX_VALUE)))
                    .
addGroup(jPanel1Layout.createSequentialGroup()
                        .
addComponent(jButton1)
                        .
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATEDjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
                        .
addComponent(jButton2)))
                .
addContainerGap(92Short.MAX_VALUE))
        );
        
jPanel1Layout.setVerticalGroup(
            
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .
addGroup(jPanel1Layout.createSequentialGroup()
                .
addGap(525252)
                .
addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .
addComponent(jLabel1)
                    .
addComponent(jTextField1javax.swing.GroupLayout.PREFERRED_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.PREFERRED_SIZE))
                .
addGap(919191)
                .
addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .
addComponent(jLabel2)
                    .
addComponent(jPasswordField1javax.swing.GroupLayout.PREFERRED_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.PREFERRED_SIZE))
                .
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED64Short.MAX_VALUE)
                .
addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .
addComponent(jButton1)
                    .
addComponent(jButton2))
                .
addGap(262626))
        );

        
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        
getContentPane().setLayout(layout);
        
layout.setHorizontalGroup(
            
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .
addComponent(jPanel1javax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
        );
        
layout.setVerticalGroup(
            
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .
addComponent(jPanel1javax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
        );

        
pack();
    }
// </editor-fold>                        

    
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        
// TODO add your handling code here:
        
System.exit(-1);
    }                                        

    
/**
    * @param args the command line arguments
    */
    
public static void main(String args[]) {
        
java.awt.EventQueue.invokeLater(new Runnable() {
            public 
void run() {
                new 
NewJFrame().setVisible(true);
            }
        });
    }

    
// Variables declaration - do not modify                     
    
private javax.swing.JButton jButton1;
    private 
javax.swing.JButton jButton2;
    private 
javax.swing.JLabel jLabel1;
    private 
javax.swing.JLabel jLabel2;
    private 
javax.swing.JPanel jPanel1;
    private 
javax.swing.JPasswordField jPasswordField1;
    private 
javax.swing.JTextField jTextField1
Mi duda es que pongo y donde para que al poner por ejemplo de nombre A y de contraseña B, y al dar al ok, te salga una ventana que ponga contraseña incorrecta, y si no es correcta pues contrasea incorrecta, gracias.