This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

scrollpane

 
CD Phillips
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is obviously a novice's question. I can't seem to figure out how to get my applet to scroll?? Can anyone help??

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

public class TheApplet2 extends Applet {
int x1, y1, z1,
hLineLen,
vLineLen1,
vLineLen2,
boxAdjH,
boxAdjV,
rectWid,
rectHth,
depth;
String menuTitle;

public void init() {
setBackground( Color.black );
hLineLen = 36;
vLineLen1 = 8;
vLineLen2 = 10;
rectWid = 60;
rectHth = 18;
boxAdjH = 40;
boxAdjV = 19;
x1 =30;
y1 =20;
z1 =50;
}

public void paint(Graphics g) {
g.setColor( Color.green );
g.drawRect( x1, y1, rectWid, rectHth );
g.drawString( menuTitle, x1 + 15, y1 + 15);

for(int i=1;i<=depth;i++) {
g.drawLine( x1 + rectWid/2, y1 + rectHth, x1 + rectWid/2, y1 + rectHth + vLineLen1);
g.drawLine( x1 + rectWid/2, y1 + rectHth + vLineLen1, x1 + rectWid/2 + hLineLen, y1 + rectHth + vLineLen1);
g.drawLine( x1 + rectWid/2 + hLineLen, y1 + rectHth + vLineLen1, x1 + rectWid/2 + hLineLen, y1 + rectHth + vLineLen1 + vLineLen2 );
g.drawRect( x1 + rectWid/2 + hLineLen - rectWid/2, y1 + rectHth + vLineLen1 + vLineLen2, rectWid, rectHth );
g.drawString( menuTitle, x1 + rectWid/2 + hLineLen - rectWid/2 + 15, y1 + rectHth + vLineLen1 + vLineLen2 + 15);
x1 += hLineLen;
y1 += rectHth + vLineLen1 + vLineLen2;
if((x1 > 120) | (x1 < 60)) hLineLen *= -1;
}//for
}//graphics

public void messageFromJS(String sMessage, String MT){
depth = Integer.parseInt(sMessage);
menuTitle = MT;
repaint();
}//messageFromJS

}//applet
 
Craig Wood
Ranch Hand
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
CD Phillips
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Craig. I'm still tyring to get it to run though. The applet opens in the window but the for loop does not execute for whatever reason(probably minor). I'll keep working on it.

Many thanks so far.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic