— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet383/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   379   380   381   382   383   384   385   386   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

 setLayout()
on the panel.


using 
swing
you are here
4
413
Playing with Swing components
You’ve learned the basics of layout managers, so now let’s try out a 
few of the most common components: a text field, scrolling text area, 
checkbox, and list. We won’t show you the whole darn API for each of 
these, just a few highlights to get you started.
JTextField
Constructors
JTextField field = new JTextField(20);
How to use it
Get text out of it
System.out.println(field.getText());
1
Put text in it
field.setText(“whatever”);
field.setText(““);
2
Get an ActionEvent when the user 
presses return or enter
field.addActionListener(myActionListener);
3
You can also register for key events if you 
really want to hear about it every time the 
user presses a key.
20 means 20 columns, not 20 pixels. 
This defines the preferred width of 
the text field.
JTextField field = new JTextField(“Your name”);
Select/Highlight the text in the field
field.selectAll();
4
Put the cursor back in the field (so the user 
can just start typing)
field.requestFocus();
5
JTextField
JLabel
This clears the field


414
 
chapter 13
JTextArea
Constructor
JTextArea text = new JTextArea(10,20);
How to use it
Make it have a vertical scrollbar only
JScrollPane scroller = new JScrollPane(text);
text.setLineWrap(true);
scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   379   380   381   382   383   384   385   386   ...   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