2009-04-13
SwingのJFileChooserの代わりにSWTのFileDialogを使う方法
○JFileChooserの起動遅延バグ
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6372808
JFileChooserの初期起動が遅いのでそこだけSWTのFileDialogを使うことにした。
public class SWTSwing { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(300, 300); Container cp = frame.getContentPane(); Canvas canvas = new Canvas(); cp.add(canvas, BorderLayout.CENTER); frame.setVisible(true); Display display = new Display(); final Shell shell = SWT_AWT.new_Shell(display, canvas); shell.setLayout(new FillLayout()); Button button = new Button(shell, SWT.PUSH); button.setText("参照"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // 読み込み用ダイアログを開く //FileDialog openDialog = new FileDialog(shell, SWT.OPEN); //String path = openDialog.open(); DirectoryDialog dialog = new DirectoryDialog(shell); String path = dialog.open(); MessageBox mesBox = new MessageBox(shell); mesBox.setMessage(path); mesBox.open(); } }); shell.pack(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } }
トラックバック - http://d.hatena.ne.jp/kensir0u/20090413/1239628579
リンク元
- 3 http://www.google.co.jp/search?client=firefox-a&rls=org.mozilla:ja:official&channel=s&hl=ja&q=Swing+SWT&lr=&btnG=Google+検索
- 3 http://www.google.co.jp/search?hl=ja&q=クラスローダ cast&lr=lang_ja
- 3 http://www.google.co.jp/search?sourceid=navclient&hl=ja&ie=UTF-8&rlz=1T4GGIH_jaJP282JP282&q=java.lang.Override
- 2 http://ezsch.ezweb.ne.jp/search/?sr=0101&query=メモリー しくみ
- 2 http://www.google.co.jp/search?hl=ja&lr=lang_ja&client=firefox-a&rls=org.mozilla:ja:official&hs=QVw&q=Introspector&revid=1741686737&ei=0yPkSaPXB8KTkAWE8MnQCw&sa=X&oi=revisions_inline&resnum=0&ct=broad-revision&cd=1
- 2 http://www.google.co.jp/search?hl=ja&q=Excel+ZIP&lr=&aq=f&oq=
- 2 http://www.google.co.jp/search?hl=ja&q=Servlet3.0&lr=&aq=f&oq=
- 2 http://www.google.co.jp/search?q=kensir0u&lr=lang_ja&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:ja:official&client=firefox-a
- 1 http://72.14.235.132/search?q=cache:3GJLHz8cOOwJ:k.hatena.ne.jp/keywordblog/Java?date=20090205+new領域は何割なのか java&cd=3&hl=ja&ct=clnk&gl=jp
- 1 http://blogsearch.google.co.jp/blogsearch?q=java excel&lr=lang_ja&oe=utf-8&rls=org.mozilla:ja:official&client=firefox-a&um=1&ie=UTF-8&sa=N&hl=en&tab=wb