日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
SWT比價(jià)Swing和AWT

自IBM公司提供的跨平臺(tái)GUI開發(fā)包SWT以來,越來越多受到廣大程序員的親睞,已經(jīng)有不少程序員用它開發(fā)出美觀、高效、實(shí)用的桌面應(yīng)用程序。這讓我們更有理由去探索SWT給我們帶來的驚奇。

創(chuàng)新互聯(lián)是一家專業(yè)提供志丹企業(yè)網(wǎng)站建設(shè),專注與網(wǎng)站設(shè)計(jì)制作、成都網(wǎng)站設(shè)計(jì)、H5網(wǎng)站設(shè)計(jì)、小程序制作等業(yè)務(wù)。10年已為志丹眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站制作公司優(yōu)惠進(jìn)行中。

SWT在外觀和性能上都超過了Swing和AWT,為什么這樣說呢?下面簡(jiǎn)單的測(cè)試程序會(huì)讓你一目了然。廢話也不多說,讓我們看Swing和AWT程序。

下面讓我們寫一個(gè)簡(jiǎn)單的程序來測(cè)試一下,程序只做一件事,就是用Label顯示”HelloWorld!”,我的測(cè)試環(huán)境是JDK1.5.0+Eclipse3.1。看看在SWT、Swing和AWT下分別實(shí)現(xiàn)該效果所需要的時(shí)間和內(nèi)存消耗。

AWT_CODE:

 
 
 
  1. import java.awt.Frame;
  2. import java.awt.Label;
  3. import java.awt.event.WindowAdapter;
  4. import java.awt.event.WindowEvent;
  5. public class awtTest {
  6. public static void main(String[] args) {
  7. long memory = 0L;
  8. long time = 0L;
  9. memory = Runtime.getRuntime().freeMemory();
  10. time = System.currentTimeMillis();
  11. Frame frame = new Frame();
  12. Label label = new Label();
  13. label.setText("Hello World!");
  14. frame.add(label);
  15. frame.setVisible(true);
  16. frame.addWindowListener(new WindowAdapter() {
  17. public void windowClosing(WindowEvent we) {
  18. System.exit(0);
  19. }
  20. });
  21. frame.pack();
  22. System.out.println(System.currentTimeMillis() - time);
  23. System.out.println(memory - Runtime.getRuntime().freeMemory());
  24. }
  25. }

SWING_CODE:

 
 
 
  1. import javax.swing.JFrame;
  2. import javax.swing.JLabel;
  3. import java.awt.event.WindowAdapter;
  4. import java.awt.event.WindowEvent;
  5. public class swingTest {
  6. public static void main(String[] args) {
  7. long memory = 0L;
  8. long time = 0L;
  9. memory = Runtime.getRuntime().freeMemory();
  10. time = System.currentTimeMillis();
  11. JFrame frame = new JFrame();
  12. JLabel label = new JLabel();
  13. label.setText("Hello World!");
  14. frame.add(label);
  15. frame.setVisible(true);
  16. frame.addWindowListener(new WindowAdapter() {
  17. public void windowClosing(WindowEvent we) {
  18. System.exit(0);
  19. }
  20. });
  21. frame.pack();
  22. System.out.print("Time:");
  23. System.out.println(System.currentTimeMillis() - time);
  24. System.out.print("Memory:");
  25. System.out.println(memory - Runtime.getRuntime().freeMemory());
  26. }
  27. }

SWT_CODE:

 
 
 
  1. import org.eclipse.swt.widgets.Display;
  2. import org.eclipse.swt.widgets.Shell;
  3. import org.eclipse.swt.widgets.Label;
  4. import org.eclipse.swt.SWT;
  5. public class swtTest {
  6. public static void main(String[] args) {
  7. long memory = 0L;
  8. long time = 0L;
  9. memory = Runtime.getRuntime().freeMemory();
  10. time = System.currentTimeMillis();
  11. Display display = new Display();
  12. Shell shell = new Shell(display);
  13. Label label = new Label(shell, SWT.NONE);
  14. label.setText("Hello World!");
  15. shell.pack();
  16. label.pack();
  17. shell.open();
  18. System.out.print("Time:");
  19. System.out.println(System.currentTimeMillis() - time);
  20. System.out.print("Memory:");
  21. System.out.println(Runtime.getRuntime().freeMemory() - memory);
  22. while(!shell.isDisposed()) {
  23. if(!display.readAndDispatch()) {
  24. display.sleep();
  25. }
  26. }
  27. display.dispose();
  28. label.dispose();
  29. }
  30. }

網(wǎng)站標(biāo)題:SWT比價(jià)Swing和AWT
新聞來源:http://www.dlmjj.cn/article/cdeccdg.html