File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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.
 
 
subject: scrollpane