• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Moving around an Image the is larger then my screen.

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic