Solved

java painting applet

Posted on 2000-03-17
3
1,045 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What's wrong with this code? 4 46
jmss example java 2 48
Is Applet the way to go for my drag and drop system? 8 51
listing all the respondents to a twitter feed - Java 5 46
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

734 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