This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Applets and the fly likes scrollpane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Applets
Bookmark "scrollpane" Watch "scrollpane" New topic
Author

scrollpane

CD Phillips
Greenhorn

Joined: Apr 13, 2005
Posts: 6
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

Joined: Jan 14, 2004
Posts: 1535
CD Phillips
Greenhorn

Joined: Apr 13, 2005
Posts: 6
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.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: scrollpane
 
It's not a secret anymore!