4 Replies - 358 Views - Last Post: 23 August 2009 - 09:46 PM Rate Topic: -----

#1 tastysoup  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 08-August 09

applet problem

Posted 22 August 2009 - 07:05 PM

Hi again!

Ok, this time I am trying to get an applet from our class text to run. I have checked it over and over and it is straight out of the text but when I compile I keep getting this error

cannot read JDemoPaint.java

Can somebody tell me what I'm doing wrong?

Thanks!


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

public class JDemoPaint extends JApplet

implements ActionListener

{
	public void init()
	{
		Container con = getContentPane();
		con.setLayout(new FlowLayout());
		con.add(pressButton);
		pressButton.addActionListener(this);
	}
	public void paint(Graphics g)

	{
		System.out.println("in paint method");
		pressButton.repaint();
	}
public void actionPerformed(ActionEvent e)
{
	Object source = e.getSource();
	if (source == pressButton)
	{
		repaint();
	}
}



Is This A Good Question/Topic? 0
  • +

Replies To: applet problem

#2 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3106
  • View blog
  • Posts: 19,145
  • Joined: 14-September 07

Re: applet problem

Posted 22 August 2009 - 07:08 PM

If you copy/pasted it directly, you're missing a bracket at the end.
Was This Post Helpful? 0
  • +
  • -

#3 tastysoup  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 08-August 09

Re: applet problem

Posted 22 August 2009 - 07:24 PM

Hey there,

Nope, I typed it in and I have gone over it to check several times. I am compiling like normal by typing javac JDemoPaint.java. Is this correct?



View PostKYA, on 22 Aug, 2009 - 06:08 PM, said:

If you copy/pasted it directly, you're missing a bracket at the end.

Was This Post Helpful? 0
  • +
  • -

#4 tastysoup  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 08-August 09

Re: applet problem

Posted 22 August 2009 - 07:44 PM

Never mind, I figured it out. I was in the wrong directory. I am really dumb and have been awake too long.

Thanks!

View Posttastysoup, on 22 Aug, 2009 - 06:24 PM, said:

Hey there,

Nope, I typed it in and I have gone over it to check several times. I am compiling like normal by typing javac JDemoPaint.java. Is this correct?



View PostKYA, on 22 Aug, 2009 - 06:08 PM, said:

If you copy/pasted it directly, you're missing a bracket at the end.

Was This Post Helpful? 0
  • +
  • -

#5 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8342
  • View blog
  • Posts: 31,880
  • Joined: 06-March 08

Re: applet problem

Posted 23 August 2009 - 09:46 PM

and pressButton is not defined
and you do not need to repaint() JComponent
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1