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