
大家好我是尋覓;
介紹個(gè)東西--SWT 給大家,不知道大家玩過沒?
SWT性能遠(yuǎn)遠(yuǎn)勝過AWT和SWING,在Eclipse下的Designer比JB強(qiáng)得多,綜合起來比C#還強(qiáng)。
Designer for Eclipse3.2.2
http://downloads.instantiations.com/Designer/continuous/latest/Designer_v6.3.1_for_Eclipse3.2.zip如果該地址無法下載,請(qǐng)到
官方網(wǎng)站下載
環(huán)境配置參照:
http://m.tkk7.com/lusm/archive/2007/06/22/125866.html包下載
ttp://download.eclipse.org/eclipse/downloads/drops/R-3.2.2-200702121330/download.php?dropFile=swt-3.2.2-win32-win32-x86.zip例子在線
http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/CatalogSWT-JFace-Eclipse.htm例子下載
http://download.eclipse.org/eclipse/downloads/drops/R-3.2.2-200702121330/download.php?dropFile=eclipse-examples-3.2.2-win32.zip給大家兩個(gè)例子
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import com.swtdesigner.SWTResourceManager;



public class Myapp1
{

private static Text text;

/** *//**
* Launch the application
* @param args
*/

public static void main(String[] args)
{
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setImage(SWTResourceManager.getImage(Myapp1.class, "/jmapps/images/iconQuery.gif"));
shell.setRegion(null);
shell.setSize(375, 239);
shell.setText("新玩兒");
//

shell.open();

final Button button = new Button(shell, SWT.NONE);
shell.setDefaultButton(button);
button.setImage(SWTResourceManager.getImage(Myapp1.class, "/jmapps/images/audio.gif"));

button.addSelectionListener(new SelectionAdapter()
{

public void widgetSelected(SelectionEvent e)
{
text.setText("當(dāng)然是沒問題咯。");
}
});
button.setText("確定");
button.setBounds(61, 144, 92, 36);

text = new Text(shell, SWT.BORDER);
text.setText("Java寫GUI不行?");
text.setFont(SWTResourceManager.getFont("", 20, SWT.NONE));
text.setBackground(SWTResourceManager.getColor(0, 128, 192));
text.setBounds(49, 50, 269, 36);

final Button button_1 = new Button(shell, SWT.NONE);

button_1.addSelectionListener(new SelectionAdapter()
{

public void widgetSelected(SelectionEvent e)
{
text.setText("Java寫GUI不行?");
}
});
button_1.setImage(SWTResourceManager.getImage(Myapp1.class, "/jmapps/images/audio-disabled.gif"));
button_1.setText(" 重來");
button_1.setBounds(214, 144, 92, 36);
shell.layout();

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

}

上面那個(gè)我寫著玩的試試而已
地震讓大伙知道:居安思危,才是生存之道。
posted on 2007-06-25 15:16
小尋 閱讀(1530)
評(píng)論(0) 編輯 收藏 所屬分類:
j2se/j2ee/j2me