— Scott McNealy, Sun Microsystems Chairman, President and ceo



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

import javax.swing.*;
import java.awt.*;
public class Button1 {
public static void main (String[] args) {
Button1 gui = new Button1();
gui.go();
}
public void go() {
JFrame frame = new JFrame();
JButton button = new JButton(“click me”);
frame.getContentPane().add(BorderLayout.EAST, button);
frame.setSize(200,200);
frame.setVisible(true);
}
}
BorderLayout is in java.awt package
specify the region
Let’s add a button to the east region:
border 
layout
brainbarbell
Brain Barbell
How did the BorderLayout manager come up with 
this size for the button?
What are the factors the layout manager has to 
consider?
Why isn’t it wider or taller?


using 
swing
you are here
4
405
Since it’s in the east 
region of a border layout, 
I’ll respect its preferred width. But 
I don’t care how tall it wants to be; 
it’s gonna be as tall as the frame, 
because that’s my policy.

public void go() {


JFrame frame = new JFrame();
JButton button = new JButton(“click like you mean it”);
frame.getContentPane().add(BorderLayout.EAST, button);
frame.setSize(200,200);
frame.setVisible(true);
}
Watch what happens when we give 
the button more characters...
We changed only the text 
on the button
Button objec

First, I ask the 
button for its 
preferred size.
I have a lot of words 
now, so I’d prefer to be 
60 pixels wide and 25 
pixels tall. 
Button objec

Next time 
I’m goin’ with flow 
layout. Then I get 
EVERYTHING I 
want.
The button gets 
its preferred 
width, 
but not height.



Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   372   373   374   375   376   377   378   379   ...   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