— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet339/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   335   336   337   338   339   340   341   342   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

g.setColor(randomColor);
g.fillOval(70,70,100,100);
}
fill the entire panel with black 
(the default color)
The first two args define the (x,y) upper left 
corner, relative to the panel, for where drawing 
starts, so 0, 0 means “start 0 pixels from the 
left edge and 0 pixels from the top edge.” The 
other two args say, “Make the width of this 
rectangle as wide as the panel (this.width()), and 
make the height as tall as the panel (this.height)”
your file name goes here
The x,y coordinates for where the picture’s top 
left corner should go. This says “3 pixels from 
the left edge of the panel and 4 pixels from the 
top edge of the panel”. These numbers are always 
relative to the widget (in this case your JPanel 
subclass), not the entire frame.
start 70 pixels from the left, 70 from 
the top, make it 100 pixels wide, and 
100 pixels tall.
You can make a color by passing in 3 ints 
to represent the RGB values. 
Display a JPEG
Paint a randomly-colored circle 
on a black background


366
 
chapter 12
The argument to paintComponent() is declared as type 
Graphics (java.awt.Graphics).
Behind every good Graphics reference 
is a Graphics2D object.
drawing gradients with 
Graphics2D
public void paintComponent(Graphics g) { }
Methods you can call on a 
Graphics
reference:
drawImage()
drawLine()
drawPolygon
drawRect()
drawOval()
fillRect()
fillRoundRect()
setColor()
So the parameter ‘g’ IS-A Graphics object. Which means it 
could be a subclass of Graphics (because of polymorphism). 
And in fact, it is
The object referenced by the ‘g’ parameter is actually an 

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   335   336   337   338   339   340   341   342   ...   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