Saturday, March 8, 2014

Problem with actionperformed callback
































































































































































































































































I tried to create function, what shows textdialog, when client press the buton, but the problem is that i have defined frame under public static void main and in ActionPerformed callback first parameter "frame" is undefined. How could i fix this?
































































































































































































































































import java.awt.*;































































































































































































































































import java.awt.event.*;































































































































































































































































import java.applet.Applet;































































































































































































































































import javax.swing.*;































































































































public class Vestlus extends Applet implements ActionListener {































































































































































































































































TextField tf = new TextField("");































































































































































































































































Button nupp = new Button(" Sisesta ");
































































































































































































































































public Vestlus()































































































































































































































































{































































































































































































































































add(tf);































































































































































































































































add(nupp);































































































































































































































































nupp.addActionListener(this);
































































































































































































































































}































































































































































































































































public void actionPerformed(ActionEvent e)































































































































































































































































{































































































































































































































































if(e.getSource() == nupp)































































































































































































































































{































































































































































































































































JOptionPane.showMessageDialog(frame,"Hoiatus","Vää rtused ei klapi!", JOptionPane.INFORMATION_MESSAGE);
































































































































































































































































}































































































































































































































































}































































































































































































































































public static void main(String args[])































































































































































































































































{
































































































































































































































































JFrame frame = new JFrame("Project LA");































































































































































































































































frame.add(new Vestlus());































































































































































































































































frame.setSize(300,200);































































































































































































































































frame.setVisible(true);































































































































































































































































frame.setDefaultCloseOperation(1);
































































































































































































































































}
































































































































































































































































}































































































































































































































































































































































































































































































































































































































































No comments:

Post a Comment