Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (292)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  a little trouble with JViewport  (Read 662 times)
0 Members and 1 Guest are viewing this topic.
Offline skytomorrownow

Junior Member





« Posted 2006-08-22 07:25:41 »

i have made a frames ruler that i'd like to embed inside a JViewport. the default behavior of JViewport.add( rulerComponent ) seems to be to create a view whose size is set to the rulerComponents, and does not change. i tried to .setPrefferedSize(), etc. to no avail because i can't query the rulerComponent for it's size to perform the calculation myself ( java.awt.Dimension always returns 0, 0 whether i call in main(), or in the constructor of the view's parent).

even if i could set the viewport's size, that wouldn't do me that much good because the layout manager of it's parent seems to only respect entire dimensions, not just one. what i would like to create is a viewport that get's it's height from the component it contains (to remain static), and for it's width to stretch to fit it's parent container. is there a good way to accomplish this? do i have to override the views getPrefferedSize method? see illustration.

i don't need code or anything, just an explanation of how to setup the viewport so it lays out as described.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (67 views)
2013-05-17 12:29:12

alaslipknot (76 views)
2013-05-16 12:24:48

gouessej (109 views)
2013-05-15 15:53:38

gouessej (104 views)
2013-05-15 15:17:58

theagentd (115 views)
2013-05-15 06:01:13

theagentd (104 views)
2013-05-15 06:00:54

StreetDoggy (149 views)
2013-05-14 06:56:26

kutucuk (172 views)
2013-05-12 08:10:36

kutucuk (170 views)
2013-05-12 06:36:09

UnluckyDevil (179 views)
2013-05-11 20:09:57
Complex number cookbook
by Roquen
2013-04-24 03:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 07:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 07:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 07:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 08:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 07:17:38

Java Data structures
by Roquen
2013-03-29 04:21:12

Topic Request
by kutucuk
2013-03-22 12:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.07 seconds with 20 queries.