— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet368/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   364   365   366   367   368   369   370   371   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

Tonight’s attendees:
Any of the charming personalities from this chapter just 
might show up!
I got the whole GUI, in my hands.
Every event type has one of these. 
 
 
The listener’s key method. 
 
This method gives JFrame its size. 
 
 
You add code to this method but never call it. 
 
When the user actually does something, it’s an _____ .
Most of these are event sources. 
 
 
I carry data back to the listener. 
 
 
An addXxxListener( ) method says an object is an _____ . 
How a listener signs up. 
 
 
 
The method where all the graphics code goes. 
I’m typically bound to an instance. 
 
 
The ‘g’ in (Graphics g), is really of class. 
 
The method that gets paintComponent( ) rolling. 
 
The package where most of the Swingers reside. 
 
Exercise
exercise: 
Who Am I


getting 
gui
you are here
4
395
The Java file on this page represents a 
complete source file. Your job is to play 
compiler and determine whether this file 
will compile. If it won’t compile, how 
would you fix it, and if it does 
compile, what would it do?
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
class InnerButton {
JFrame frame;
JButton b;
public static void main(String [] args) {
InnerButton gui = new InnerButton();
gui.go();
}
public void go() {
frame = new JFrame();
frame.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE);
b = new JButton(“A”);
b.addActionListener();
frame.getContentPane().add(
BorderLayout.SOUTH, b);
frame.setSize(200,100);
frame.setVisible(true);
}
class BListener extends ActionListener {
public void actionPerformed(ActionEvent e) {
if (b.getText().equals(“A”)) {
b.setText(“B”);
} else {
b.setText(“A”);
}
}
}
}
Exercise
BE the compiler


Pool Puzzle
Your job is to take code snippets from 
the pool and place them into the blank 
lines in the code. You may use the 
same snippet more than once, 
and you won’t need to use all the 
snippets. Your goal is to make a 
class that will compile and run 
and produce the output listed.

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   364   365   366   367   368   369   370   371   ...   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