- 讲师:刘萍萍 / 谢楠
- 课时:160h
- 价格 4580 元
特色双名师解密新课程高频考点,送国家电网教材讲义,助力一次通关
配套通关班送国网在线题库一套
百度广告
一是指性能上的稳定,其中的关键是源于SWT的设计理念。SWT最大化了操作系统的图形构件API,就是说只要操作系统提供了相应图形的构件,那么SWT只是简单应用JNI技术调用它们,只有那些操作系统中不提供的构件,SWT才自己去做一个模拟的实现。可以看出SWT的性能上的稳定大多时候取决于相应操作系统图形构件的稳定性。
另一个稳定是指SWT API包中的类、方法的名称和结构已经少有改变,程序员不用担心由于Eclipse组织开发进度很快(Eclipse IDE每天都会有一个Nightly版本的发布),而导致自己的程序代码变化过大。从一个版本的SWT更新至另一版本,通常只需要简单将SWT包换掉就可以了。
二、Eclipse3.0的swt编程
windows系统+eclipse3.0 具体操作:
+swt
+src(原文件)
+swt-awt-win32-3062.dll(以下均从eclipse"plugins"org.eclipse.swt.win32_3.0.1"os"win32"x86下导入)
+javaw.exe.manifest
(3).AddressBookUI.java原代码
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.events.SelectionEvent;
private Shell shell;
private Text addrText;
private Text phoneText;
private Text fnameText;
private Button saveButton;
private Button prevButton;
private Button deleteButton;
public static void main(String args) {
window.open();
public void open() {
shell = new Shell();
shell.setText("Address Book");
newButton = new Button(shell, SWT.NONE);
public void widgetSelected(SelectionEvent e) {
setTextEditable(true);
enableSaveButtons(true);
System.out.println("New button selected.");
});
newButton.setText("New");
{
deleteButton.addSelectionListener(new SelectionAdapter() {
clearText();
System.out.println("Delete button selected.");
});
deleteButton.setText("Delete");
{
editButton.addSelectionListener(new SelectionAdapter() {
setTextEditable(true);
enableSaveButtons(true);
System.out.println("Edit button selected.");
});
editButton.setText("Edit");
{
prevButton.addSelectionListener(new SelectionAdapter() {
System.out.println("Previous button selected.");
});
prevButton.setText("Previous");
{
nextButton.addSelectionListener(new SelectionAdapter() {
System.out.println("Next button selected.");
});
nextButton.setText("Next");
{
saveButton.addSelectionListener(new SelectionAdapter() {
setTextEditable(false);
enableSaveButtons(false);
System.out.println("Save button selected.");
});
saveButton.setText("Save");
}
cancelButton = new Button(shell, SWT.NONE);
public void widgetSelected(SelectionEvent e) {
enableEditButtons(true);
System.out.println("Cancel button selected.");
});
cancelButton.setText("Cancel");
}
final Group group = new Group(shell, SWT.NONE);
group.setBounds(10, 10, 585, 355);
final Label label = new Label(group, SWT.NONE);
label.setText("First Name:");
{
label.setBounds(10, 60, 135, 25);
}
final Label label = new Label(group, SWT.NONE);
label.setText("Phone:");
{
label.setBounds(10, 140, 135, 25);
}
final Label label = new Label(group, SWT.NONE);
label.setText("Address:");
{
label.setBounds(10, 255, 135, 25);
}
fnameText = new Text(group, SWT.BORDER | SWT.READ_ONLY);
}
lnameText = new Text(group, SWT.BORDER | SWT.READ_ONLY);
}
phoneText = new Text(group, SWT.BORDER | SWT.READ_ONLY);
}
emailText = new Text(group, SWT.BORDER | SWT.READ_ONLY);
}
addrText = new Text(group, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL);
}
miscText = new Text(group, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL);
}
setupMenu();
shell.open();
if (!display.readAndDispatch())
}
private void setupMenu() {
Menu menu = new Menu(shell, SWT.BAR);
//add the File option to it
file.setText("File");
file.setMenu(new Menu(file));
MenuItem prevItem = new MenuItem(new Menu(file), SWT.NONE);
MenuItem nextItem = new MenuItem(new Menu(file), SWT.PUSH);
MenuItem seperator = new MenuItem(new Menu(file), SWT.SEPARATOR);
quitItem.setText("Quit");
prevItem.addListener(SWT.Selection, new Listener() {
System.out.println("Previous menu item selected.");
});
public void handleEvent(Event e) {
}
quitItem.addListener(SWT.Selection, new Listener() {
shell.dispose();
});
private void clearText() {
lnameText.setText("");
emailText.setText("");
miscText.setText("");
private void setTextEditable(boolean editable) {
lnameText.setEditable(editable);
emailText.setEditable(editable);
miscText.setEditable(editable);
private void enableEditButtons(boolean enable) {
deleteButton.setEnabled(enable);
}
private void enableSaveButtons(boolean enable) {
cancelButton.setEnabled(enable);
}
(4).测试运行,run就可以,你可以到http://www.java2s.com寻找关于swt的好程序.
责编:罗莉
课程专业名称 |
讲师 |
课时 |
查看课程 |
---|
课程专业名称 |
讲师 |
课时 |
查看课程 |
---|
点击加载更多评论>>