— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet372/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   368   369   370   371   372   373   374   375   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

400
 
chapter 13
Component 
is the more correct term for what we’ve been calling a widget
The things you put in a GUI. The things a user sees and interacts with. Text 
fields, buttons, scrollable lists, radio buttons, etc. are all components. In 
fact, they all extend
javax.swing.JComponent

components and 
containers
Swing components
In Swing, virtually all components are capable of holding other 
components. In other words, you can stick just about anything into anything 
else. But most of the time, you’ll add user interactive components such as 
buttons and lists into background components such as frames and panels. 
Although it’s possible to put, say, a panel inside a button, that’s pretty 
weird, and won’t win you any usability awards. 
With the exception of JFrame, though, the distinction between interactive 
components and background components is artificial. A JPanel, for 
example, is usually used as a background for grouping other components, 
but even a JPanel can be interactive. Just as with other components, you 
can register for the JPanel’s events including mouse clicks and keystrokes.
Components can be nested
Four steps to making a GUI (review)
JFrame frame = new JFrame();
Make a window (a JFrame)
JButton button = new JButton(“click me”);
frame.getContentPane().add(BorderLayout.EAST, button);
1
Make a component (button, text field, etc.)
2
Add the component to the frame
3
frame.setSize(300,300);
frame.setVisible(true);
Display it (give it a size and make it visible)
4
Put 
interactive components
:
Into 
background components
:
JButton
JCheckBox
JTextField
JFrame
JPanel
A widget is technically 
a Swing Component. 
Almost every thing 
you can stick in a 
GUI extends from 
javax.swing.JComponent.



Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   368   369   370   371   372   373   374   375   ...   555




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish