— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet328/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   324   325   326   327   328   329   330   331   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

354
 
chapter 12
You don’t add things to the frame 
directly.Think of the frame as the 
trim around the window, and you add 
things to the window pane.
“If I see one more 
command-line app, 
you’re fired.”
A JFrame is the object that represents 
a window on the screen. It’s where you 
put all the interface things like buttons, 
checkboxes, text fields, and so on. It can 
have an honest-to-goodness menu bar 
with menu items. And it has all the little 
windowing icons for whatever platform 
you’re on, for minimizing, maximizing, and 
closing the window. 
The JFrame looks different depending on 
the platform you’re on. This is a JFrame on 
Mac OS X:
a JFrame with a menu bar 
and two ‘widgets’ (a button 
and a radio button)
Making a GUI is easy:
your first 
gui
 
It all starts with a window
JFrame frame = new JFrame();
Once you have a JFrame, you can put 
things (‘widgets’) in it by adding them 
to the JFrame. There are a ton of Swing 
components you can add; look for them 
in the javax.swing package. The most 
common include JButton, JRadioButton, 
JCheckBox, JLabel, JList, JScrollPane, 
JSlider, JTextArea, JTextField, and 
JTable. Most are really simple to use, but 
some (like JTable) can be a bit more 
complicated. 
Put widgets in the window
Make a frame (a JFrame)
JButton button = new JButton(“click me”);
frame.getContentPane().add(button);
1
Make a widget (button, text field, etc.)
2
Add the widget to the frame
3
frame.setSize(300,300);
frame.setVisible(true);
Display it (give it a size and make it visible)
4



Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   324   325   326   327   328   329   330   331   ...   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