Vor eig. Appstart ein Login funktioniert nicht

DJ WeSt

Neues Mitglied
Hallo Leute,

ich bin dabei mir eine kleine Desktop Anwendung zu schreiben allerdings stoße ich auf ein Problem.
Hier mal mein Code der main Class:
Java:
/*
 * SKSJBusiness2011App.java
 */

package sksjbusiness2011;

import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;

/**
 * The main class of the application.
 */
public class SKSJBusiness2011App extends SingleFrameApplication {
    
    private SKSJBusiness2011Login login;
   
    @Override protected void startup() {
        
        show(new SKSJBusiness2011Login(login));  
        
        if(login.loginApp() == true){
            show(new SKSJBusiness2011View(this)); 
        
        }
    }
    /*
    private SKSJBusiness2011Login login = new SKSJBusiness2011Login( null ); 
    
    @Override protected void startup() {
    show(new SKSJBusiness2011Login(login));     
        
            if(login.loginApp() == true){
                   show(new SKSJBusiness2011View(this)); 
            }
    }
    */
    /**
     * This method is to initialize the specified window by injecting resources.
     * Windows shown in our application come fully initialized from the GUI
     * builder, so this additional configuration is not needed.
     */
    @Override protected void configureWindow(java.awt.Window root) {
    }

    /**
     * A convenient static getter for the application instance.
     * @return the instance of SKSJBusiness2011App
     */
    public static SKSJBusiness2011App getApplication() {
        return Application.getInstance(SKSJBusiness2011App.class);
    }

    /**
     * Main method launching the application.
     */
    public static void main(String[] args) {
        launch(SKSJBusiness2011App.class, args);
    }
}

und hier der Code der Loginklasse:
Java:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * SKSJBusiness2011Login.java
 *
 * Created on 07.06.2011, 11:10:17
 */
package sksjbusiness2011;

import org.jdesktop.application.Action;

/**
 *
 * @author ll
 */
public class SKSJBusiness2011Login extends javax.swing.JDialog {

    /** Creates new form SKSJBusiness2011Login */
    public SKSJBusiness2011Login(java.awt.Dialog parent) {
        super(parent);
        initComponents();
        setLocationRelativeTo(null);
    }
    
    @Action public boolean loginApp(){    
        
        if(jTextField1.getText().equals("Admin")){   
            System.out.println("Der Benutzername ist korrekt!");
            dispose();
            return true;
        }
        else {
            System.out.println("Der Benutzername ist falsch!");
        }
        return true;
    }
        
    @Action public void closeLoginBox() {
        dispose();
    }

    /** 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() {

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

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(sksjbusiness2011.SKSJBusiness2011App.class).getContext().getResourceMap(SKSJBusiness2011Login.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setName("Form"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(sksjbusiness2011.SKSJBusiness2011App.class).getContext().getActionMap(SKSJBusiness2011Login.class, this);
        jButton1.setAction(actionMap.get("loginApp")); // NOI18N
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N

        jButton2.setAction(actionMap.get("closeLoginBox")); // NOI18N
        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N

        jPasswordField1.setText(resourceMap.getString("jPasswordField1.text")); // NOI18N
        jPasswordField1.setName("jPasswordField1"); // NOI18N

        jTextField1.setText(resourceMap.getString("jTextField1.text")); // NOI18N
        jTextField1.setName("jTextField1"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 86, Short.MAX_VALUE)
                        .addComponent(jButton2))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2))
                        .addGap(37, 37, 37)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jPasswordField1)
                            .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

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

    /**
     * @param args the command line arguments
     */

    // 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.JPasswordField jPasswordField1;
    public javax.swing.JTextField jTextField1;
    // End of variables declaration                   
}

Ich bekomme eine NullpointerException in der Mainklasse Methode startup() bei der If-Abfrage weshalb ?
Ich bin kein wirklicher Javaexperte also bitte ich um Nachsicht bin ja hier um es zu lernen.
 
Java:
private SKSJBusiness2011Login login;
Danach ist login noch null.
 
Okay was mich halt wundert ist der Logindialog startet, allerdings nach Klick auf anmelden passiert nix mehr.
Wo doch eigentlich die eigentliche App gestartet werden sollte.
 

Zurück
Oben