Results 1 to 8 of 8
  1. #1
    Tucan is offline Member
    Join Date
    Jul 2009
    Location
    Rotterdam
    Posts
    8
    Rep Power
    0

    Unhappy class problen with java Applet

    On complilation I am givven: JDemoCteateGraphicsObject3 is not abstract and does not override abstract method actionPreformed (java.awt.event.ActionEvent) in java.awt.event.ActionListener.

    Code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;

    public class JDemoCreateGraphicsObject3 extends JApplet implements ActionListener
    {
    String companyName = new String("Event Handlers Incorperated ");
    JButton moveButton = new JButton("Move it ");
    Font helv12Font = new Font("Helvetica ", Font.ITALIC, 12);
    int x = 10, y = 50;

    public void init ()
    {
    setBackground(Color.YELLOW);
    Container con = getContentPane();
    con.setLayout(new FlowLayout() );
    con.add(moveButton);
    moveButton.addActionListener(this);
    }
    public void ActionerPerformed(ActionEvent e)
    {
    Object source = e.getSource();
    if (source == moveButton)
    {
    Graphics pen = getGraphics();
    pen.setFont(helv12Font);
    pen.setColor(Color.MAGENTA);
    if(x <250)
    pen.drawString(companyName, x +=20, y += 20);
    else
    moveButton.setEnabled(false);
    pen.setColor(Color.BLACK);
    pen.drawOval(50, 170, 70, 70);
    pen.drawLine(85, 240, 110, 300);
    pen.drawOval(100, 170, 70, 70);

    }//end if
    }//end actionPreformed()
    }//end JDemoCreateGraphicsObject class

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    828
    Rep Power
    6

    Default

    Its a typo error from ur end.

    the method should be actionPerformed(ActionEvent ae)
    Ramya:cool:

  3. #3
    Tucan is offline Member
    Join Date
    Jul 2009
    Location
    Rotterdam
    Posts
    8
    Rep Power
    0

    Unhappy class problem with java Applet

    Dear Ramya,
    I have changed the actionEvent a to (ae) but it makes no difference. I got the sme results as stated at the begining of my Thread. Sorry, but it did not work.
    Thanks,
    Tucan.

  4. #4
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    828
    Rep Power
    6

    Default

    method name is "actionPerformed".U have typed as "ActionerPerformed"
    Ramya:cool:

  5. #5
    Tucan is offline Member
    Join Date
    Jul 2009
    Location
    Rotterdam
    Posts
    8
    Rep Power
    0

    Unhappy Class proplem with javaApplet

    Dear Ramya,
    Thanks for your patience and effort but, I am having the same results. The software I am using is jGrasp. When I compile I am getting the message at the beginning of my thread. When I run the Applet for current file ,I get the message " Class does not appear to be an Applet " Continue anyway? I press Continue and the Applet viewer appears but,empty. While I should be seeing the company name move to x-coordinate 250, before the JButton is disabled,and the balloon drawing appears. I have done some modification on the first code so, note the difference:

    code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;

    public class JDemoCreateGraphicsObject3 extends JApplet implements ActionListener
    {
    String companyName = new String("Event Handlers Incorperated ");
    JButton moveButton = new JButton("Move it ");
    Font helv12Font = new Font("Helvetica ", Font.ITALIC, 12);
    int x = 10, y = 50;

    public void init ()
    {
    setBackground(Color.YELLOW);
    Container con = getContentPane();
    con.setLayout(new FlowLayout() );
    con.add(moveButton);
    moveButton.addActionListener(this);
    }
    public void actionerPerformed(ActionEvent ae)
    {
    Object source = ae.getSource();
    if (source == moveButton)
    {
    Graphics pen = getGraphics();
    pen.setFont(helv12Font);
    pen.setColor(Color.MAGENTA);
    if(x < 250)
    {
    pen.drawString(companyName, x+=20, y+= 20);
    }
    else
    {
    moveButton.setEnabled(false);
    pen.setColor(Color.BLACK);
    pen.drawOval(50, 170, 70, 70);
    pen.drawLine(85, 240, 110, 300);
    pen.drawOval(100, 170, 70, 70);

    }

    }

    }
    }

    Any other sujjestions will be welcome please.
    Thanking you in anticipation,
    Tucan

  6. #6
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    828
    Rep Power
    6

    Default

    Hi,
    How many times u type wrongly and ask for suiggestion.Gothru this...


    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;

    public class JDemoCreateGraphicsObject3 extends JApplet implements ActionListener
    {
    String companyName = new String("Event Handlers Incorperated ");
    JButton moveButton = new JButton("Move it ");
    Font helv12Font = new Font("Helvetica ", Font.ITALIC, 12);
    int x = 10, y = 50;

    public void init ()
    {
    setBackground(Color.YELLOW);
    Container con = getContentPane();
    con.setLayout(new FlowLayout() );
    con.add(moveButton);
    moveButton.addActionListener(this);
    }
    public void actionPerformed(ActionEvent ae)
    {
    Object source = ae.getSource();
    if (source == moveButton)
    {
    Graphics pen = getGraphics();
    pen.setFont(helv12Font);
    pen.setColor(Color.MAGENTA);
    if(x < 250)
    {
    pen.drawString(companyName, x+=20, y+= 20);
    }
    else
    {
    moveButton.setEnabled(false);
    pen.setColor(Color.BLACK);
    pen.drawOval(50, 170, 70, 70);
    pen.drawLine(85, 240, 110, 300);
    pen.drawOval(100, 170, 70, 70);

    }

    }

    }
    }
    Ramya:cool:

  7. #7
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    828
    Rep Power
    6

    Default

    Hi,
    How many times u type wrongly and ask for suiggestion.Gothru this...


    Java Code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    
    public class JDemoCreateGraphicsObject3 extends JApplet implements ActionListener
    {
    String companyName = new String("Event Handlers Incorperated ");
    JButton moveButton = new JButton("Move it ");
    Font helv12Font = new Font("Helvetica ", Font.ITALIC, 12);
    int x = 10, y = 50;
    
    public void init ()
    {
    setBackground(Color.YELLOW);
    Container con = getContentPane();
    con.setLayout(new FlowLayout() );
    con.add(moveButton);
    moveButton.addActionListener(this);
    }
    public void [B]actionPerformed[/B](ActionEvent ae)
    {
    Object source = ae.getSource();
    if (source == moveButton)
    {
    Graphics pen = getGraphics();
    pen.setFont(helv12Font);
    pen.setColor(Color.MAGENTA);
    if(x < 250)
    {
    pen.drawString(companyName, x+=20, y+= 20);
    }
    else
    {
    moveButton.setEnabled(false);
    pen.setColor(Color.BLACK);
    pen.drawOval(50, 170, 70, 70);
    pen.drawLine(85, 240, 110, 300);
    pen.drawOval(100, 170, 70, 70);
    
    }
    
    }
    
    }
    }
    Ramya:cool:

  8. #8
    Tucan is offline Member
    Join Date
    Jul 2009
    Location
    Rotterdam
    Posts
    8
    Rep Power
    0

    Thumbs up Class problem with java Applet

    Dear Ramya,
    Thanks a lot, your last example was the best. It solved the " Problem ". Thanks again. I am very sorry, I will try my best to be more accurate in future.
    Thanks,
    Tucan.

Similar Threads

  1. Replies: 14
    Last Post: 05-28-2009, 05:44 AM
  2. problem with integration of a applet class
    By JuliaS85 in forum Java Applets
    Replies: 0
    Last Post: 03-27-2009, 04:32 PM
  3. Multiple class applet
    By lordbob75 in forum Java Applets
    Replies: 5
    Last Post: 01-08-2009, 01:22 AM
  4. Replies: 3
    Last Post: 07-23-2008, 08:07 AM
  5. class.java to class.exe
    By f_the_cook in forum New To Java
    Replies: 11
    Last Post: 07-16-2008, 02:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •