File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Moving around an Image the is larger then my screen. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Moving around an Image the is larger then my screen." Watch "Moving around an Image the is larger then my screen." New topic
Author

Moving around an Image the is larger then my screen.

Scott Kimberly
Greenhorn

Joined: Mar 04, 2012
Posts: 25
I am working on generating semi-random images for a map for a game im making. Right now im trying to figure out how to move around my JPanel using scroll bars for now. I cant figure out how exactly to place them so that i can move around and check an image that is larger then my monitor's resolution (which is 1920 x 1080). What would be the best way to make it so i can do this?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

1) Use a proper layout manager. BorderLayout suggests itself. The BorderLayout.CENTER attribute will try to fill up your screen
2) Put the Image in a JLabel
3) Add the image to JScrollPane
4) Add the JScrollPane to the container with the border layout.

I will move this topic over to the GUI forums, where Swing questions are usually discussed


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Scott Kimberly
Greenhorn

Joined: Mar 04, 2012
Posts: 25
This is my current GUI method:



It doesnt work. How do i properly combine my JFrame, JPanel, JLabel, and JScrollPane to make a working scrollable gui?
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4664
    
    5

1. We have no idea what's going on in your MyDrawing2 class.
2. You appear to be redundantly adding ot to a JPanel and placing that JPanel in a JScrollPane.
3. ItDoesntWorkIsUseless. TellTheDetails.

To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem. Not all your code.


luck, db
There are no new questions, but there may be new answers.
Scott Kimberly
Greenhorn

Joined: Mar 04, 2012
Posts: 25
DrawP and MyDrawing2 hold the image im making.

JFrame holds the borderlayout. Thats like the first thing i need and the last thing i need.

How do i add all the other components in to make a working gui.

Im sorry that this post is even in this section, it SHOULD have stayed in the new to java section where it belongs but one of the admins moved it.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Moving around an Image the is larger then my screen.