Hi Luigi, What is the reason behind creating a separate thread?
You cannot manipulate ULC components from other threads than the main application thread because ULC adheres to the strict request-response model defined by J2EE. All code must be executed as part of processing a client request. However, if you have a long task and from which you would like to access ULC components, you can do is create a ULCPollingTimer and register an IActionListener with it. The ULCPollingTimer's client half-object (UIPollingTimer) creates a Swing timer on the client side and generates client action events which will notify the ULCPollingTimer's IActionListener on the server side. Upon each notification, you can read the common data structure from within the IActionListener's actionPerformed method and update your label accordingly. This will always happen in the main application thread. I hope this helps. Thanks and regards, Janak >-----Original Message----- >From: [EMAIL PROTECTED] >[mailto:[EMAIL PROTECTED] Behalf Of Luigi >Santangelo >Sent: Tuesday, October 10, 2006 10:44 PM >To: [email protected] >Subject: [ULC-developer] Thread and super do not work fine > > >Hi all, >For a long time I'm working to resolve the following problem but I >can't. Have you had same problem? Thanks you for your help. Now, the >problem. I write this (become simpler) code: > >=================== >[start code] > >class myText extends ULCTextField >{ > myText() > { > super(); > } > > public void setText(String t) > { > super.setText(t); > } > > public void setBackground(Color c) > { > (3) super.setBackground(c); > } >} > >public class FrameWithThread extends ULCFrame { > > myText txtText = new myText(); > ULCFlowLayoutPane principalPanel = new ULCFlowLayoutPane(); > ULCButton btnOpen = new ULCButton("Open"); > > FrameWithThrade() > { > principalPanel.add(btnOpen); > principalPanel.add(txtText); > this.getContentPane().add(principalPanel); > StartTest(); > } > > public void StartTest() > { > // this works fine > (1) txtText.setBackground(Color.pink); > > myThread t = new myThread() > { > public void construct() > { > // this DOESN'T WORK FINE > (2) txtText.setBackground(Color.cyan); > System.out.print("Started"); > } > }; > t.start(); > } >} > >public abstract class myThread { > > Thread t; > > public myThread() > { > Runnable doConstract = new Runnable() > { > public void run() > { > construct(); > } > }; > > t = new Thread(doConstract); > } > > public void start() > { > t.start(); > } > > public abstract void construct(); > >} > >[end code] >============================== > >When I run the project, the instruction labeled (2) generates this >error: >Exception in thread "Thread-2" java.lang.NullPointerException > at com.ulcjava.base.application.ULCProxy.a(ULCProxy.java:13) > at com.ulcjava.base.application.ULCProxy.a(ULCProxy.java:245) > at com.ulcjava.base.application.ULCProxy.a(ULCProxy.java:430) > at com.ulcjava.base.application.ULCProxy.a(ULCProxy.java:121) > at com.ulcjava.base.application.ULCProxy.setStateUI(ULCProxy.java: >256) > at com.ulcjava.base.application.ULCComponent.setBackground >(ULCComponent.java:162) > at myText.setBackground(FrameWithThrade.java:54) > at FrameWithThrade$1.construct(FrameWithThrade.java:32) > at myThread$1.run(myThread.java:12) > at java.lang.Thread.run(Thread.java:595) > >The same instruction (labeled with (1)) works fine. If I remove the >istruction 1 or istraction 3, it works fine. According to me, the >problem is during the creation of ULCTextField (because the super. >setBackground(...) instruction generates the NullPointerException. >Can you help me? Thanks and regards. >Luigi > > >Naviga e telefona senza limiti con Tiscali >Scopri le promozioni Tiscali adsl: navighi e telefoni senza canone Telecom > >http://abbonati.tiscali.it/adsl/ > >_______________________________________________ >ULC-developer mailing list >[email protected] >http://lists.canoo.com/mailman/listinfo/ulc-developer > _______________________________________________ ULC-developer mailing list [email protected] http://lists.canoo.com/mailman/listinfo/ulc-developer
