Sarah
Posts: 4
Nickname: mbonfyre
Registered: Mar, 2002
|
|
Re: if statements
|
Posted: Mar 21, 2002 1:36 PM
|
|
Here goes (please be gentle,but acurate with your critisims, I'm a newbie to java)
import java.applet.Applet; import java.awt.*; import java.awt.event.*;
public class try1abcd extends Applet implements AdjustmentListener { private private Panel bottomPanel;
private Scrollbar scrollX; private Scrollbar scrollY; private Scrollbar scrollBig; private Scrollbar scrollWide; int startX = 110; int startY = 170; int big = 80; int wide = 160;
public void init() {
scrollX = new Scrollbar(Scrollbar.HORIZONTAL,100,1,0,200); scrollY = new Scrollbar(Scrollbar.VERTICAL,100,1,0,200); add(scrollX); add(scrollY); scrollX.addAdjustmentListener(this); scrollY.addAdjustmentListener(this); scrollBig = new Scrollbar(Scrollbar.HORIZONTAL,50,1,0,200); scrollWide = new Scrollbar(Scrollbar.VERTICAL,100,1,0,200); add(scrollBig); add(scrollWide); scrollBig.addAdjustmentListener(this); scrollWide.addAdjustmentListener(this); setLayout(new BorderLayout() ); bottomPanel = new Panel(); add("South",bottomPanel); bottomPanel.setBackground(Color.yellow); bottomPanel.add(scrollX); bottomPanel. add(scrollY); bottomPanel.add(scrollBig); bottomPanel.add(scrollWide); }
public void adjustmentValueChanged(AdjustmentEvent e) { startX = scrollX.getValue(); startY = scrollY.getValue(); big = scrollBig.getValue(); wide = scrollWide.getValue(); repaint(); }
public void paint(Graphics g) { //g.drawString("startX Value is "+startX,10,50); //g.drawString("startY Value is "+startY,10,80); //g.drawRect(startX,startY,big,wide);example g.setColor(Color.blue);//period g.fillOval(70,70,10,10); g.setColor(Color.green); g.fillArc(90,20,40,60,45,280);//Outer Arc for E g.setColor(Color.lightGray); g.fillArc(100,29,20,40,45,360);//Inner Arc for E g.setColor(Color.green); g.fillRect(100,42,17,10);//Bar for E g.setColor(Color.orange);//period g.fillOval(140,70,10,10); g.setColor(Color.yellow); g.fillArc(160,20,40,60,45,280);//Outer Arc for C g.setColor(Color.lightGray); g.fillArc(170,29,20,40,45,360);//Inner Arc for C g.setColor(Color.magenta);//period g.fillOval(210,70,10,10); g.setColor(Color.blue); g.fillArc(230,20,40,60,45,280);//Outer Arc for E g.setColor(Color.lightGray); g.fillArc(240,29,20,40,45,360);//Inner Arc for E g.setColor(Color.blue); g.fillRect(240,42,17,10);//Bar for E g.setColor(Color.red);//period g.fillOval(280,70,10,10);
g.setColor(Color.green);//colours moveable rectangle g.fillRect(startX,startY,big,wide);//gives co ords for starting point g.setColor(Color.black); g.drawLine(110,170,150,110);//tower g.drawLine(150,110,190,170);//tower g.drawRect(110,170,80,160);//main body
g.setColor(Color.white); g.fillOval(130,180,40,40);//clock face g.setColor(Color.black); g.drawLine(150,200,160,190);//Big Hand g.drawLine(154,190,160,190); g.drawLine(160,190,160,195);
g.drawLine(140,200,150,200);//Little Hand g.drawLine(140,200,143,197); g.drawLine(140,200,143,203);
g.setColor(Color.red); g.fillRect(130,270,40,60);//disk g.setColor(Color.black); g.fillRect(132,272,3,4); g.fillRect(163,272,3,4); g.setColor(Color.gray); g.fillRect(140,312,23,19);//slide g.setColor(Color.black); g.fillRect(143,317,6,9);
g.setColor(Color.red); g.drawString("LECE, Get London Computing",80,350);
if (mouseIn ==true) { g.setColor(Color.red); g.fillRect(23,23,10,57);//L g.fillRect(23,70,33,10);} else { g.setColor(Color.blue); g.fillRect(23,23,10,57);//L g.fillRect(23,70,33,10); } } }
|
|