— Scott McNealy, Sun Microsystems Chairman, President and ceo



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

gui.go();
}
public void go() {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
JButton button = new JButton(“Just Click It”);
button.addActionListener(this);
text = new JTextArea(10,20);
text.setLineWrap(true);

JScrollPane scroller = new JScrollPane(text);
scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

panel.add(scroller);

frame.getContentPane().add(BorderLayout.CENTER, panel);
frame.getContentPane().add(BorderLayout.SOUTH, button);

frame.setSize(350,300);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent ev) {
text.append(“button clicked \n ”);
}
}

Insert a new line so the words go on a 


separate line each time the button is 
clicked. Otherwise, they’ll run together.


416
 
chapter 13
JCheckBox
Constructor
JCheckBox check = new JCheckBox(“Goes to 11”);
How to use it
Listen for an item event (when it’s selected or deselected)
check.addItemListener(this);
1
Handle the event (and find out whether or not it’s selected)
public void itemStateChanged(ItemEvent ev) {
String onOrOff = “off”;
if (check.isSelected()) onOrOff = “on”;
System.out.println(“Check box is “ + onOrOff);
}
2
Select or deselect it in code
check.setSelected(true);
check.setSelected(false);
3
check 

Download 40,57 Mb.

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