/
Forside
/
Teknologi
/
Udvikling
/
Java
/
Nyhedsindlæg
Login
Brugernavn
*
Kodeord
*
Husk mig
Brugerservice
Kom godt i gang
Bliv medlem
Seneste indlæg
Stil et spørgsmål
Skriv et tip
Pointsystemet
Kontakt Kandu.dk
Emnevisning
Kategorier
Alfabetisk
Karriere
Interesser
Teknologi
Reklame
Top 10 brugere
Java
#
Navn
Point
1
molokyle
3688
2
Klaudi
855
3
strarup
740
4
Forvirret
660
5
gøgeungen
500
6
Teil
373
7
Stouenberg
360
8
vnc
360
9
pmbruun
341
10
mccracken
320
Instantiat Interface ??
Fra :
Mike T. Altun
Dato :
29-01-01 13:23
I have a question to Java. I hope you can answer me.
How can it be possible to instantiate an interface like this code below :
ActionListener al = new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
if (ae.getSource() == button1)
{
System.out.println("Button selected!");
}
else
if (ae.getSource() == text1)
{
String text2 = ((JTextField)ae.getSource()).getText();
String text3 = ae.getActionCommand();
System.out.println("Text from ActionEvent : " + text2);
System.out.println("Text from TextField : " + text3);
}
}
};
button1.addActionListener(al);
Thank You !
Lars Dam (
29-01-2001
)
Kommentar
Fra :
Lars Dam
Dato :
29-01-01 13:45
On Mon, 29 Jan 2001 13:22:31 +0100, "Mike T. Altun"
<Tuncay.love@worldonline.dk> wrote:
>I have a question to Java. I hope you can answer me.
>
>How can it be possible to instantiate an interface like this code below :
Part of the java specification. Read the docs 'Anonymous classes'.
>
>Thank You !
>
kr. ld
--
"Time is the fire in which we burn"
Ulrik Magnusson (
29-01-2001
)
Kommentar
Fra :
Ulrik Magnusson
Dato :
29-01-01 15:33
"Mike T. Altun" wrote:
> How can it be possible to instantiate an interface like this code below :
Because you are defining the (anonymous) class that implements the interface
in the very same statement.
Anonymous inner classes:
http://www.boisejug.org/tij2/Chapter08.html#Heading263
Ulrik Magnusson
--
"Look! Ducks in the lake"
'Agent Cooper' in Twin Peaks - Lynch, 1990
Visit my home page:
http://www.geocities.com/ulrikm
Søg
Alle emner
Teknologi
Udvikling
Java
Indstillinger
Spørgsmål
Tips
Usenet
Reklame
Statistik
Spørgsmål :
177822
Tips :
31980
Nyheder :
719565
Indlæg :
6410983
Brugere :
218912
Månedens bedste
Årets bedste
Sidste års bedste
Copyright © 2000-2026 kandu.dk. Alle rettigheder forbeholdes.