org.gnome.gtk

Class Container

Known Direct Subclasses:
Bin, Box, Fixed

public abstract class Container
extends Widget

A Widget that contains at least one, and maybe more, other Widgets. Container is the base of the GTK box packing model; all layouts are composed of Widgets that are packed into other Widgets.

Containers fall into two major categories. They are either:

decorators
ButtonWindowor
layout
FixedBoxTable

TODO Add a human understandable discussion about the basics of size requests and size allocations.

Author:
Andrew Cowie
Since:
4.0.0

Nested Class Summary

Nested classes/interfaces inherited from class org.gnome.gtk.Widget

Widget.ENTER_NOTIFY_EVENT, Widget.FOCUS_OUT_EVENT

Method Summary

void
add(Widget child)
Add a child Widget to this Container.
void
remove(Widget child)
Remove a Widget from this Container.

Methods inherited from class org.gnome.gtk.Widget

connect, connect, getParent, show, showAll

Methods inherited from class org.freedesktop.bindings.Proxy

toString

Method Details

add

public void add(Widget child)
Add a child Widget to this Container. This works for all the various Container types, of course, but most offer more specialized packing methods that allow you to control the positioning of the Widget being added with greater finesse.
Since:
4.0.0

remove

public void remove(Widget child)
Remove a Widget from this Container.

In native GTK, this often results in the destruction of the Widget. In java-gnome, that will occur once the last Java reference goes out of scope and a garbage collection run occurs. So you can, quite safely, do:

 box1.remove(button);
 box2.add(button);
 
without worrying that that Button is going to evaporate out from under you.
Parameters:
child - A child Widget that is already in the Container, right? If you try to remove a Widget that isn't, don't complain when you get all sorts of errors!
Since:
4.0.2