Results 1 to 8 of 8
Thread: class problen with java Applet
- 07-06-2009, 03:32 PM #1
Member
- Join Date
- Jul 2009
- Location
- Rotterdam
- Posts
- 8
- Rep Power
- 0
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
- 07-06-2009, 03:33 PM #2
Its a typo error from ur end.
the method should be actionPerformed(ActionEvent ae)Ramya:cool:
- 07-07-2009, 01:08 PM #3
Member
- Join Date
- Jul 2009
- Location
- Rotterdam
- Posts
- 8
- Rep Power
- 0
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.
- 07-07-2009, 01:12 PM #4
method name is "actionPerformed".U have typed as "ActionerPerformed"
Ramya:cool:
- 07-07-2009, 02:44 PM #5
Member
- Join Date
- Jul 2009
- Location
- Rotterdam
- Posts
- 8
- Rep Power
- 0
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
- 07-07-2009, 03:23 PM #6
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:
- 07-07-2009, 03:24 PM #7
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:
- 07-07-2009, 05:02 PM #8
Member
- Join Date
- Jul 2009
- Location
- Rotterdam
- Posts
- 8
- Rep Power
- 0
Similar Threads
-
E:\IT 215 Java Programming\public class Inventory.java:39: class, interface, or enum
By tlouvierre in forum New To JavaReplies: 14Last Post: 05-28-2009, 05:44 AM -
problem with integration of a applet class
By JuliaS85 in forum Java AppletsReplies: 0Last Post: 03-27-2009, 04:32 PM -
Multiple class applet
By lordbob75 in forum Java AppletsReplies: 5Last Post: 01-08-2009, 01:22 AM -
What're the differences between JSP, Java Script, and Java Applet?
By meili100 in forum New To JavaReplies: 3Last Post: 07-23-2008, 08:07 AM -
class.java to class.exe
By f_the_cook in forum New To JavaReplies: 11Last Post: 07-16-2008, 02:24 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks