— Scott McNealy, Sun Microsystems Chairman, President and ceo


scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)



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

scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
panel.add(scroller);
1
Replace the text that’s in it
text.setText(“Not all who are lost are wandering”);
2
Make a JScrollPane and give it the 
text area that 
it’s going to 
scroll for.
10 means 10 lines (sets the preferred height)
Select/Highlight the text in the field
text.selectAll();
4
Put the cursor back in the field (so the user 
can just start typing)
text.requestFocus();
5
20 means 20 columns (sets the preferred width)
Unlike JTextField, JTextArea can have more than one line of text. It 
takes a little configuration to make one, because it doesn’t come out of 
the box with scroll bars or line wrapping. To make a JTextArea scroll, you 
have to stick it in a ScrollPane. A ScrollPane is an object that really loves 
to scroll, and will take care of the text area’s scrolling needs.
Append to the text that’s in it
text.append(“button clicked”);
3
Turn on line wrapping
Tell the scroll pane to use only 
a vertical scrollbar
Important!! You give the text area to the scroll pane (through the 
scroll pane constructor), then add the scroll pane to the panel. You 
don’t add the text area directly to the panel!
text 
area


using 
swing
you are here
4
415
JTextArea example
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TextArea1 implements ActionListener {
JTextArea text;
public static void main (String[] args) {
TextArea1 gui = new TextArea1();

Download 40,57 Mb.

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