最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

SWT(JFace)體驗之打開多個Form

 更新時間:2009年06月25日 11:01:01   作者:  
SWT(JFace)體驗之打開多個Form的實現(xiàn)代碼。
代碼很簡單,如下所示:
復(fù)制代碼 代碼如下:

package swt_jface.demo1;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class Main {

public static void main(String[] args) {

Display display = new Display();

Image small = new Image(display, 16, 16);
GC gc = new GC(small);
gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
gc.fillArc(0, 0, 16, 16, 45, 270);
gc.dispose();

Image large = new Image(display, 32, 32);
gc = new GC(large);
gc.setBackground(display.getSystemColor(SWT.COLOR_BLUE));
gc.fillArc(0, 0, 32, 32, 45, 270);
gc.dispose();

Shell shell = new Shell(display);
shell.setText("Small and Large icons");
shell.setImages(new Image[] {small, large});
Shell shell2 = new Shell(display);
shell2.setText("Small icon");
shell2.setImage(small);

shell.open();
shell2.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}

下面是打開子畫面的代碼:
復(fù)制代碼 代碼如下:

package swt_jface.demo1;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class DialogShell {
public DialogShell() {

Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new RowLayout());
shell.setSize(500, 200);
final Button openDialog = new Button(shell, SWT.PUSH);
openDialog.setText("Click here to rate this book ...");
openDialog.addSelectionListener(new SelectionListener() {

public void widgetSelected(SelectionEvent e) {
final Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
dialog.setLayout(new RowLayout());
final String[] ratings =
new String[] {"Killer!", "Good stuff", "So-so", "Needs work" };
final Button[] radios = new Button[ratings.length];
for (int i = 0; i < ratings.length; i++) {
radios[i] = new Button(dialog, SWT.RADIO);
radios[i].setText(ratings[i]);
}
Button rateButton = new Button(dialog, SWT.PUSH);
rateButton.setText("Rate!");
rateButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
for (int i = 0; i < radios.length; i++)
if (radios[i].getSelection()) openDialog.setText("Rating: " + ratings[i]);
dialog.close();
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
dialog.pack();
dialog.open();

Rectangle shellBounds = shell.getBounds();
Point dialogSize = dialog.getSize();
dialog.setLocation(shellBounds.x + (shellBounds.width - dialogSize.x) / 2, shellBounds.y + (shellBounds.height - dialogSize.y) / 2);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
public static void main(String[] args) {
new DialogShell();
}
}

相關(guān)文章

  • Java mongodb連接配置實踐

    Java mongodb連接配置實踐

    這篇文章主要介紹了Java mongodb連接配置實踐,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-12-12
  • 詳解Jmeter中的BeanShell腳本

    詳解Jmeter中的BeanShell腳本

    BeanShell是一種完全符合Java語法規(guī)范的腳本語言,并且又擁有自己的一些語法和方法,所以它和java是可以無縫銜接的,學(xué)了Java的一些基本語法后,就可以來在Jmeter中寫寫B(tài)eanShell腳本了
    2021-12-12
  • 關(guān)于Spring啟動時Context加載源碼分析

    關(guān)于Spring啟動時Context加載源碼分析

    這篇文章通過源碼分析主要給大家介紹了關(guān)于Spring啟動時Context加載的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-01-01
  • Java打包之后讀取Resources下的文件失效原因及解決方法

    Java打包之后讀取Resources下的文件失效原因及解決方法

    這篇文章主要給大家介紹了Java打包之后讀取Resources下的文件失效的問題分析和解決方法,文中通過代碼示例和圖文結(jié)合給大家講解非常詳細,需要的朋友可以參考下
    2023-12-12
  • Java獲取客戶端真實IP地址過程解析

    Java獲取客戶端真實IP地址過程解析

    這篇文章主要介紹了Java獲取客戶端真實IP地址過程解析,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-01-01
  • 當mybatis返回值遇見內(nèi)部類的問題

    當mybatis返回值遇見內(nèi)部類的問題

    這篇文章主要介紹了當mybatis返回值遇見內(nèi)部類的問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-12-12
  • 如何將字符串、字節(jié)數(shù)組轉(zhuǎn)為輸入流

    如何將字符串、字節(jié)數(shù)組轉(zhuǎn)為輸入流

    這篇文章主要介紹了如何將字符串、字節(jié)數(shù)組轉(zhuǎn)為輸入流問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-05-05
  • 深入理解Java中1是true0是false

    深入理解Java中1是true0是false

    Java中,1可以被看作是true,0可以被看作是false,本文就來進行詳細的講解,具有一定的參考價值,感興趣的可以了解一下
    2024-02-02
  • IntelliJ IDEA創(chuàng)建maven多模塊項目(圖文教程)

    IntelliJ IDEA創(chuàng)建maven多模塊項目(圖文教程)

    這篇文章主要介紹了IntelliJ IDEA創(chuàng)建maven多模塊項目(圖文教程),非常具有實用價值,需要的朋友可以參考下
    2017-09-09
  • Java實現(xiàn)對象轉(zhuǎn)CSV格式

    Java實現(xiàn)對象轉(zhuǎn)CSV格式

    CSV是一種逗號分隔值格式的文件,一般用來存儲數(shù)據(jù)的純文本格式文件。Java對象轉(zhuǎn)CSV,有現(xiàn)成的工具包,commons-lang3 的ReflectionToStringBuilder 就可以簡單的解決的對象轉(zhuǎn)CSV,快跟隨小編一起學(xué)習(xí)一下吧
    2022-06-06

最新評論

双柏县| 铜陵市| 孙吴县| 赤城县| 德令哈市| 云梦县| 哈尔滨市| 海宁市| 将乐县| 富蕴县| 都江堰市| 五大连池市| 伊春市| 斗六市| 定兴县| 安吉县| 泰宁县| 双柏县| 滦平县| 沙田区| 尼木县| 得荣县| 台江县| 嵩明县| 贺州市| 元阳县| 南雄市| 南城县| 隆尧县| 金塔县| 万载县| 德江县| 休宁县| 岐山县| 汕头市| 宣化县| 从江县| 肃宁县| 井冈山市| 定日县| 信阳市|