Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Null Exception

Empfohlene Antworten

Hi, ich hab hier ein kleines Problem mit einem Anmeldungsfenster. Sobald ich etwas eingegeben habe, und auf Enter drücke bekomme ich diese Exception. Ich poste mal den Code:

################################################

import java.awt.*;

import java.awt.event.*;

class Password extends Frame

implements ActionListener{

TextField pass;

public void showFrame(){

setTitle("Authentifizierung");

setLayout(new FlowLayout());

setSize(220,100);

// Label:

Label l = new Label("Passwort: ");

add(l);

// TextField:

TextField pass = new TextField(11);

pass.setEchoChar('#');

add(pass);

//pass.addActionListener(this);

//Button

Button ok = new Button("OK");

ok.addActionListener(this);

add(ok);

//Fensteraktivitäten

addWindowListener(

new WindowAdapter ()

{ public void windowClosing (WindowEvent e)

{

dispose();

System.exit(0);

}

}

);

}

public void actionPerformed (ActionEvent e)

{

System.out.println(pass.getText());

}

}

##################################################

Ich habe es mal mit einem Button probiert, aber da tritt dass gleiche Problem wie mit Enter auf.

Für Hilfe wäre ich sehr dankbar.

Hallo,

diese Zeile: TextField pass = new TextField(11);

muss so lauten: pass = new TextField(11);

da du TextField pass schon als Klassenvariable definiert hast.

Gruß Jaraz

PS: Poste das nächste mal auch bitte den Stacktrace der Exception, dann ist das Suchen einfacher. :)

Hi,

danke echt cool für die schnelle Hilfe. :P

Und danke für den Tip ("immer diese Newbies")!

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.