• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Moving around an Image the is larger then my screen.

 
Scott Kimberly
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11165
14
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Scott Kimberly
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Scott Kimberly
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic