麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > Java > 正文

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

2020-01-31 16:51:47
字體:
來源:轉載
供稿:網友
代碼很簡單,如下所示:
復制代碼 代碼如下:

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();
}
}

下面是打開子畫面的代碼:
復制代碼 代碼如下:

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();
}
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 日韩黄色片免费看 | 污版视频在线观看 | 蜜桃麻豆视频 | 亚洲码无人客一区二区三区 | 久久99精品久久久久久园产越南 | 国产99久久久久久免费看 | 91成人在线免费视频 | 久久久视频免费观看 | 国产精品刺激对白麻豆99 | 久久久日韩av免费观看下载 | 视频一区二区三区在线播放 | 毛片毛片免费看 | 久久成年人视频 | 91国内精品久久久久免费影院 | 超碰一区| 97风流梦电影 | 91一区二区在线观看 | av电影直播 | 免费h片 | 国产羞羞视频在线观看免费应用 | 亚洲一区二区中文字幕在线观看 | 日本中文高清 | 久久久久亚洲a | 日韩av在线影院 | 水多视频在线观看 | 成年性羞羞视频免费观看 | 91短视频免费 | 亚洲国产精品一区二区久久 | 欧美精品久久久久久久久久 | 久国久产久精永久网页 | 在线免费亚洲 | 精品国产91久久久久久 | 国产一级桃视频播放 | 久久亚洲线观看视频 | 男女隐私免费视频 | 一二区成人影院电影网 | 污黄视频在线播放 | 美女黄污视频 | 色网站综合| 99精品视频在线观看免费 | 国产91亚洲精品一区二区三区 |