> Hi,
>
[quoted text clipped - 17 lines]
> at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
> at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
> at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
> at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
[quoted text clipped - 6 lines]
> Thanks
> Connell
You'll need to show your code.
Show us what you do on line 66 in qlsettings, and show where you initialize
the objects you use on that line.

Signature
Regards,
Christophe Vanfleteren
Connell Gauld - 29 Nov 2003 22:25 GMT
I removed some unimportant stuff from below but line 66 was:
String str=new String(txtDatabaseAddress.getText());
The rest of the code is below:
import java.awt.*;
import java.io.*;
import javax.swing.*;
public class qlsettings extends Frame {
protected Button cmdSave;
protected Button cmdCancel;
protected TextField txtServerAddress;
protected TextField txtServerPassword;
private JTextField txtServerPort;
protected TextField txtDatabaseAddress;
qi uParent;
public qlsettings(qi parent, Frame mth){
uParent=parent;
setResizable(false);
setBackground(new Color(223,223,223));
setTitle("Settings");
setLayout(new GridLayout(5,2,3,3));
add(new Label("Server Address"));
TextField txtServerAddress=new TextField(uParent.qlserveraddress);
add(txtServerAddress);
add(new Label("Server Port"));
JTextField txtServerPort=new JTextField(uParent.qlserverport);
add(txtServerPort);
add(new Label("Server Password"));
TextField txtServerPassword=new TextField(uParent.qlserverpassword);
txtServerPassword.setEchoChar('*');
add(txtServerPassword);
add(new Label("Database Address"));
TextField txtDatabaseAddress=new TextField(uParent.dbserveraddress);
add(txtDatabaseAddress);
cmdSave=new Button("Save");
cmdCancel=new Button("Cancel");
add(cmdSave);
add(cmdCancel);
pack();
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((screen.width-getWidth())/2,(screen.height-getHeight())/2);
show();
System.out.println(txtDatabaseAddress.getText());
}
public boolean action(Event evt, Object whichAction){
if (evt.target==cmdSave){
outer();
}
if (evt.target==cmdCancel){
hide();
}
return true;
}
public void outer(){
String str=new String(txtDatabaseAddress.getText());
}
}
Christophe Vanfleteren - 30 Nov 2003 02:02 GMT
> I removed some unimportant stuff from below but line 66 was:
>
> String str=new String(txtDatabaseAddress.getText());
Actually, you don't need to use the String constructor for that (you almost
never need it).
Just typing "String str = txtDatabaseAddress.getText()" will do.
> The rest of the code is below:
>
[quoted text clipped - 21 lines]
> TextField txtServerAddress=new
> TextField(uParent.qlserveraddress); add(txtServerAddress);
These kind of lines are the problem:
You're defining a new variable of type TextField with the same name as one of
your instance variables. So in this scope (the scope of the constructor),
txtServerAddress is not the same variable as the txtServerAddress of your
class. Because of this, your "normal", instance variable txtServerAddress
never gets a value, and hence will throw nullpointerexceptions if you try to
dereference it.
Just leave the declaration of the type away and type 'txtServerAddress = ..."
instead.
The compiler should at least issue warnings in cases like these IMO.

Signature
Regards,
Christophe Vanfleteren
Connell Gauld - 30 Nov 2003 11:55 GMT
Worked great, thanks!
>> I removed some unimportant stuff from below but line 66 was:
>>
[quoted text clipped - 43 lines]
>
> The compiler should at least issue warnings in cases like these IMO.