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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 2003Java 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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 2003THE 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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 20033
Webtechnológia 1
AWT, Swing
•
Abstract Window Toolkit
•
sok UI komponens
•
eseménykezelés
•
grafikus 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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 20034
Webtechnológia 1
MVC és Swing
alkalmazás
View
Controller
Model
Window obj.
Events
Listener obj.
Messages
Data obj.
Update
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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 20035
Webtechnoló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
• Swing component inheritance hierarchy
•
Component
defines methods that can be used in its
subclasses (for example,
paint
and
repaint
)
•
Container
- collection of related components
– When using
JFrames
, attach components to the content
pane (a
Container
)
– Method
add
•
JComponent
- superclass to most Swing components
• Much of a component's functionality inherited from these
classes
java.awt.Component
java.awt.Container
java.lang.Object
javax.swing.JComponent
2000 Prentice Hall, Inc. All rights reserved.
4
12.2 Swing Overview
• Some capabilities of subclasses of
JComponent
– Pluggable look and feel
– Shortcut keys (mnemonics)
• Direct access to components through keyboard
– Common event handling
• If several components perform same actions
– Tool tips
• Description of component that appears when mouse over it
• Swing vs. awt?
– Different components
• Java 1.0 vs. Java 1.1 vs. Java 1.2?
– Different event model
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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 20036
Webtechnoló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
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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 20037
Webtechnoló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ényfigyel
"
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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 20038
Webtechnológia 1
Java eseménykezelési
modellje (folyt.)
•
Delegációs esemény modell
•
esemény figyel
"
k használata
•
az objektum számára érdekes
események feldolgozása
•
Esemény bekövetkeztekor
•
GUI komponens értesíti a
figyel
"
ket
•
figyel
"
meghívja az
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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 20039
Webtechnoló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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200310
Webtechnoló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
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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200311
Webtechnoló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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200312
Webtechnológia 1
Swing osztályok
JComponent
JTextComponent
AbstractButton
JComboBox
JLabel
JList
JMenuBar
JPane
JPopupMenu
JScrollbar
JScrollPane
JTable
JTree
JToggleButton
JButton
JMenuItem
JCheckBox
JRadioButton
JRadioButtonMenuItem
JCheckBoxMenuItem
Container
Component
Object
JPanel
JApplet
Applet
Panel
JMenu
Font
Color
JTextArea
JTextField
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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200313
Webtechnológia 1
Swing GUI
komponensek
Demo program 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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200314
Webtechnológia 1
Layout kezelé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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200315
Webtechnológia 1
Border layout
public class TestBorderLayout extends JApplet {
public void init() {
Container guiContainer = getContentPane();
Font big = new Font("SansSerif", Font.BOLD, 20);
JButton buttonOne = new JButton("1");
buttonOne.setFont(big);
guiContainer.add(buttonOne, BorderLayout.WEST);
JButton buttonTwo = new JButton("2");
buttonTwo.setFont(big);
guiContainer.add(buttonTwo, BorderLayout.CENTER);
JButton buttonThree = new JButton("3");
buttonThree.setFont(big);
guiContainer.add(buttonThree, BorderLayout.EAST);
JButton buttonFour = new JButton("4");
buttonFour.setFont(big);
guiContainer.add(buttonFour, BorderLayout.NORTH);
JButton buttonFive = new JButton("5");
buttonFive.setFont(big);
guiContainer.add(buttonFive, BorderLayout.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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200316
Webtechnológia 1
GridLayout
public class TestGridLayout extends JApplet {
private JTextField name = new JTextField(15);
private JTextField address = new JTextField(15);
private JTextField phone = new JTextField(15);
private JTextField eMail = new JTextField(15);
public void init() {
Container guiContainer = getContentPane();
guiContainer.setLayout(new GridLayout(4, 2, 5, 5));
JLabel label = new JLabel("Name:", JLabel.RIGHT);
guiContainer.add(label);
guiContainer.add(name);
label = new JLabel("Address:", JLabel.RIGHT);
guiContainer.add(label);
guiContainer.add(address);
label = new JLabel("Phone:", JLabel.RIGHT);
guiContainer.add(label);
guiContainer.add(phone);
label = new JLabel("E-mail:", JLabel.RIGHT);
guiContainer.add(label);
guiContainer.add(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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200317
Webtechnoló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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200318
Webtechnoló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
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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200319
Webtechnoló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 fixed 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.fill = 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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 2003THE 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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200321
Webtechnoló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="HelloWorld.class" codebase="examples/" archive="helloWorld.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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200322
Webtechnoló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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200323
Webtechnológia 1
Appletek (folyt.)
•
grafikus 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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200324
Webtechnológia 1
Applet
életciklus
The applet is stopped,
the user has left the
Web 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.
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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200325
Webtechnoló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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200326
Webtechnoló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
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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200327
Webtechnoló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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200328
Webtechnoló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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200329
Webtechnoló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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200330
Webtechnoló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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200331
Webtechnoló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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200332
Webtechnológia 1
A homokozó
•
browser security policy
•
SecurityManager
•
SecurityException
•
korlátozások
•
An applet cannot load libraries or define native methods.
•
It cannot ordinarily read or write files 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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200333
Webtechnoló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 file 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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200334
Webtechnoló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
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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200335
Webtechnoló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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200336
Webtechnoló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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200337
Webtechnoló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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200338
Webtechnoló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
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 about100,000others, using like colors for similar Web addresses.
a
-Scientistshave recently discoveredthat variouscomplexsystemshave
antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$ha
red organili ng principies.
Thisinsight
has important impli~ationsfor a
hostof
applications,from drugdevelopmentto Internet security
BYALBERT-U\SZLO
BARABASI
ANDERICBONABEAU
50
SCIENTIFIC AMERICAN MAY 200339
Webtechnoló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 about100,000others, using like colors for similar Web addresses.