Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-06-2009, 04:32 PM
Member
 
Join Date: Jul 2009
Location: Rotterdam
Posts: 8
Rep Power: 0
Tucan is on a distinguished road
Send a message via Yahoo to Tucan
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
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-06-2009, 04:33 PM
RamyaSivakanth's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Chennai
Posts: 532
Rep Power: 1
RamyaSivakanth is on a distinguished road
Default
Its a typo error from ur end.

the method should be actionPerformed(ActionEvent ae)
__________________
Ramya
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-07-2009, 02:08 PM
Member
 
Join Date: Jul 2009
Location: Rotterdam
Posts: 8
Rep Power: 0
Tucan is on a distinguished road
Send a message via Yahoo to Tucan
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.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-07-2009, 02:12 PM
RamyaSivakanth's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Chennai
Posts: 532
Rep Power: 1
RamyaSivakanth is on a distinguished road
Default
method name is "actionPerformed".U have typed as "ActionerPerformed"
__________________
Ramya
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-07-2009, 03:44 PM
Member
 
Join Date: Jul 2009
Location: Rotterdam
Posts: 8
Rep Power: 0
Tucan is on a distinguished road
Send a message via Yahoo to Tucan
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
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 07-07-2009, 04:23 PM
RamyaSivakanth's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Chennai
Posts: 532
Rep Power: 1
RamyaSivakanth is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 07-07-2009, 04:24 PM
RamyaSivakanth's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Chennai
Posts: 532
Rep Power: 1
RamyaSivakanth is on a distinguished road
Default
Hi,
How many times u type wrongly and ask for suiggestion.Gothru this...


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 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
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 07-07-2009, 06:02 PM
Member
 
Join Date: Jul 2009
Location: Rotterdam
Posts: 8
Rep Power: 0
Tucan is on a distinguished road
Send a message via Yahoo to Tucan
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.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
E:\IT 215 Java Programming\public class Inventory.java:39: class, interface, or enum tlouvierre New To Java 14 05-28-2009 06:44 AM
problem with integration of a applet class JuliaS85 Java Applets 0 03-27-2009 05:32 PM
Multiple class applet lordbob75 Java Applets 5 01-08-2009 02:22 AM
What're the differences between JSP, Java Script, and Java Applet? meili100 New To Java 3 07-23-2008 09:07 AM
class.java to class.exe f_the_cook New To Java 11 07-16-2008 03:24 PM


All times are GMT +2. The time now is 12:28 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org