Salve ragazzi,sono nuovo di questo forum! io ho da fare la consegna di questo programma...nn sono riuscito a continuare perchè mi da questo errore alla riga 76: "non-static method Ctrl() cannot be referenced from a static context data.Ctrl();" come posso fare?? Incollo il codice del programma:
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
class GestoreFinestra implements WindowListener
{
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}
public void windowClosing(WindowEvent e)
{
System.out.println("Programma terminato...");
System.exit(0);
}
}
public class ConvertFrame extends JFrame implements ActionListener
{
public JPanel p1 = new JPanel();
public JPanel p2 = new JPanel();
public JTextField data1 = new JTextField(15);
public JTextField data2 = new JTextField(15);
public JButton confronta = new JButton("Confronto date");
public JButton festa = new JButton("Controllo festività");
public JButton exit = new JButton("Uscita");
public JButton giorno = new JButton("Stabilisci giorno");
public String prima,sec;
public int i,dim;
public ConvertFrame()
{
super("...Bondavalli Roberto... GESTIONE CLASSE DATA");
addWindowListener(new GestoreFinestra());
p1.add(new JLabel("1 DATA: "));
p1.add(data1);
p2.add(new JLabel("2 DATA: "));
p2.add(data2);
setLayout(new GridLayout(3,1,5,10));
add(p1);
add(p2);
add(confronta);
add(festa);
add(giorno);
add(exit);
confronta.addActionListener(this);
festa.addActionListener(this);
exit.addActionListener(this);
giorno.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
String bottone = e.getActionCommand();
if (e.getActionCommand()== "Uscita")
{
System.exit(0);
}
else
if (e.getActionCommand()== "Confronto date")
{
prima= data1.getText();
sec= data2.getText();
data.Ctrl();
}
}
public void main(String args[])
{
ConvertFrame f = new ConvertFrame();
f.pack();
f.setVisible(true);
}
class data
{
public void Ctrl()
{
dim= prima.length();
System.out.println("dim: "+dim);
}
}
}
<font color=red></font id=red><b></b>
grazie mille in anticipo..ma nn so come fare...