Qhov txawv ntawm AWT thiab viav vias

Cov txheej txheem:

Qhov txawv ntawm AWT thiab viav vias
Qhov txawv ntawm AWT thiab viav vias

Video: Qhov txawv ntawm AWT thiab viav vias

Video: Qhov txawv ntawm AWT thiab viav vias
Video: Java Swing GUI Part #1: Difference between AWT and Swing | Look and Feel-Windows, Metal and Motif 2024, Kaum ib hlis
Anonim

Key Difference – AWT vs Swing

Java yog cov lus programming qib siab tsim los ntawm Sun Microsystems. Java txhawb nqa Object Oriented Programming uas pab tsim thiab tsim software siv cov khoom. Thaum Java program tau muab tso ua ke, nws tau hloov mus rau hauv bytecode. Cov bytecode ntawd txhais tau los ntawm Java Virtual Machine (JVM) ntawm txhua lub platform. Yog li ntawd, nws yog hom lus programming uas cov programmers tuaj yeem sau ib zaug thiab khiav ntawm txhua lub platform. Java tuaj yeem siv los tsim ntau yam kev siv xws li desktop, mobile thiab web applications. Cov lus muab cov cuab yeej siv los tsim kev nplua nuj Graphical User Interfaces (GUI). Ob ntawm lawv yog AWT thiab Swing. Kab lus no tham txog qhov sib txawv ntawm AWT thiab Swing. Qhov sib txawv tseem ceeb ntawm AWT thiab Swing yog tias AWT yog Java tus thawj platform nyob ntawm qhov rais, cov duab, thiab cov neeg siv interface widget toolkit thaum Swing yog GUI widget toolkit rau Java uas yog qhov txuas ntxiv rau AWT.

AWT yog dab tsi?

A Graphical User Interface yog ib qho interface rau cov neeg siv los muab cov lus qhia rau software ua haujlwm. Nws muaj ntau yam graphical Cheebtsam. Qee qhov GUI Cheebtsam yog qhov rais, khawm, combo lub thawv, thaj chaw ntawv, daim ntawv teev npe, thiab daim ntawv lo. Siv cov khoom siv no, tus programmer tuaj yeem tsim qhov kev sib tham sib tham rau tus neeg siv rau daim ntawv thov. GUI yog ua raws li cov xwm txheej. Nyem khawm, kaw lub qhov rais, ntaus ib yam dab tsi hauv lub thawv ntawv yog qee qhov piv txwv ntawm cov xwm txheej uas tuaj yeem tshwm sim hauv Graphical User Interface raws li daim ntawv thov. Niaj hnub no ntau daim ntawv thov muaj GUIs. Cov ntawv thov txawb, Air ticket reservation systems, Automated Teller Machines muaj nplua nuj graphical interfaces rau cov neeg siv khoom siv daim ntawv thov yooj yim.

AWT stands for Abstract Window Toolkit. AWT xav tau ib hom OS khoom siv los siv cov haujlwm. Yog li ntawd, AWT Cheebtsam yog hnyav hnyav thiab xav tau ntau qhov chaw nco. AWT Cheebtsam kuj siv sijhawm los ua. Tus naj npawb ntawm cov khoom muaj nyob hauv AWT yog qhov tsawg kawg nkaus. Nws yog tsim nyog los import javax.awt pob los tsim AWT raws li GUI daim ntawv thov.

Qhov txawv ntawm AWT thiab Swing
Qhov txawv ntawm AWT thiab Swing
Qhov txawv ntawm AWT thiab Swing
Qhov txawv ntawm AWT thiab Swing

Figure 01: AWT and Swing

Qee AWT Cheebtsam yog khawm, cov ntawv teb, xa cov thawv, scroll bars, qhov rai, ncej, vaj huam sib luag, cov ntawv lo. Tom qab tsim cov khoom, lawv tuaj yeem muab tso rau hauv ib lub thawv. Lub thawv muab qhov chaw rau cov khoom thauj khoom. AWT tsis txhawb nqa pluggable saib thiab hnov. Yog li, daim ntawv thov AWT tsim nyob rau hauv ib qho kev khiav hauj lwm yuav tsis zoo ib yam hauv lwm qhov kev khiav hauj lwm.

Swing yog dab tsi?

