pineappelle
11-19-2011, 03:19 AM
i have this code
/**
* @(#)circle.java
*
* circle Applet application
*
* @author
* @version 1.00 2011/11/18
*/
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class circle extends java.applet.Applet implements AdjustmentListener,ItemListener,ActionListener {
Graphics screen;
Scrollbar width, height, red, green, blue, xcord, ycord;
Label widthL, heightL, redL, greenL, blueL, outlineL, xcordL, ycordL;
int widthI, heightI, redI, greenI, blueI, xcordI, ycordI;
Checkbox outline;
Button dance;
Color clr;
String yon,danceS;
public void init() {
setLayout(null);
width=new Scrollbar(0,105,1,10,210);
height=new Scrollbar(0,105,1,10,210);
red=new Scrollbar(0,255,1,0,255);
green=new Scrollbar(0,0,1,0,255);
blue=new Scrollbar(0,255,1,0,255);
widthL=new Label("Width");
heightL=new Label("Height");
redL=new Label("Red");
greenL=new Label("Green");
blueL=new Label("Blue");
outline=new Checkbox("",null,false);
outlineL=new Label("Outline");
xcord=new Scrollbar(0,0,1,200,400);
ycord=new Scrollbar(0,0,1,200,400);
xcordL=new Label("X");
ycordL=new Label("Y");
dance=new Button("Dance!");
heightL.setBounds(10,10,50,20);
widthL.setBounds(10,40,50,20);
height.setBounds(70,10,200,20);
width.setBounds(70,40,200,20);
redL.setBounds(280,10,50,20);
greenL.setBounds(280,40,50,20);
blueL.setBounds(280,70,50,20);
red.setBounds(340,10,200,20);
green.setBounds(340,40,200,20);
blue.setBounds(340,70,200,20);
outline.setBounds(610,10,20,20);
outlineL.setBounds(550,10,50,20);
xcordL.setBounds(10,70,50,20);
ycordL.setBounds(10,100,50,20);
xcord.setBounds(70,70,200,20);
ycord.setBounds(70,100,200,20);
dance.setBounds(550,40,50,20);
height.addAdjustmentListener(this);
width.addAdjustmentListener(this);
red.addAdjustmentListener(this);
green.addAdjustmentListener(this);
blue.addAdjustmentListener(this);
outline.addItemListener(this);
xcord.addAdjustmentListener(this);
ycord.addAdjustmentListener(this);
dance.addActionListener(this);
add(height);
add(width);
add(heightL);
add(widthL);
add(red);
add(green);
add(blue);
add(redL);
add(greenL);
add(blueL);
add(outline);
add(outlineL);
add(xcord);
add(ycord);
add(xcordL);
add(ycordL);
add(dance);
}
public void adjustmentValueChanged(AdjustmentEvent event) {
height.getValue();
width.getValue();
red.getValue();
green.getValue();
blue.getValue();
xcord.getValue();
ycord.getValue();
heightI=height.getValue();
widthI=width.getValue();
redI=red.getValue();
greenI=green.getValue();
blueI=blue.getValue();
xcordI=xcord.getValue();
ycordI=ycord.getValue();
repaint();
}
public void itemStateChanged(ItemEvent event) {
if (outline.getState()==true) {
yon="yes";
}
else if (outline.getState()==false) {
yon="no";
}
repaint();
}
public void actionPerformed(ActionEvent event) {
danceS="dance";
}
public void paint(Graphics screen) {
height.getValue();
width.getValue();
red.getValue();
green.getValue();
blue.getValue();
xcord.getValue();
ycord.getValue();
heightI=height.getValue();
widthI=width.getValue();
redI=red.getValue();
greenI=green.getValue();
blueI=blue.getValue();
xcordI=xcord.getValue();
ycordI=ycord.getValue();
clr=new Color(redI,greenI,blueI);
screen.setColor(clr);
screen.fillOval(xcordI,ycordI,(widthI+1),(heightI+1));
screen.setColor(Color.black);
if (yon=="yes") {
screen.drawOval(xcordI,ycordI,widthI,heightI);
}
else {
}
if(danceS=="dance") {
xcord.setValue(200);
ycord.setValue(200);
for (int dummy=1;dummy<10;dummy=dummy+1){
}
xcord.setValue(400);
ycord.setValue(200);
for (int dummy=1;dummy<10;dummy=dummy+1){
}
xcord.setValue(400);
ycord.setValue(400);
for (int dummy=1;dummy<10;dummy=dummy+1){
}
xcord.setValue(200);
ycord.setValue(400);
for (int dummy=1;dummy<10;dummy=dummy+1){
}
xcord.setValue(200);
ycord.setValue(200);
danceS="nodance";
}
else {
}
}
}
and i want to make the circle dance. but the code that i have isnt working. can someone tell me why?
/**
* @(#)circle.java
*
* circle Applet application
*
* @author
* @version 1.00 2011/11/18
*/
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class circle extends java.applet.Applet implements AdjustmentListener,ItemListener,ActionListener {
Graphics screen;
Scrollbar width, height, red, green, blue, xcord, ycord;
Label widthL, heightL, redL, greenL, blueL, outlineL, xcordL, ycordL;
int widthI, heightI, redI, greenI, blueI, xcordI, ycordI;
Checkbox outline;
Button dance;
Color clr;
String yon,danceS;
public void init() {
setLayout(null);
width=new Scrollbar(0,105,1,10,210);
height=new Scrollbar(0,105,1,10,210);
red=new Scrollbar(0,255,1,0,255);
green=new Scrollbar(0,0,1,0,255);
blue=new Scrollbar(0,255,1,0,255);
widthL=new Label("Width");
heightL=new Label("Height");
redL=new Label("Red");
greenL=new Label("Green");
blueL=new Label("Blue");
outline=new Checkbox("",null,false);
outlineL=new Label("Outline");
xcord=new Scrollbar(0,0,1,200,400);
ycord=new Scrollbar(0,0,1,200,400);
xcordL=new Label("X");
ycordL=new Label("Y");
dance=new Button("Dance!");
heightL.setBounds(10,10,50,20);
widthL.setBounds(10,40,50,20);
height.setBounds(70,10,200,20);
width.setBounds(70,40,200,20);
redL.setBounds(280,10,50,20);
greenL.setBounds(280,40,50,20);
blueL.setBounds(280,70,50,20);
red.setBounds(340,10,200,20);
green.setBounds(340,40,200,20);
blue.setBounds(340,70,200,20);
outline.setBounds(610,10,20,20);
outlineL.setBounds(550,10,50,20);
xcordL.setBounds(10,70,50,20);
ycordL.setBounds(10,100,50,20);
xcord.setBounds(70,70,200,20);
ycord.setBounds(70,100,200,20);
dance.setBounds(550,40,50,20);
height.addAdjustmentListener(this);
width.addAdjustmentListener(this);
red.addAdjustmentListener(this);
green.addAdjustmentListener(this);
blue.addAdjustmentListener(this);
outline.addItemListener(this);
xcord.addAdjustmentListener(this);
ycord.addAdjustmentListener(this);
dance.addActionListener(this);
add(height);
add(width);
add(heightL);
add(widthL);
add(red);
add(green);
add(blue);
add(redL);
add(greenL);
add(blueL);
add(outline);
add(outlineL);
add(xcord);
add(ycord);
add(xcordL);
add(ycordL);
add(dance);
}
public void adjustmentValueChanged(AdjustmentEvent event) {
height.getValue();
width.getValue();
red.getValue();
green.getValue();
blue.getValue();
xcord.getValue();
ycord.getValue();
heightI=height.getValue();
widthI=width.getValue();
redI=red.getValue();
greenI=green.getValue();
blueI=blue.getValue();
xcordI=xcord.getValue();
ycordI=ycord.getValue();
repaint();
}
public void itemStateChanged(ItemEvent event) {
if (outline.getState()==true) {
yon="yes";
}
else if (outline.getState()==false) {
yon="no";
}
repaint();
}
public void actionPerformed(ActionEvent event) {
danceS="dance";
}
public void paint(Graphics screen) {
height.getValue();
width.getValue();
red.getValue();
green.getValue();
blue.getValue();
xcord.getValue();
ycord.getValue();
heightI=height.getValue();
widthI=width.getValue();
redI=red.getValue();
greenI=green.getValue();
blueI=blue.getValue();
xcordI=xcord.getValue();
ycordI=ycord.getValue();
clr=new Color(redI,greenI,blueI);
screen.setColor(clr);
screen.fillOval(xcordI,ycordI,(widthI+1),(heightI+1));
screen.setColor(Color.black);
if (yon=="yes") {
screen.drawOval(xcordI,ycordI,widthI,heightI);
}
else {
}
if(danceS=="dance") {
xcord.setValue(200);
ycord.setValue(200);
for (int dummy=1;dummy<10;dummy=dummy+1){
}
xcord.setValue(400);
ycord.setValue(200);
for (int dummy=1;dummy<10;dummy=dummy+1){
}
xcord.setValue(400);
ycord.setValue(400);
for (int dummy=1;dummy<10;dummy=dummy+1){
}
xcord.setValue(200);
ycord.setValue(400);
for (int dummy=1;dummy<10;dummy=dummy+1){
}
xcord.setValue(200);
ycord.setValue(200);
danceS="nodance";
}
else {
}
}
}
and i want to make the circle dance. but the code that i have isnt working. can someone tell me why?