Redian新闻
>
java update main UI from child thread issue
avatar
java update main UI from child thread issue# Java - 爪哇娇娃
w*r
1
真想掐死一个阿三,据调查薪水比我高,屁都不懂,lead developer, 最近一个
project due, 丫什么都做不出来,一出错就打电话来complain说有这样那样的问题,
也是我不好给他解释debug 过了一次,这下好过去的两周每天收到其SR的电话和email,
从中发现此人什么都不懂,想不通怎么会被雇佣的,而且还混了N年到现在的地位,
TNND我要是it的manager当场就要fire it..
avatar
c*9
2
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");
}
}
});

}
});
avatar
B*g
3
he can blow

email,

【在 w*r 的大作中提到】
: 真想掐死一个阿三,据调查薪水比我高,屁都不懂,lead developer, 最近一个
: project due, 丫什么都做不出来,一出错就打电话来complain说有这样那样的问题,
: 也是我不好给他解释debug 过了一次,这下好过去的两周每天收到其SR的电话和email,
: 从中发现此人什么都不懂,想不通怎么会被雇佣的,而且还混了N年到现在的地位,
: TNND我要是it的manager当场就要fire it..

avatar
Y*G
4
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);

avatar
w*r
5
vivian chow!!!

【在 B*****g 的大作中提到】
: he can blow
:
: email,

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。