Diego_Armando
01-06-2004, 14:06
Ciao!
AIUTOOOOOO!!!!
Ma dov'è l'errore? a me sembra tutt ok..
E' un semplicissimo programma che sfrutta le API AWT..per creare un bottone. Una volta premuto dovrebbe stampare "Grazie"..
Ecco il codice:
import java.awt.*;
import java.awt.event.*;
class ButtonFrame extends Frame implements ActionListener
{ Button button;
ButtonFrame(String s);
{ super(s);
setSize(250,100);
setLayout(new Flowlayout());
button = new Button("Fare clic");
add(button);
button.addActionListener(this);
setVisible(true);
}
public void actionPerformed(ActionEvent event)
{ if (event.getActionCommand().equals("Fare clic")) System.out.println("Grazie");
}
}
class Test2
{
public static void main(String[] args)
{ ButtonFrame buttonFrame = new ButtonFrame("Esempio");
}
}
______________________________________
E l'errore è:
C:\jena>javac Test2.java
Test2.java:6: missing method body, or declare abstract
ButtonFrame(String s);
^
Test2.java:7: call to super must be first statement in constructor
{ super(s);
^
Test2.java:9: cannot resolve symbol
symbol : class Flowlayout
location: class ButtonFrame
setLayout(new Flowlayout());
^
3 errors
:muro: :muro: :muro:
AIUTOOOOOO!!!!
Ma dov'è l'errore? a me sembra tutt ok..
E' un semplicissimo programma che sfrutta le API AWT..per creare un bottone. Una volta premuto dovrebbe stampare "Grazie"..
Ecco il codice:
import java.awt.*;
import java.awt.event.*;
class ButtonFrame extends Frame implements ActionListener
{ Button button;
ButtonFrame(String s);
{ super(s);
setSize(250,100);
setLayout(new Flowlayout());
button = new Button("Fare clic");
add(button);
button.addActionListener(this);
setVisible(true);
}
public void actionPerformed(ActionEvent event)
{ if (event.getActionCommand().equals("Fare clic")) System.out.println("Grazie");
}
}
class Test2
{
public static void main(String[] args)
{ ButtonFrame buttonFrame = new ButtonFrame("Esempio");
}
}
______________________________________
E l'errore è:
C:\jena>javac Test2.java
Test2.java:6: missing method body, or declare abstract
ButtonFrame(String s);
^
Test2.java:7: call to super must be first statement in constructor
{ super(s);
^
Test2.java:9: cannot resolve symbol
symbol : class Flowlayout
location: class ButtonFrame
setLayout(new Flowlayout());
^
3 errors
:muro: :muro: :muro: