Skip to main content
gamedev.net
🔒 Locked

[java] JApplet & ActionListener help

Started by Thoover Feb 24, 2007 at 8:12 PM 4 replies 2.4k views
Original Post
Thoover
Thoover
No mater what i do, i get an error, i went from 2 errors, i fixed them now i got 12 errors that i cant see how it errors, here is my code so far:

import java.applet.AudioClip;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;

public class mainpage extends JApplet implements ActionListener
{
 public void init()
 {
  bg="main.jpg";
  log="login.jpg";
  neu="new.jpg";
 }
 public void paint(Graphics artist)
 {
  Image photo = getImage( getCodeBase(), bg);
  artist.drawImage(photo, 0, 0,this);
  Image lgi = getImage( getCodeBase(), loh);
  lgi.addActionListener(this);
  artist.drawImage(lgi, 100,100,this);
  Image nur = getImage( getCodeBase(), neu);
  nur.addActionListener(this);
  artist.drawImage(nur, 200,100,this);
 }
 public void actionPreformed(ActionEvent e)
 {
  if(e.getActionCommand() == lgi) new userslog();
  if(e.getActionCommand() == nur) new usersneu();
 }
}


class userslog extends JApplet
{
 public void log(Graphics artist)
 {
  Image p = getImage( getCodeBase(), "main.jpg");
  artist.drawImage(p, 0, 0,this); 
 }
}

class usersneu extends JApplet
{
 public void log(Graphics artist)
 {
  Image p = getImage( getCodeBase(), "main.jpg");
  artist.drawImage(p, 0, 0,this); 
 }
}



here is the error log:

mainpage.java:7: mainpage is not abstract and does not override abstract meth
actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
public class mainpage extends JApplet implements ActionListener
       ^
mainpage.java:11: cannot find symbol
symbol  : variable bg
location: class mainpage
  bg="main.jpg";
  ^
mainpage.java:12: log has private access in java.awt.Component
  log="login.jpg";
  ^
mainpage.java:12: incompatible types
found   : java.lang.String
required: java.util.logging.Logger
  log="login.jpg";
      ^
mainpage.java:13: cannot find symbol
symbol  : variable neu
location: class mainpage
  neu="new.jpg";
  ^
mainpage.java:17: cannot find symbol
symbol  : variable bg
location: class mainpage
  Image photo = getImage( getCodeBase(), bg);
                                         ^
mainpage.java:19: cannot find symbol
symbol  : variable loh
location: class mainpage
  Image lgi = getImage( getCodeBase(), loh);
                                       ^
mainpage.java:20: cannot find symbol
symbol  : method addActionListener(mainpage)
location: class java.awt.Image
  lgi.addActionListener(this);
     ^
mainpage.java:22: cannot find symbol
symbol  : variable neu
location: class mainpage
  Image nur = getImage( getCodeBase(), neu);
                                       ^
mainpage.java:23: cannot find symbol
symbol  : method addActionListener(mainpage)
location: class java.awt.Image
  nur.addActionListener(this);
     ^
mainpage.java:28: cannot find symbol
symbol  : variable lgi
location: class mainpage
  if(e.getActionCommand() == lgi) new userslog();
                             ^
mainpage.java:29: cannot find symbol
symbol  : variable nur
location: class mainpage
  if(e.getActionCommand() == nur) new usersneu();
                             ^
12 errors


can any one tell me exactly what is wrong, it all worked perfictly before the action listener was in it, then it went one error after another. thanks in advance - thoover
Alpha_ProgDes
Alpha_ProgDes
no. i mean what data types are:
bg    //you have variables that have no data typelog   //same herenew   //and here
?
Beginner in Game Development?  Read here. And read here.  
Thoover
Thoover
oh, they are strings, i put string bg,log,neu; in and i now have only 7 errors:
mainpage.java:9: cannot find symbolsymbol  : class stringlocation: class mainpage string bg,log,neu; ^mainpage.java:7: mainpage is not abstract and does not override abstract methodactionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListenerpublic class mainpage extends JApplet implements ActionListener       ^mainpage.java:20: cannot find symbolsymbol  : variable lohlocation: class mainpage  Image lgi = getImage( getCodeBase(), loh);                                       ^mainpage.java:21: cannot find symbolsymbol  : method addActionListener(mainpage)location: class java.awt.Image  lgi.addActionListener(this);     ^mainpage.java:24: cannot find symbolsymbol  : method addActionListener(mainpage)location: class java.awt.Image  nur.addActionListener(this);     ^mainpage.java:29: cannot find symbolsymbol  : variable lgilocation: class mainpage  if(e.getActionCommand() == lgi) new userslog();                             ^mainpage.java:30: cannot find symbolsymbol  : variable nurlocation: class mainpage  if(e.getActionCommand() == nur) new usersneu();                             ^7 errors

i still get errors, so that cant be the only problem

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.