由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - java update main UI from child thread issue
相关主题
A rookie question on Java GUIFrameWork of Thread application 1
Java Swing的UI开发很落后啊Re: connection pool
请教各位高手一个applet的问题can applet implements runnable?
JFileChooser的小问题ZT: 关于性爱的多线程问题研究(一)
怎么练习java multithread问个Thread 的问题,java certificate里的
实在搞不定了,问问大虾,java里面得itemListener●●●●紧急求助JAVA初级问题,今天project due●●●●
有一系列的buttonCan Java thread return a value?
Re: How to showStatus in Applet?能这么 create thread 吗?
相关话题的讨论汇总
话题: text话题: button话题: shell话题: new
进入Java版参与讨论
1 (共1页)
c*******9
发帖数: 6411
1
I tried the following code, and looks like text.setText("test") caused
the "org.eclipse.swt.SWTException: Invalid thread access" error.
the UI here has text field, and a browser button, the browser button will
display JFileChooser to choose a file.
any idea how to get this work?
thanks.
testing code:
private void createContents(final Shell shell)
shell.setLayout(new GridLayout(3, false));
final Label lable = new Label(shell, SWT.READ_ONLY);
lable.setText("File Path");
final Text text = new Text(shell, SWT.SINGLE | SWT.BORDER);
text .setBounds(100, 75, 100, 20);
text .setTextLimit(150);
Button button = new Button(shell, SWT.PUSH);
button.setText("Browse...");
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {

Display.getDefault().asyncExec(new Runnable() {

public void run()
{
JFileChooser jfc = new JFileChooser();
jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);

jfc.setMultiSelectionEnabled(false);
int status = jfc.showOpenDialog(null);
if(status == JFileChooser.APPROVE_OPTION)
{
File browseFile = jfc.getSelectedFile();
text.setText("test");
}
}
});

}
});
Y**G
发帖数: 1089
2
google Advanced Swing Multithreading Tutorial, it will answer your question

【在 c*******9 的大作中提到】
: I tried the following code, and looks like text.setText("test") caused
: the "org.eclipse.swt.SWTException: Invalid thread access" error.
: the UI here has text field, and a browser button, the browser button will
: display JFileChooser to choose a file.
: any idea how to get this work?
: thanks.
: testing code:
: private void createContents(final Shell shell)
: shell.setLayout(new GridLayout(3, false));
: final Label lable = new Label(shell, SWT.READ_ONLY);

1 (共1页)
进入Java版参与讨论
相关主题
能这么 create thread 吗?怎么练习java multithread
implements runable 和 extends thread实在搞不定了,问问大虾,java里面得itemListener
几个问题有一系列的button
一个基本问题。Re: How to showStatus in Applet?
A rookie question on Java GUIFrameWork of Thread application 1
Java Swing的UI开发很落后啊Re: connection pool
请教各位高手一个applet的问题can applet implements runnable?
JFileChooser的小问题ZT: 关于性爱的多线程问题研究(一)
相关话题的讨论汇总
话题: text话题: button话题: shell话题: new