Skip to main content

Paint event in actionperformed

2 replies [Last post]
Joined: 2009-10-11
Points: 0

Hello all,

I want something very simple, every time I click a command i.e. the actionPerformed method is executed, the header should change it's text to "Loading" and after that execute some hard logic in worker thread. The problem is that when actionPerformed is entered, the EDT thread gets busy and can't process my Form.setTitle() invocation. And the title is not changing.

I have a similar problem with the menu which I want to hide immediately after a command is clicked. But it doesn't.

Any ideas how can I get around it ?

Best regards

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2010-03-26
Points: 0

Hi,I'm new to this platform,I need help to do the simple thing like when we click on the next button it need to display the next screen.

Thank you.

Joined: 2009-10-11
Points: 0

I figured this out, please delete the thread.

I was looking at this example

public void actionPerformed(ActionEvent ev) {
label.setText("Initiating IO, please wait...");
Display.getInstance().invokeAndBlock(new Runnable() {
public void run() {
// perform IO operation...
label.setText("IO completed!");
// update UI...


it seems that if we want the label (or in my case the header label) to be changed, we need to call immediately after the setText method. Otherwise it'll not be changed. The menu will not hide neither.

But another interesting question is why show() is doing this job and repaint(), for example, don't?
It seems that the actual label repaint is happening after the actionPerformed method. Unless we call show before the end.
Also if we don't call show() before invokeAndBlock and after setText(), the menu will not hide and the user will think that the UI is frozen, but it's not.


Message was edited by: digitalsol