Based on Java's AWT and Swing frameworks Component position within container(x, y), size(w, h) horizontal and vertical padding, ints text: string font_size: int colours: foreground, background, and border parent: a container Container: a kind of component content: a vector of components orientation: horizontal or vertical spacing: number of pixels to leave between components Frame: a kind of container which represents a whole window focus: component * // which component has the input focus Component methods: get_absolute_position(int & x, int & y) // gets position withing frame // gets parents absolute position and adds own x, y // frame has absolute position of (0, 0) get_ideal_size(int & w, int & h) // works out what size should be, based on contents set_position(x, y) set_size(w, h) bool do_you_contain(x, y) pack() // work out what your own size should be draw() // makes the component appear on the screen Panel: a kind of contaniner usually has no text or border, just used to position its components Label: a kind of component usually has invisible background and border, just used to make fixed text appear Spacer: a kind of component invisible, just used to help position other components constructor takes width and height Container methods: add(component *) pack() // tell all contents to work out their own sizes // position contents based on orientation and their ideal sizes draw() // draws itself, then tells all contents to draw themselves // on top of it in their calculated positions Frame methods: draw() this is usually the last thing in a program. As well as doing all that container::draw() does, it also contains the unending loop that waits for mouse clicks and key presses, and passes those events on to the correct component ActionListener: an object which can react to mouse clicks or key presses every component has an ActionListener which may be NULL methods: mouse_clicked(x, y) // receives coordinates of the click key_pressed(char c) Useful library.h functions: measure_string(string s, int & w, int & h) measure_char(int c, int & w, int & h) wait_for_mouse_click_or_key_typed(double timeout - default infinite) int what_happened() // returns event::mouse_left_click or event::key_typed or event::none, etc int get_click_x() int get_click_y() char get_key_typed() More component methods: act_on_mouse_click(x, y); // container delivers it to appropriate component (remember x, y are relative) // component may fire ActionListener's mouse_clicked() act_on_keypress(char c); // always delivered to the component that has focus, often ignored Button: a kind of component that reacts when clicked on TextField: a kind of component if a key is pressed when it has focus, that char is added to the text displayed, backspace etc treated specially Checkbox: a kind of component can be set to checked or unchecked changes when mouse clicked on it