Swing yog GUI widget toolkit rau Java. Nws yog ib feem ntawm Oracle's Java Foundation Classes (JFC). Nws yog Daim Ntawv Thov Programming Interface los tsim GUI rau Java daim ntawv thov. Nws yog tsim rau saum AWT API. Lub viav vias tau tsim los muab cov khoom hloov pauv tau yooj yim thiab cov khoom siv zoo dua li AWT. Lub viav vias muaj cov khoom siv yooj yim xws li cov ntawv sau, cov thawv ntawv, cov nyees khawm. Nws kuj tseem muaj cov khoom siv siab dua. Ib txhia ntawm lawv yog ntoo, rooj, cov npe, scroll panes thiab tabbed panes. Yog tias tus programmer xav tau los siv Swing daim ntawv thov, nws yog qhov tsim nyog los import javax.swing pob. Lub pob muab cov chav kawm rau Java Swing API xws li JButton, JRadioButton, JTextField, JCheckbox thiab lwm yam.

Swing Cheebtsam tsis muaj lub platform tshwj xeeb code. Yog li ntawd, Swing yog platform ywj siab. Tsis zoo li AWT, Swing tsis xav tau OS hu los tsim cov khoom. JVM yog lub luag haujlwm rau kev hu cov txheej txheem ib txwm muaj. Swing Cheebtsam yog lub teeb yuag. Qhov chaw nco yuav tsum yog qhov tsawg kawg nkaus. Qhov no yog qhov tseem ceeb tshaj plaws los khiav Swing raws li daim ntawv thov sai dua. Hauv kev txhim kho daim ntawv thov, Qauv, Saib, Tswj (MVC) yog ib qho qauv tsim. Tus qauv sawv cev rau cov ntaub ntawv. Qhov kev pom sawv cev rau qhov kev nthuav qhia thaum Controller yog qhov cuam tshuam ntawm Model thiab Saib. Swing ua raws li tus qauv no. Swing txhawb qhov pluggable saib thiab hnov. Zuag qhia tag nrho, nws muaj zog dua AWT.

Qhov Zoo sib xws ntawm AWT thiab viav vias yog dab tsi?

Ob leeg yog Java-based toolkits los tsim Graphical User Interface

Qhov txawv ntawm AWT thiab viav vias yog dab tsi?

AWT vs Swing

AWT yog Java tus thawj platform nyob ntawm qhov rais, duab thiab cov neeg siv interface widget toolkit ua ntej Swing. Swing yog GUI widget toolkit rau Java uas yog ib feem ntawm Oracle's Java Foundation Class (JFC).
Platform Dependency
AWT Cheebtsam yog lub platform nyob ntawm. Swing Cheebtsam yog platform ywj siab.
Tus naj npawb ntawm Cheebtsam
AWT muaj tsawg tus lej ntawm cov khoom. Swing muaj ntau dua ntawm cov khoom.
khoom
AWT Cheebtsam yog hnyav. Swing Cheebtsam yog lub teeb yuag.
MVC
AWT tsis ua raws MVC. Swing follow MVC.
Speed
AWT tsis nrawm li Swing. Swing nrawm dua AWT.
Yuav tsum muaj chaw nco
AWT Cheebtsam xav tau ntau qhov chaw nco. Swing Cheebtsam xav tau chaw nco tsawg dua.
pob khoom xav tau
AWT xav kom import javax.awt pob. Swing xav tau import javax.swing pob.
Pluggable Saib thiab xav
AWT tsis txhawb pluggable saib thiab hnov. Swing muab qhov ntsaws ntsaws qhov muag thiab hnov.

Summary – AWT vs Swing

Kab lus no tau tham txog ob lub Graphical User Interface Designing tool uas yog AWT thiab Viav. Qhov sib txawv ntawm AWT thiab Swing yog tias AWT yog Java tus thawj platform nyob ntawm qhov rais, cov duab thiab cov neeg siv interface widget toolkit thaum Swing yog GUI widget toolkit rau Java, uas yog qhov txuas ntxiv rau AWT. Swing muab kev ua haujlwm zoo dua piv rau AWT. Cov tsos ntawm GUI tsim siv Swing zoo li zoo dua GUI nrog AWT. Tsis zoo li AWT, viav vias txhawb nqa pluggable saib thiab hnov thiab ua rau kom siv tau ntawm daim ntawv thov.

Download the PDF Version of AWT vs Swing

Koj tuaj yeem rub tawm PDF version ntawm kab lus no thiab siv nws rau offline hom phiaj raws li daim ntawv ceeb toom. Thov rub tawm PDF version ntawm no: Qhov txawv ntawm AWT thiab Swing

Pom zoo: