Java Appletek I.

snottybugbearΛογισμικό & κατασκευή λογ/κού

3 Νοε 2013 (πριν από 3 χρόνια και 9 μήνες)

59 εμφανίσεις

THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
Ja
va
Appletek I.
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
Ja
va és GUI-k
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
3
W
ebtechnológia 1
AWT, Swing

Abstract Window Toolkit

sok UI komponens

eseménykezelés

grafi
kus eszközök

layout managerek

Swing

pluggable look & feel

lightweight UI Framework

magas szint
!
komponensek
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
4
W
ebtechnológia 1
MVC és Swing

alkalmazás
View
Controller
Model
Window obj.
Listener obj.
Data obj.
Events
Messages
Update
Java UI components
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
5
W
ebtechnológia 1
Swing áttekintés

JComponent

Az alkalmazás vagy applet összes

látható eleme component

A Container osztály példányai

komponensek csoportjait

tartalmazzák

add metódus
2
©

2000
Prentice Hall,
Inc. All rights reserved.
3
12.2
Swing
Overview

Swin
g com
ponen
t
inh
eritance
h
ierarchy

Component

defines
meth
ods
that
can
be
used
in
its
subclasses (for example,
paint

and
repaint
)

Container
- collection of rela
ted components

When
usi
ng
JFrames
,
atta
ch
components
to
the
conten
t
pane
(a
Container
)

Method
add

JComponent
- supercla
ss to most Swing componen
ts

Much
of
a
component
's
functional
ity
inh
erited
from
these
classes
java
.awt
.Comp
onen
t
java
.awt
.Cont
aine
r
java
.lan
g.Obj
ect
java
x.sw
ing.J
Comp
onent
©

2000
Prentice Hall,
Inc. All rights reserved.
4
12.2
Swing
Overview

Som
e
capabili
ties
of
subcl
asses
of
JComponent

Pluggable
look
and
fee
l

Shortcut
key
s
(mne
m
o
n
ics)

Direct access to components
thr
ough keybo
a
r
d

Comm
o
n

e
v
ent
h
andlin
g

If
several
components
p
erform
same
a
ctions

Tool tips

Description
o
f

c
o
mponent
that
appears
when
mouse
over
it

Swin
g
vs
.

awt?

Diffe
rent
com
pone
n
t
s

Java
1.0
v
s
.
Java
1.1
v
s
.
Java
1.2?

Diffe
rent
ev
ent
m
o
d
e
l
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
6
W
ebtechnológia 1
Swing áttekintés

(folyt.)

JComponent legfontosabb

tulajdonságai

pluggable look&feel

shortcut keys

közös eseménykezelés lehetséges

tool tipek

Swing vagy AWT

különböz
"
komponensek
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
7
W
ebtechnológia 1
Java eseménykezelési

modellje

Eseményvezérelt GUI

eseménygenerálás, ha a felhasználó

interakcióba lép egy GUI komponenssel

esemény infók tárolása AWTEvent

leszármazottakban

Események feldolgozása

eseményfi
gyel
"
regisztrálása

event-listener interface

implementálása

eseménykezel
"
implementálása

eseményre válaszul meghívandó

metódusok
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
8
W
ebtechnológia 1
Java eseménykezelési

modellje (folyt.)

Delegációs esemény modell

esemény fi
gyel
"
k használata

az objektum számára érdekes

események feldolgozása

Esemény bekövetkeztekor

GUI komponens értesíti a


gyel
"
ket


gyel
"
meghívja az

eseménykezel
"
metódust
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
9
W
ebtechnológia 1
Események

Különféle események

ActionEvent

képerny
"
gomb megnyomása

AdjustmentEvent

scrollbar mozgatása

MouseEvent

egér koordináták

KeyEvent

billenty
!
kód, karakter
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
10
W
ebtechnológia 1
Adapter osztályok

El
"
regyártott Adapter osztályok

Listener interface-eket

implementáló abstract osztályok

leszármaztatottban a kívánt

metódus felülírható
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
11
W
ebtechnológia 1
Swing komponensek
és az MVC

Maguk a Swing komponensek MVC

struktúrájúak

JComponent-eknek van model-jük

pl. JButton -> ButtonModel

view és controller absztrakt UI

delegáltakban

javax.swing.plaf
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
12
W
ebtechnológia 1
Swing osztályok
JComponent
JT
extComponent
AbstractButton
JComboBox
JLabel
JList
JMenuBar
JPane
JPopupMenu
JScrollbar
JScrollPane
JT
able
JT
ree
JT
oggleButton
JButton
JMenuItem
JCheckBox
JRadioButton
JRadioButtonMenuItem
JCheckBoxMenuItem
Container
Component
Object
JPanel
JApplet
Applet
Panel
JMenu
Font
Color
JT
extArea
JT
extField
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
13
W
ebtechnológia 1
Swing GUI

komponensek
Demo pr
ogram at jdk1.4/demo/jfc/SwingSet2/SwingSet2.html
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
14
W
ebtechnológia 1
Layout kezelés

Automatikus átrendezés
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
15
W
ebtechnológia 1
Border layout
public class
T
estBor
derLa
y
out extends JApplet {
public v
oid init() {
Container guiContainer  getContentPane();
F
ont big  ne
w F
ont("SansSerif",
F
ont.BOLD
,
20);
JButton buttonOne  ne
w JButton("1");
buttonOne
.setF
ont(big);
guiContainer
.ad
d(buttonOne
,
Bor
derLa
y
out.WEST);
JButton buttonT
w
o  ne
w JButton("2");
buttonT
w
o
.setF
ont(big);
guiContainer
.ad
d(buttonT
w
o
,
Bor
derLa
y
out.CENTER);
JButton buttonThr
ee  ne
w JButton("3");
buttonThr
ee
.setF
ont(big);
guiContainer
.ad
d(buttonThr
ee
,
Bor
derLa
y
out.EAST);
JButton buttonF
our  ne
w JButton("4");
buttonF
our
.setF
ont(big);
guiContainer
.ad
d(buttonF
our
,
Bor
derLa
y
out.NOR
TH);
JButton buttonFiv
e  ne
w JButton("5");
buttonFiv
e
.setF
ont(big);
guiContainer
.ad
d(buttonFiv
e
,
Bor
derLa
y
out.SOUTH);
}
}
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
16
W
ebtechnológia 1
GridLayout
public class
T
estGridLa
y
out extends JApplet {
private JT
extField name  ne
w JT
extField(15);
private JT
extField ad
dr
ess  ne
w JT
extField(15);
private JT
extField phone  ne
w JT
extField(15);
private JT
extField eMail  ne
w JT
extField(15);
public v
oid init() {
Container guiContainer  getContentPane();
guiContainer
.setLa
y
out(ne
w GridLa
y
out(4,
2,
5,
5));
JLabel label  ne
w JLabel("Name:",
JLabel.RIGHT);
guiContainer
.ad
d(label);
guiContainer
.ad
d(name);
label  ne
w JLabel("Ad
dr
ess:",
JLabel.RIGHT);
guiContainer
.ad
d(label);
guiContainer
.ad
d(ad
dr
ess);
label  ne
w JLabel("Phone:",
JLabel.RIGHT);
guiContainer
.ad
d(label);
guiContainer
.ad
d(phone);
label  ne
w JLabel("E-mail:",
JLabel.RIGHT);
guiContainer
.ad
d(label);
guiContainer
.ad
d(eMail);
}
}
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
17
W
ebtechnológia 1
GridBagLayout

GridBagLayout is the most general of all the layout

managers, and often the only applicable.

It’s not suited for the trial end error method.

To use it you have to do a careful planning. Use pen

and paper!

The manager has many parameters, and an error

may give unpredictable results.

First, create a sketch of the window:

Divide the window into rectangular cells by using

vertical and horizontal lines.

Not more than one GUI component in every cell.

A GUI component may cover more than one cell.

This sketch makes it possible to state the

requirements of every component.
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
18
W
ebtechnológia 1
GridBag példa

toolbar
table
on
the left
list
on
the right
backgr.
text
at the ottom
text
box
at
the bottom
gridx
0
0
3
1
2
gridy
0
1
1
2
2
gridwidth
4
3
1
1
1
gridheight
1
1
1
1
1
fill
NONE
BOTH
BOTH
NONE
HORIZONTAL
anchor
WEST
CENTER
CENTER
EAST
WEST
0
1
2
0
1
2
3
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
19
W
ebtechnológia 1
GridBag példa

(folyt.)
Container guiContainer = getContentPane();
guiContainer.setLayout(new GridBagLayout()); // don’t forget this!
GridBagConstraints constraints = new GridBagConstraints();
/* The following variables are fi
xed for all components */
constraints.insets = new Insets(5, 5, 5, 5); // space around and between the components
constraints.weightx = 0.5;
constraints.weighty = 0.5;
/* Then each component has to be handled according to the table */
/* The Toolbar */
constraints.gridx = 0;
constraints.gridy = 0;
constraints.gridwidth = 4;
constraints.gridheight = 1;
constraints.fi
ll = GridBagConstraints.NONE;
constraints.anchor = GridBagConstraints.WEST;
guiContainer.add(toolbar, constraints);
// ..and so on, for all the components
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
Appletek
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
21
W
ebtechnológia 1
Hello world

applet
import javax.swing.JApplet;
import java.awt.Graphics;
public class HelloWorld extends JApplet {
public void paint(Graphics g) {
g.drawRect(0, 0,
getSize().width - 1,
getSize().height - 1);
g.drawString("Hello world!", 5, 15);
}
}
<applet code="HelloW
orld.class" codebase="examples/" archive="helloW
orld.jar"

width="150" height="30"></applet>
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
22
W
ebtechnológia 1
Appletek
Object
Component
JFrame
JApplet
JInternalFrame
Dialog
JDialog
Container
Window
JComponent
Panel
Frame
JWindow
Applet
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
23
W
ebtechnológia 1
Appletek (folyt.)

grafi
kus kisalkalmazás

böngész
"
vagy appletviewer

kontextus

java.applet.Applet vagy

javax.swing.JApplet specializálása

standard interfész

homokozó (sandbox)

SecurityManager
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
24
W
ebtechnológia 1
Applet
életciklus
The applet is stopped,
the user has left the
W
eb page.
init()
start()
start()
stop()
destroy()
The applet is
loaded and starts
right away
.
The applet is
running, the
user is watching.
The applet is out of the
world because the
browser is closed, or for
another reason.
loaded
running
stopped
dead
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
25
W
ebtechnológia 1
Applet
életciklus (folyt.)
/*
* Java(TM) SE 6 Version
*/
import java.applet.Applet;
import java.awt.Graphics;
//No need to extend JApplet, since we don't add any components;
//we just paint.
public class Simple extends Applet {
StringBuffer buffer;
public void init() {
buffer = new StringBuffer();
addItem("initializing... ");
}
public void start() {
addItem("starting... ");
}
public void stop() {
addItem("stopping... ");
}
public void destroy() {
addItem("preparing for unloading...");
}
private void addItem(String newWord) {
System.out.println(newWord);
buffer.append(newWord);
repaint();
}
public void paint(Graphics g) {
//Draw a Rectangle around the applet's display area.
g.drawRect(0, 0,
getWidth() - 1,
getHeight() - 1);
//Draw the current string inside the rectangle.
g.drawString(buffer.toString(), 5, 15);
}
}
appletviewer lifeCycle.html
initializing...
starting...
stopping...
preparing for unloading...
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
26
W
ebtechnológia 1
Applet
életciklus (folyt.)

init metódus

constructor szer
!
m
!
veletek

elvégzése, teljes contextus

start metódus

az applet tevékenysége

szálak indítása

stop metódus

er
"
források elengedése
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
27
W
ebtechnológia 1
Megjelenítés

Applet megjelenítés a

paint metódussal
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
28
W
ebtechnológia 1
Eseménykezelés
/*
* Java(TM) SE 6 version.
*/
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.applet.Applet;
import java.awt.Graphics;
//No need to extend JApplet, since we don't add any components;
//we just paint.
public class SimpleClick extends Applet

implements MouseListener
{
StringBuffer buffer;
public void init() {

addMouseListener(this);
buffer = new StringBuffer();
addItem("initializing... ");
}
public void start() {
addItem("starting... ");
}
public void stop() {
addItem("stopping... ");
}
public void destroy() {
addItem("preparing for unloading...");
}
void addItem(String newWord) {
System.out.println(newWord);
buffer.append(newWord);
repaint();
}
public void paint(Graphics g) {
//Draw a Rectangle around the applet's display area.
g.drawRect(0, 0,
getWidth() - 1,
getHeight() - 1);
//Draw the current string inside the rectangle.
g.drawString(buffer.toString(), 5, 15);
}
//The following empty methods could be removed
//by implementing a MouseAdapter (usually done
//using an inner class).
public void mouseEntered(MouseEvent event) {
}
public void mouseExited(MouseEvent event) {
}
public void mousePressed(MouseEvent event) {
}
public void mouseReleased(MouseEvent event) {
}

public void mouseClicked(MouseEvent event) {
addItem("click!... ");
}
}
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
29
W
ebtechnológia 1
UI komponensek

appletben

Swing komponensek

Applet -> Container

add, remove

setLayout
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
30
W
ebtechnológia 1
UI komponensek

appletben (pl.)
/*
* Java(TM) SE 6 version.
*/
import
javax.swing.JApplet;
import
javax.swing.JTextField;
import
javax.swing.SwingUtilities;
//Since we're adding a Swing component, we now need to
//extend JApplet. We need to be careful to access
//components only on the event-dispatching thread.
public

class
ScrollingSimple
extends
JApplet {
JTextField field;

public

void
init() {

//Execute a job on the event-dispatching thread:

//creating this applet's GUI.

try
{
SwingUtilities.invokeAndWait(
new
Runnable() {

public

void
run() {
createGUI();
}
});
}
catch
(Exception e) {
System.err.println(
"createGUI didn't successfully complete"
);
}
addItem(
false
,
"initializing... "
);
}

private

void
createGUI() {

//Create the text field and make it uneditable.
field =
new
JTextField();
field.setEditable(
false
);

//Set the layout manager so that the text field will be

//as wide as possible.
getContentPane().setLayout(
new
java.awt.GridLayout(
1
,
0
));

//Add the text field to the applet.
getContentPane().add(field);
}

public

void
start() {
addItem(
false
,
"starting... "
);
}

public

void
stop() {
addItem(
false
,
"stopping... "
);
}

public

void
destroy() {
addItem(
false
,
"preparing for unloading..."
);
cleanUp();
}
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
31
W
ebtechnológia 1
UI komponensek

appletben (pl.)
private

void
cleanUp()
//Execute a job on the event-dispatching thread:
//taking the text field out of this applet.
try
{
SwingUtilities.invokeAndWait(
new
Runnable() {
public

void
run() {
remove(field);
}
});
}
catch
(Exception e) {
System.err.println(
"cleanUp didn't successfully complete"
);
}
field =
null
;
}
private

void
addItem(
boolean
alreadyInEDT, String newWord) {

if
(alreadyInEDT) {
addItem(newWord);
}
else
{

final
String word = newWord;

//Execute a job on the event-dispatching thread:

//invoking addItem(newWord).

try
{
SwingUtilities.invokeAndWait(
new
Runnable() {

public

void
run() {
addItem(word);
}
});
}
catch
(Exception e) {
System.err.println(
"addItem didn't successfully complete"
);
}
}
}


//Invoke this method ONLY from the event-dispatching thread.

private

void
addItem(String newWord) {
String t = field.getText();
System.out.println(newWord);
field.setText(t + newWord);
}
}
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
32
W
ebtechnológia 1
A homokozó

browser security policy

SecurityManager

SecurityException

korlátozások

An applet cannot load libraries or defi
ne native methods.

It cannot ordinarily read or write fi
les on the host that's

executing it.

It cannot make network connections except to the host that

it came from.

It cannot start any program on the host that's executing it.

It cannot read certain system properties.

Windows that an applet brings up look di
#
erent than

windows that an application brings up.
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
33
W
ebtechnológia 1
Applet

sajátosságok

Alkalmazásoktól eltér
"
lehet
"
ségek

Applets can usually make network connections to the

host they came from.

Applets running within a Web browser can easily

cause HTML documents to be displayed.

Applets can invoke public methods of other applets

on the same page.

Applets that are loaded from the local fi
le system

(from a directory in the user's CLASSPATH) have none

of the restrictions that applets loaded over the

network do.
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
34
W
ebtechnológia 1
Az applet API

Az appletek az API-n keresztül

értesülhetnek az applet futási

állapotváltozásairól

az applet vagy beágyazó oldal URL-
jéhez relatív elérési utakkal fájlokat

tölthetnek le

írhatnak a browser státusz-sorába

megjeleníthatnek dokumentumokat a

browserben

paramétereket olvashatnak az applet

tagb
"
l
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
35
W
ebtechnológia 1
Fájlok letöltése

getCodeBase

getDocumentBase

getImage

gif, jpeg

MediaTracker

getAudioClip

wav,midi,ai
#
,au

URL osztály
class file
a.png
imgDir
Image image = getImage(getCodeBase(), "imgDir/a.png");
com
xcompany
xproj
class file
a.png
imgDir
package com.xcompany.xproj;
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
36
W
ebtechnológia 1
MediaTracker
// Create a MediaTracker instance,
// to montior loading of images
tracker = new MediaTracker(this);
// Load the image
Image img = getImage( getDocumentBase(),"picture.jpg" );
// Register it with media tracker
tracker.addImage(img, 1);
// Check to see if it has loaded
if (tracker.checkID(1) == false)
{
// Not yet, display message .....
}
else
{
// Display the animation
}
// Wait until all images have loaded
tracker.waitForAll();
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
37
W
ebtechnológia 1
Fájlok letöltése

(pl.)
import
javax.swing.*;
import
java.awt.*;
/** Demonstrate drawing an image. **/
public

class
ImageApplet
extends
JApplet
{

public

void
init () {
Container content_pane = getContentPane ();

// Grab the image.
Image img = getImage (getCodeBase (),
"liftoff.jpg"
);

// Create an instance of DrawingPanel
DrawingPanel drawing_panel =
new
DrawingPanel (img);

// Add the DrawingPanel to the contentPane.
content_pane.add (drawing_panel);
}
// init
}
// ImageApplet
/** Draw on a JPanel rather than on JApplet's Panel. **/
class
DrawingPanel
extends
JPanel {
Image img;
DrawingPanel (Image img) {

this
.img = img;
}

public

void
paintComponent (Graphics g) {

super
.paintComponent (g);

// Use the image width& width to find the starting point

int
img_x = getSize ().width/
2
- img.getWidth (
this
)/
2
;

int
img_y = getSize ().height/
2
- img.getHeight (
this
)/
2
;

//Draw image at centered in the middle of the panel
g.drawImage (img, img_x, img_y,
this
);
}
// paintComponent
}
// class DrawingPanel
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
38
W
ebtechnológia 1
Dokumentum megjelenítés

a böngész
!
ben

public void showDocument(java.net.URL url)

public void showDocument(java.net.URL url, String targetWindow)

browser ablakok

_blank

új, névtelen ablak

_self

az applet ablaka

_parent

keretek esetén a frameset ablaka

_top

legmagasabb szint
!
frameset ablaka
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
39
W
ebtechnológia 1
Dokumentum megjelenítés

a böngész
!
ben (pl.)
/*
* Java(TM) SE 6 version.
*/
import
java.applet.AppletContext;
import
javax.swing.*;
import
java.awt.GridBagLayout;
import
java.awt.GridBagConstraints;
import
java.awt.Insets;
import
java.awt.event.*;
import
java.net.URL;
import
java.net.MalformedURLException;
public

class
ShowDocument
extends
JApplet

implements
ActionListener {
URLWindow urlWindow;

public

void
init() {

//Execute a job on the event-dispatching thread:

//creating this applet's GUI.

try
{
SwingUtilities.invokeAndWait(
new
Runnable() {

public

void
run() {
createGUI();
}
});
}
catch
(Exception e) {
System.err.println(
"createGUI didn't successfully complete"
);
}
}
private

void
createGUI() {
JButton button =
new
JButton(
"Bring up URL window"
);
button.addActionListener(
this
);
getContentPane().add(button);
JFrame.setDefaultLookAndFeelDecorated(
true
);
urlWindow =
new
URLWindow(getAppletContext());
urlWindow.pack();
}

public

void
destroy() {

//Execute a job on the event-dispatching thread:

//creating this applet's GUI.

try
{
SwingUtilities.invokeAndWait(
new
Runnable() {

public

void
run() {
destroyGUI();
}
});
}
catch
(Exception e) { }
}


private

void
destroyGUI() {
urlWindow.setVisible(
false
);
urlWindow =
null
;
}
public

void
actionPerformed(ActionEvent event) {
urlWindow.setVisible(
true
);
}
}
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
40
W
ebtechnológia 1
Dokumentum megjelenítés

a böngész
!
ben (pl.)
class
URLWindow
extends
JFrame

implements
ActionListener {
JTextField urlField;
JComboBox choice;
AppletContext appletContext;

public
URLWindow(AppletContext appletContext) {

super
(
"Show a Document!"
);

this
.appletContext = appletContext;
JPanel contentPane =
new
JPanel(
new
GridBagLayout());
setContentPane(contentPane);
contentPane.setBorder(BorderFactory.createEmptyBorder(
10
,
10
,
10
,
10
));
GridBagConstraints c =
new
GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
JLabel label1 =
new
JLabel(
"URL of document to show: "
,
JLabel.TRAILING);
getContentPane().add(label1, c);
urlField =
new
JTextField(
"http://java.sun.com/"
,
20
);
label1.setLabelFor(urlField);
urlField.addActionListener(
this
);
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx =
1.0
;
getContentPane().add(urlField, c);
JLabel label2 =
new
JLabel(
"Window/frame to show it in: "
,
JLabel.TRAILING);
c.gridwidth =
1
;
c.weightx =
0.0
;
getContentPane().add(label2, c);
String[] strings = {

"(browser's choice)"
,
//don't specify

"My Personal Window"
,
//a window named "My Personal Window"

"_blank"
,
//a new, unnamed window

"_self"
,

"_parent"
,

"_top"

//the Frame that contained this applet
};
choice =
new
JComboBox(strings);
label2.setLabelFor(choice);
c.fill = GridBagConstraints.NONE;
c.gridwidth = GridBagConstraints.REMAINDER;
c.insets =
new
Insets(
5
,
0
,
0
,
0
);
c.anchor = GridBagConstraints.LINE_START;
getContentPane().add(choice, c);
JButton button =
new
JButton(
"Show document"
);
button.addActionListener(
this
);
c.weighty =
1.0
;
c.ipadx =
10
;
c.ipady =
10
;
c.insets =
new
Insets(
10
,
0
,
0
,
0
);
c.anchor = GridBagConstraints.PAGE_END;
getContentPane().add(button, c);
}
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
41
W
ebtechnológia 1
Dokumentum megjelenítés

a böngész
!
ben (pl.)

public

void
actionPerformed(ActionEvent event) {
String urlString = urlField.getText();
URL url =
null
;

try
{
url =
new
URL(urlString);
}
catch
(MalformedURLException e) {
System.err.println(
"Malformed URL: "
+ urlString);
}

if
(url !=
null
) {

if
(choice.getSelectedIndex() ==
0
) {
appletContext.showDocument(url);
}
else
{
appletContext.showDocument(url,
(String)choice.getSelectedItem());
}
}
}
}
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
42
W
ebtechnológia 1
Státusz-sor

átmeneti státusz információk kiírása
import
!
java.applet.AppletContext;
import
!
java.awt.Graphics;
import
!
java.net.URL;
import
!
javax.swing.JApplet;
public
!
class
!
MainClass
!
extends
!
JApplet
!
{
!!
public
!
void
!
paint(Graphics
!
g)
!
{
!!!!
AppletContext
!
ac
!
=
!
getAppletContext();
!!!!
try
!
{
!!!!!!
URL
!
url
!
=
!
new
!
URL(
"http://www.java2s.com"
);
!!!!!!
ac.showDocument(url,
!
"frame2"
);
!!!!
}
!
catch
!
(Exception
!
e)
!
{
!!!!!!
showStatus(
"Exception:
!
"
!
+
!
e);
!!!!
}
!!!!
g.drawString(
"ShowDocument
!
Applet"
,
!
10
,
!
25
);
!!
}
}
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
43
W
ebtechnológia 1
Applet

paraméterek

commandline paraméterekhez hasonló

használat


exibilis felhasználás

paraméterek

név

értékkészlet

default érték
<APPLET CODE=SampleApplet.class CODEBASE=example
WIDTH=350 HEIGHT=60>
<PARAM NAME=windowClass VALUE=BorderWindow>
<PARAM NAME=windowTitle VALUE="BorderLayout">
<PARAM NAME=buttonText
VALUE="Click here to see a BorderLayout in action">
</APPLET>
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
44
W
ebtechnológia 1
Applet paraméterek

(folyt.)
public String getParameter(String name)
int requestedWidth = 0; //default value
. . .
String windowWidthString = getParameter("WINDOWWIDTH");
if (windowWidthString != null) {
try {
requestedWidth = Integer.parseInt(windowWidthString);
} catch (NumberFormatException e) {
//Use default width.
}
}
THE
INTERNET,
mapped
on
the
opposite
page,
is
a
scale-free
network
in
that
some
siteS
(starbursts
and
detail
above)
have
a
seemingly
unlimited
number
of
connections
to
other
sites.
This
map,
made
on
February
6,
2003,
traces
the
shortest
routes
from
a
test
Web
sinHo
about
100,000
others,
using
like
colors
for
similar
Web
addresses.
a
-
Scientists
have
recently
discovered
that
various
complex
systems
have
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red
orga
n
ili
ng
pri
nci
pies.
This
insight
has
important
impli~ationsfor
a
host
of
applications,
from
drug
development
to
Internet
security
BY
ALBERT-U\SZLO
BARABASI
AND
ERIC
BONABEAU
50
SCIENTIFIC
AMERICAN
MAY
2003
45
W
ebtechnológia 1
Applet paraméterek

(folyt.)

Paraméter információk megadása
public String[][] getParameterInfo() {
String[][] info = {
// Parameter Name Kind of Value Description
{"imagesource", "URL", "a directory"},
{"startup", "URL", "displayed at startup"},
{"background", "URL", "displayed as background"},
{"startimage", "int", "start index"},
{"endimage", "int", "end index"},
{"namepattern", "URL", "used to generate indexed names"},
{"pause", "int", "milliseconds"},
{"pauses", "ints", "milliseconds"},
{"repeat", "boolean", "repeat or not"},
{"positions", "coordinates", "path"},
{"soundsource", "URL", "audio directory"},
{"soundtrack", "URL", "background music"},
{"sounds", "URLs", "audio samples"},
};
return info;
}