Java的圖形介面依然是跨平台的

來源:互聯網
上載者:User

標籤:工具箱   tom   處理   style   轉換   表單   java   awt   一個   

Awt:抽象視窗工具箱,它由三部分組成:

①組件:介面元素;

②容器:裝載組件的容器(例如表單);

③布局管理器:負責決定容器中組件的擺放位置。

圖形介面的應用分四步:

① 選擇一個容器:

⑴window:帶標題的容器(如Frame);

⑵Panel:面板

通過add()想容器中添加組件。

Java的圖形介面依然是跨平台的。但是在調用了一個表單之後只產生一個表單,沒有事件的處理,關閉按鈕並不工作。此時只能使用CTRL+C終止程式。

②設定一個布局管理器:用setLayout();

③向容器中添加組件;

 

 1 package TomTexts; 2  3 public class TomTexts_19 { 4     public static void main(String[] args)  5     {    //使用基礎資料型別 (Elementary Data Type) 6         double d = 0.7E-3;          7         int i = 1000; 8         byte b = 55; 9         short s = 500;10         Double dd=new Double(d);     11 //使用建構函式產生基礎資料型別 (Elementary Data Type)類的對象12         Integer ii=new Integer(i);13         Byte bb=new Byte(b);14         Short ss=new Short(s);15         Long ll=new Long(50000L);16         Character cc=new Character(‘a‘);17         Float ff=new Float( 0.23F);  18         Boolean bbool=new Boolean( true);  19         //取得對象中的基本類型資料20         double x=dd.doubleValue();21         int y=ii.intValue();22         System.out.println(x);23         System.out.println(y);24         System.out.println(bb.byteValue());25         System.out.println(ss.shortValue());26         System.out.println(ll.longValue());27         System.out.println(cc.charValue());28         System.out.println(ff.floatValue());29         System.out.println(bbool.booleanValue());30         //將基礎資料型別 (Elementary Data Type)類中的數值轉換為字串31         System.out.println(ii.toString());32         System.out.println(ff.toString());33         System.out.println(dd.toString());34         System.out.println(ll.toString());35         System.out.println(ii);36         System.out.println(ff);37         //Integer si= new Integer("45");38         //System.out.println(si.intValue());39     }40 41 }

 

Java的圖形介面依然是跨平台的

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.