— Scott McNealy, Sun Microsystems Chairman, President and ceo



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

using 
swing
you are here
4
401
Layout Managers
Panel A’s layout manager 
controls the size and 
placement of Panel B.
As a layout manager, 
I’m in charge of the size 
and placement of your components. 
In this GUI, I’m the one who decided 
how big these buttons should be, and 
where they are relative to each 
other and the frame.
A layout manager is a Java object associated 
with a particular component, almost always a 
background component. The layout manager 
controls the components contained within the 
component the layout manager is associated 
with. In other words, if a frame holds a panel, 
and the panel holds a button, the panel’s layout 
manager controls the size and placement of 
the button, while the frame’s layout manager 
controls the size and placement of the 
panel. The button, on the other hand, 
doesn’t need a layout manager because the 
button isn’t holding other components. 
If a panel holds five things, even if those 
five things each have their own layout 
managers, the size and location of the five 
things in the panel are all controlled by the 
panel’s layout manager. If those five things, 
in turn, hold other things, then those other 
things are placed according to the layout 
manager of the thing holding them.
When we say hold we really mean add as in, a 
panel holds a button because the button was 
added to the panel using something like:
myPanel.add(button);
Layout managers come in several flavors, and 
each background component can have its own 
layout manager. Layout managers have their 
own policies to follow when building a layout. 
For example, one layout manager might insist 
that all components in a panel must be the same 
size, arranged in a grid, while another layout 
manager might let each component choose its 
own size, but stack them vertically. Here’s an 
example of nested layouts:
Panel A
Panel B
button 1
button 2
button 3
Panel B’s layout manager 
controls the size and placement 
of the three buttons.
Panel A’s layout manager has NOTHING to 
say about the three buttons. The hierarchy 
of control is only one level—Panel A’s layout 
manager controls only the things added directly 
to Panel A, and does not control anything 
nested within those added components. 

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   369   370   371   372   373   374   375   376   ...   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