Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #5323

Re: How to clip child from layout manager

Newsgroups comp.lang.java.gui
Date 2013-04-08 07:38 -0700
References <7a07006d-a3a8-4e09-b3a3-1cd9ee01328f@googlegroups.com> <kjnmhk$fb4$1@dont-email.me>
Message-ID <cd9d48a8-45a2-47bb-8807-acbbffac794b@googlegroups.com> (permalink)
Subject Re: How to clip child from layout manager
From FredK <fred.l.kleinschmidt@gmail.com>

Show all headers | View raw


On Friday, April 5, 2013 4:28:07 PM UTC-7, markspace wrote:
> On 4/5/2013 10:03 AM, FredK wrote: > I have a custom layout manager. > If the Swing container that uses this manager is too small to layout > the children at preferred sizes, I want to clip one or more of them. > > I do not want to set the child's size smaller than its desired size. > > For example, suppose the child's desired width is 100. I want to > place it at x=250 with width = 100, but I want to clip part of it so > that the first 40 pixels are clipped. The end result will be > that its position is [250,350] but only the child's [60,100] part > is visible ( occupying the region [290,350] ). > I think this happens automatically. I think the clip region of the Graphic2D is already set for you when your layout manager is called. Just call setBounds() on each object you want to lay out. They'll be drawn at that position, even if only partly visible. If not visible it won't be drawn at all, the underlying graphics tool is smart like that.


No, this is not what I want do do here. Calling setBound() with a size
smaller than the preferred size causes the component to try to draw itself
in that smaller size, and will clip anything that won't fit.

Here's what I want it to do. Suppose the child's preferred size is
200x500. I want it to draw itself at that size, with its UL corner at,
say, (200,400), so its LR corner will be at (400,900).

But I want to see only that portion of it that is within my
rectangle [upperleft=(250,350), lowerright=(350,500)]. Thus it clips
itself around all edges - similar to what you see in the viewport
of a ScrollPane

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

How to clip child from layout manager FredK <fred.l.kleinschmidt@gmail.com> - 2013-04-05 10:03 -0700
  Re: How to clip child from layout manager markspace <markspace@nospam.nospam> - 2013-04-05 16:28 -0700
    Re: How to clip child from layout manager FredK <fred.l.kleinschmidt@gmail.com> - 2013-04-08 07:38 -0700
      Re: How to clip child from layout manager markspace <markspace@nospam.nospam> - 2013-04-08 10:00 -0700
  Re: How to clip child from layout manager Roedy Green <see_website@mindprod.com.invalid> - 2013-04-05 20:51 -0700
  Re: How to clip child from layout manager Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-04-08 14:08 -0700

csiph-web