Solved

java painting applet

Posted on 2000-03-17
3
1,032 Views
Last Modified: 2013-11-23
Hello,
         can anyone help I am looking for a java applet that can be used by children in a educational site.

Is there any free applets that can be used to draw paint etc but very siimply with 1 color and brush size being able to change brushes and colors is not required. ie tha ability for kids to be able to draw in a thin pencil off white color on a black background is ideal.

best wishes from New zealand
0
Comment
Question by:wampy
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
loumf earned 150 total points
ID: 2630458
Here's source for something simple.
Draw with the mouse, erase by refreshing the page.  If you need the class file tell me your email and I'll send that and sample html

// DrawApplet
//

import java.awt.*;
import java.applet.*;
import java.util.*;


public class DrawApplet extends Applet
{
      public void init()
      {
      }

      public boolean mouseDown(Event e, int x, int y)
      {
            FDown = true;
            FX = x;
            FY = y;
            return true;
      }
      
      public boolean mouseUp(Event e, int x, int y)
      {
            FLines.addElement(new Rectangle(x,y, FX, FY));
            FDown = false;
            return true;
      }
      
      public boolean mouseDrag(Event e, int x, int y)
      {
            if (FDown) {
                  FLines.addElement(new Rectangle(x,y, FX, FY));
                  FX = x;
                  FY = y;
                  repaint(10);
            }
            return true;
      }      
      
      public void update(Graphics g)
    {
            Graphics gr;
               
            if (FOffScreenBuffer==null ||
                  (! (FOffScreenBuffer.getWidth(this) == this.size().width
                  && FOffScreenBuffer.getHeight(this) == this.size().height))) {
                  
                    FOffScreenBuffer = this.createImage(size().width, size().height);
            }

            // We need to use our buffer Image as a Graphics object:
            
            gr = FOffScreenBuffer.getGraphics();
            gr.clearRect(0,0,size().width, size().height);
            
            paint(gr);
            
            g.drawImage(FOffScreenBuffer, 0, 0, this);                  
    }

      
      public void paint(Graphics g)
      {
            g.setColor(Color.black);
            g.fillRect(0,0,getSize().width, getSize().height);
            g.setColor(Color.white);
            for (int i = 0; i < FLines.size(); ++i) {
                  Rectangle r = (Rectangle)FLines.elementAt(i);
                  g.drawLine(r.x, r.y, r.width, r.height);
            }
      }
      
      private boolean FDown = false;
      private int FX = 0;
      private int FY = 0;
      private Vector FLines = new Vector();
      private Image FOffScreenBuffer;
}
0
 

Author Comment

by:wampy
ID: 2630669
yes if you could please send applet and sample htm im off trying to figure a compiler my email is arrowtow@es.co.nz.

are you interested in custom applet jobs?

all the best Gerald.
0
 

Author Comment

by:wampy
ID: 2630733
ok thanks ive worked it out found a programme on my linux box  guavac that compiled it aok.

for 50 more points can you show me how to make a clear screen button.

many thanks gerald
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
The viewer will learn how to implement Singleton Design Pattern in Java.

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now