MouseEvent in JavaBeans
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   daniel_wong
Posted On:   Friday, August 30, 2002 09:10 AM

Hi, I need to put different components in a class rather than using Beanbox or some other tools. I can compile the program and make it in a jar, but there is an exception when I try to load the bean into the bean box. The exception as follow: WARNING: Could not instantiate bean "TestMouseEvent" from JAR "C:BDK1.1 eanbox TestMouseEvent.jar" We located the class "TestMouseEvent" OK The class provides a public zero-arg constructor But were unable to create an instance of the class because we got an exception while doing Class.newInstance() : java.lang.NoClassDefFoundError: TestMouseEvent$1 The stack ba   More>>

Hi,



I need to put different components in a class rather than using Beanbox or some other tools.



I can compile the program and make it in a jar, but there is an exception when I try to load the bean into the bean box. The exception as follow:



WARNING: Could not instantiate bean "TestMouseEvent" from JAR "C:BDK1.1 eanbox
TestMouseEvent.jar"

We located the class "TestMouseEvent" OK
The class provides a public zero-arg constructor
But were unable to create an instance of the class because we
got an exception while doing Class.newInstance() :

java.lang.NoClassDefFoundError: TestMouseEvent$1

The stack backtrace at the time of this exception is
java.lang.NoClassDefFoundError: TestMouseEvent$1

at TestMouseEvent. (TestMouseEvent.java:19)

at java.lang.Class.newInstance0(Native Method)

at java.lang.Class.newInstance(Unknown Source)

at sun.beanbox.JarInfo.diagnoseInstantiationException(JarInfo.java:308)

at sun.beanbox.JarInfo.getInstance(JarInfo.java:155)

at sun.beanbox.ToolBoxPanel.mousePressed(ToolBox.java:343)

at java.awt.Component.processMouseEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)




I think the logic is the same if I use event to link the components together, I use the most simple code to test the mouseEvent, The code as follow:


import java.applet.*;
import java.awt.*;
import java.beans.*;
import java.awt.event.*;
import javax.swing.*;


public class TestMouseEvent extends Panel implements java.io.Serializable

{

private JButton testb;


public TestMouseEvent()

{

setSize(800, 1000);

testb = new JButton("Test");

testb.addMouseListener(new MouseAdapter(){

public void mousePressed(MouseEvent me){


System.out.println("mousePressed");

}

public void mouseReleased(MouseEvent me){

System.out.println("mouseReleased");

}

});


add(testb);



}


}


I just use a Panel and add a new JButton for the mouse listener, but still have the exception, I hope you know about JavaBeans and give me some idea of the problem. I can load the jar file if I comment out the event


Best Regards,


Daniel

   <<Less
About | Sitemap | Contact