Skip to content

Instantly share code, notes, and snippets.

@octopuscabbage
Created May 8, 2013 15:44
Show Gist options
  • Save octopuscabbage/5541346 to your computer and use it in GitHub Desktop.
Save octopuscabbage/5541346 to your computer and use it in GitHub Desktop.
Main file
/**
* @(#)Main.java
*
*
* @author
* @version 1.00 2013/4/25
*/
import java.awt.*;
import java.applet.Applet;
public class Main extends java.applet.Applet {
Graphics g;
Colors color = new Colors();
int numTool = 1;
//1
Pen pen = new Pen(g);
//2
//Eraser eraser;
//3
//Paintbrush paintBrush;
//4
// Roller roller;
//5
//Line line = new Line();
//6
//Circle circle;
//7
//Rectangle rectangle;
//8
//Oval oval;
//9
//Colorpage colorPage;
//10
//Eraseall eraseAll;
public void paint(Graphics g) {
g = g
Toolbar tool = new Toolbar(g);
tool.display(g);
ColorToolbar.draw(g);
tools(g);
}
public void update(Graphics g){
}
public boolean mouseDrag(Event e, int x, int y, Graphics g){
if((x>85 && x < 1000) && (y>0 && y <600)){
switch(numTool){
case 1: pen.paint(g,x,y,color);
}
}
return true;
}
public boolean mouseUp( Event e, int x, int y){
return true;
}
public boolean mouseDown(Event e, int x, int y){
//Add MouseEvents Here
int numColor;
if((x > 15 && x< 45)&&(y>15 && y <45)){
numTool = 1; //Pen
}
if((x > 55 && x < 85)&&(y>15 && y<45)){
numTool = 2; //Eraser
}
if((x > 15 && x < 45)&&(y>55 && y < 85)){
numTool = 3; //Paint Brush
}
if((x > 55 && x < 85)&&(y > 55 && y < 85)){
numTool = 4; //roller
}
if((x > 15 && x < 45)&&(y > 95 && y < 125)){
numTool = 5; //line
}
if((x > 55 && x < 85)&&(y >85 && y < 125)){
numTool = 6; //circle
}
if((x > 15 && x < 45)&&(y > 135 && y < 165)){
numTool = 7; //rectangle
}
if((x > 55 && x < 85)&&(y > 135 && y < 165)){
numTool = 8; //oval
}
if((x > 15 && x < 45)&&(y > 175 && y < 205)){
numTool = 9; //colorPage
}
if((x > 55 && x < 85)&&(y > 175 && y < 205)){
numTool = 10; //eraseAll
}
return true;
}
Image ClearImage, EraserImage, RollerImage, BrushImage, PenImage, windowColorImage, CircleImage, LineImage, RectImage, OvalImage;
public void init()
{
ClearImage = getImage(getDocumentBase(),"cleartool.jpg");
EraserImage = getImage(getDocumentBase(),"Eraser.jpg");
RollerImage = getImage(getDocumentBase(),"Paintroller.jpg");
PenImage = getImage(getDocumentBase(),"pen.jpg");
windowColorImage = getImage(getDocumentBase(),"windowscolortool.jpg");
BrushImage = getImage(getDocumentBase(),"Paintbrush.jpg");
CircleImage = getImage(getDocumentBase(),"Circletool.jpg");
LineImage = getImage(getDocumentBase(),"Linetool.jpg");
OvalImage = getImage(getDocumentBase(),"Ovaltool.jpg");
RectImage = getImage(getDocumentBase(),"Rectangletool.jpg");
}
public void tools(Graphics g)
{
g.drawImage(PenImage,15,15,this);
g.drawImage(EraserImage,55,15,this);
g.drawImage(BrushImage,15,55,this);
g.drawImage(RollerImage,55,55,this);
g.drawImage(LineImage,15,95,this);
g.drawImage(CircleImage,55,95,this);
g.drawImage(RectImage,15,135,this);
g.drawImage(OvalImage,55,135,this);
g.drawImage(windowColorImage,15,175,this);
g.drawImage(ClearImage,55,175,this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment