This site requires JavaScript, please enable it in your browser!
Greenfoot back
davidlewine wrote ...


scroll bar in executable jar

davidlewine davidlewine


I would like to create a world that is longer than the screen height, and would like to scroll using a scroll bar when I open the executable jar file. I know I could make my own scroll bar out of Greenfoot actors which would work together with a scrollable world (moving the scroll bar level indicator actor would reposition all objects in the world) but I would rather just have the world be in a scrollable window like it is when I open a project in the greenfoot application. Could it be as simple as finding the right Jpanel in the code and making it scrollable? Any advice or hints about where to look in the greenfoot code would be appreciated.
MathManiac MathManiac


import javax.swing.*;
import java.awt.*;

public class HelloWorld extends JFrame {
    public HelloWorld() {
        setSize(640, 430);
        MyPane p = new MyPane();
        add(new JScrollBar(p));
        //Following line optional. Closes whole program (Even Greenfoot App itself) when red X clicked
    private class MyPane extends JPanel {
        public void paint(Graphics g) {
            //Mess around here        
I have an idea, but it has to be in a JFrame, so it's harder to do sprites. Here's the basic code:
davmac davmac


davidlewine, look at the greenfoot.export.GreenfootScenarioViewer class. You might turn the center panel into a JScrollPane for instance. MathManiac: I think the question is about Greenfoot's own code, not about how to create a scroll bar generally.
You need to login to post a reply.