I just converted some code over from java 1.0 - an application, not an applet.
So, instead of using show(), I need to use something like setVisible(true);
(I think)
Here is the relevant code: (inside of the class AllComponents)
public static void main(String[] args) {
Frame f = new AllComponents("AWT Demo");
// We should call f.pack() here. But its buggy.
f.setVisible(true);
f.setSize(450, 475);
}
and the error:
java.lang.NullPointerException
at sun.awt.motif.MFramePeer.<init>(MFramePeer.java:59)
at sun.awt.motif.MToolkit.createFrame(MToolkit.java:153)
at java.awt.Frame.addNotify(Frame.java)
at java.awt.Window.show(Window.java)
at java.awt.Component.show(Component.java)
at java.awt.Component.setVisible(Component.java)
at AllComponents.main(AllComponents.java:165)
So, why is it doing this? I think I am using the right method.
-Galen
ps. Is there a good source of application code for 1.1 anywhere online?
Thanks,
-Galen
import java.awt.*;
class AllComponents extends Frame{
AllComponents(String x){
System.out.println(x);
}//
public static void main(String[] args) {
Frame f = new AllComponents("AWT Demo");
// We should call f.pack() here. But its buggy.
f.setVisible(true);
f.setSize(450, 475);
}
}
Enjoy the Java,
Dick Baldwin
======================================================================
Richard G. Baldwin, Assoc. Prof. of Computer Science
Austin Community College, Austin, TX
Richard...@worldnet.att.net
http://www.austin.cc.tx.us/baldwin/
>ps. Is there a good source of application code for 1.1 anywhere online?
============
Unless AllComponents is a subclass of Frame, I would be suspicious of the
statement
Frame f = new AllComponents("AWT Demo");
In any event you can find dozens of example programs, many of which use Frame
objects on Dick Baldwin's Instructional Java Page at:
<http://www.geocities.com/Athens/7077/Java000.htm>