Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Netbeans newbe help needed

0 views
Skip to first unread message

Avraham

unread,
May 30, 2004, 9:11:19 AM5/30/04
to
Hello,

This is my newbe simplest program.
It compiles OK.
When I try to run it with NETBEENS I get error messages (see bellow),

When I run it in another IDE (JCreator) it runs. (only it won't close
the window. Wish I knew why..).

Please help on both issues.

Thanks, Avraham gutbir1 @ 013.net.il
------------------------------------

import java.awt.*;
import java.awt.event.*;

public class ButtonDemo extends Frame{

Button b;
public ButtonDemo(){ // constructor
super ();
this.setLayout(new FlowLayout(FlowLayout.LEFT));
this.setBackground(Color.green);
b=new Button("Press me and I will blush");
b.setSize(100,100); // did not work !

// for button action :
b.addActionListener(new MyButtonHandler());
this.add(b);
this.setSize(300,300);

// for window closing :
this.addWindowListener(new MyWindowListener());
//this.setResizable(false);
}

// inner class for button listener :
class MyButtonHandler implements ActionListener{
public void actionPerformed(ActionEvent e){
Button bb=(Button)e.getSource();
bb.setLabel("Thanks");
bb.setBackground(Color.yellow);
ButtonDemo.this.setBackground(Color.red); // relates to frame
}
}

// inner class for window listener :
class MyWindowListener extends WindowAdapter{

public void WindowClosing(WindowEvent e){
System.exit(0); // exit from application
System.out.println("heh");
}

}

public static void main(String[] args) {
ButtonDemo wind=new ButtonDemo();
wind.setVisible(true);
}
}

//----------------------------- end if program -----------------------


java.lang.NoClassDefFoundError: ButtonDemo/ButtonDemo (wrong name:
ButtonDemo)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
Exception in thread "main"

Andrew Thompson

unread,
May 30, 2004, 9:21:25 AM5/30/04
to
On 30 May 2004 06:11:19 -0700, Avraham wrote:

> This is my newbe simplest program.

Head on over to c.l.j.help and I will
offer you step by step general guidance
<http://www.physci.org/codes/javafaq.jsp#cljh>

[ But be prepared to lose the IDE(s).
You need to figure how to do it from
the command line, then _they_ will be
easy to configure. ]

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

0 new messages