SWT Tips and Samples 基礎編 > FontDialog |
|
FontDialogFontDialogはフォントを選択するためのダイアログです。他のダイアログと同様にopenメソッド実行後ダイアログが表示され、戻り値としてFontDataを得られます。またキャンセルボタンが押されるとnullが返ります。 スクリーンショットソースコード (FontDialogTest.java)import org.eclipse.swt.widgets.*; import org.eclipse.swt.SWT; import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.layout.*; public class FontDialogTest { private Shell shell; private Label label; public static void main(String[] args) { new FontDialogTest(); } public FontDialogTest() { Display display = new Display(); shell = new Shell(display); shell.setText("FontDialogTest"); GridLayout gl = new GridLayout(1, false); shell.setLayout(gl); label = new Label(shell, SWT.BORDER); label.setText("Test String"); GridData gd = new GridData(); gd.widthHint = 200; gd.heightHint = 100; label.setLayoutData(gd); Button b = new Button(shell, SWT.PUSH); b.setText("Open Font Dialog"); b.addSelectionListener(new SelectionAdapter(){ public void widgetSelected(SelectionEvent e) { FontDialog dialog = new FontDialog(shell); FontData fd = dialog.open(); if (fd == null){ return; } Font font = new Font(shell.getDisplay(), fd); label.setFont(font); } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } } 最新更新日: 2004年8月31日 |
- PR -
【Sony】大手他社よりも安い!ビジネス向け光・100Mしかも固定IP付!今なら更に初期費用最大15,000円OFF!
オフィス用品・オフィス家具 価 格 交 渉 可!
|
||||
|
|||||
Copyright(C) 2003,2004 Jasmin Project. All Right Reserved. |
SEO | [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送 | ||