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

首頁 > 編程 > Java > 正文

SWT(JFace)體驗之Icon任我變

2019-11-26 16:19:24
字體:
來源:轉載
供稿:網友
代碼如下
復制代碼 代碼如下:

package swt_jface.demo;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class IconSelector {
Display display = new Display();
Shell shell = new Shell(display);
Label labelIconFile;
Text textIconFile;

Button buttonIconBrowse;
Button buttonSetIcon;

Image shellIcon;

Image buttonIcon;

public IconSelector() {

initializeUI();

shell.pack();
shell.open();

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

private void initializeUI() {
GridLayout gridLayout = new GridLayout(3, false);
shell.setLayout(gridLayout);
labelIconFile = new Label(shell, SWT.NULL);

textIconFile = new Text(shell, SWT.SINGLE | SWT.BORDER);

GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.grabExcessHorizontalSpace = true;
textIconFile.setLayoutData(gridData);
buttonIconBrowse = new Button(shell, SWT.PUSH);
gridData = new GridData();
gridData.horizontalSpan = 3;
gridData.horizontalAlignment = GridData.CENTER;
buttonSetIcon = new Button(shell, SWT.PUSH);
buttonSetIcon.setLayoutData(gridData);
shell.setText("Icon Selector");
labelIconFile.setText("Select an icon:");
buttonIconBrowse.setText("Browse");
buttonSetIcon.setText("Set Icon");
buttonIconBrowse.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
String file = dialog.open();
if (file != null) {
textIconFile.setText(file);
}
}
});
buttonSetIcon.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if(shellIcon != null)
shellIcon.dispose();

try {
shellIcon = new Image(display, textIconFile.getText());
shell.setImage(shellIcon);
}catch(Exception ex) {
ex.printStackTrace();
}
}
});
}

public static void main(String[] args) {
new IconSelector();
}
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 激情小说色 | 日韩黄色一级视频 | 久久久久久久久日本理论电影 | 内地av在线 | 极品销魂一区二区三区 | 日本视频免费 | 蜜桃成品人免费视频 | 午夜色片 | 久久久中精品2020中文 | av免费在线播放网址 | 美女黄视频在线观看 | 黄色网页在线观看 | 天天夜天天操 | 日韩毛片在线看 | 国产美女视频一区 | 全免费午夜一级毛片真人 | 久久99久久98精品免观看软件 | 综合国产一区 | 欧美大屁股精品毛片视频 | 国产精品视频一区二区三区综合 | 亚洲一区二区中文字幕在线观看 | 久久免费视频一区 | 毛片在哪里看 | 91精品国产综合久久青草 | 久久99精品久久久久久久久久久久 | 毛片免费大全短视频 | 久久午夜国产 | 精品一区二区三区在线播放 | 色交视频 | 色综合久久久久久久粉嫩 | 久久爽久久爽久久av东京爽 | 欧美不卡视频在线观看 | 国产91免费看 | 国产日韩一区二区三区在线观看 | 成人福利软件 | 91在线视频精品 | 91短视频网址 | av在线一区二区三区四区 | 欧美爱爱视频免费看 | 狠狠色噜噜狠狠狠米奇9999 | 日韩视频不卡 |