java-gnome version 4.0.19

org.gnome.gtk
Class TextComboBox

Object
  extended by org.freedesktop.bindings.Pointer
      extended by org.freedesktop.bindings.Proxy
          extended by org.gnome.glib.Object
              extended by org.gnome.gtk.Object
                  extended by org.gnome.gtk.Widget
                      extended by org.gnome.gtk.Container
                          extended by org.gnome.gtk.Bin
                              extended by org.gnome.gtk.ComboBox
                                  extended by org.gnome.gtk.TextComboBox
All Implemented Interfaces:
CellEditable, CellLayout

public class TextComboBox
extends ComboBox

A ComboBox for displaying simple Strings. A common use case for ComboBoxes is to just choose from a list of textual options. This subclass of ComboBox takes care of the mechanics of setting up a the ListStore and the appropriate CellRenderers so as to allow a straight forward interface with a limited number of convenience methods for adding Strings.

Usage is very straight forward:

 combo = new TextComboBox();
 combo.appendText("SYD");
 combo.appendText("YYZ");
 combo.appendText("JFK");
 combo.appendText("LHR");
 ...
 
You can still use the getActive() from ComboBox, but for simple lists of Strings being displayed be this Widget, the String specific getActiveText() that is introduced here is probably what you want.

These text-only methods are actually found in GTK on GtkComboBox, but using them collides with the normal ComboBox methods. We have therefore moved them to a custom subclass to make the API safe.

Since:
4.0.6
Author:
Andrew Cowie, Serkan Kaba

Nested Class Summary
 
Nested classes/interfaces inherited from class org.gnome.gtk.ComboBox
ComboBox.Changed
 
Nested classes/interfaces inherited from class org.gnome.gtk.Widget
Widget.ButtonPressEvent, Widget.ButtonReleaseEvent, Widget.EnterNotifyEvent, Widget.ExposeEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.MotionNotifyEvent, Widget.PopupMenu, Widget.ScrollEvent, Widget.UnmapEvent, Widget.VisibilityNotifyEvent
 
Nested classes/interfaces inherited from class org.gnome.gtk.Object
Object.Destroy
 
Constructor Summary
TextComboBox()
          Construct a new text-only ComboBox.
 
Method Summary
 void appendText(String text)
          Append an item to the list.
 String getActiveText()
          Returns the text of the active item.
 void insertText(int position, String text)
          Append an item at the supplied position.
 void prependText(String text)
          Prepend an item to the beginning of the list.
 void removeText(int position)
          Removes the item at given position from the list.
 void setModel(TreeModel model)
          Unsupported.
 
Methods inherited from class org.gnome.gtk.ComboBox
connect, getActive, getActiveIter, popdown, popup, setActive, setActiveIter
 
Methods inherited from class org.gnome.gtk.Bin
getChild
 
Methods inherited from class org.gnome.gtk.Container
add, getChildren, remove, setBorderWidth
 
Methods inherited from class org.gnome.gtk.Widget
activate, addEvents, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getRequisition, getSensitive, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, isSensitive, modifyBackground, modifyBase, modifyFont, modifyText, queueDraw, queueDrawArea, realize, setCanDefault, setCanFocus, setColormap, setEvents, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll
 
Methods inherited from class org.gnome.gtk.Object
connect, destroy
 
Methods inherited from class org.freedesktop.bindings.Pointer
toString
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextComboBox

public TextComboBox()
Construct a new text-only ComboBox.

Since:
4.0.6
Method Detail

appendText

public void appendText(String text)
Append an item to the list.

Since:
4.0.6

getActiveText

public String getActiveText()
Returns the text of the active item.

Since:
4.0.6

insertText

public void insertText(int position,
                       String text)
Append an item at the supplied position. Positions are zero origin.

Since:
4.0.6

prependText

public void prependText(String text)
Prepend an item to the beginning of the list.

Since:
4.0.6

removeText

public void removeText(int position)
Removes the item at given position from the list.

Since:
4.0.15

setModel

public void setModel(TreeModel model)
Unsupported.

If you're using a text mode ComboBox, GTK internally allocates a ListStore of a certain structure and the methods are designed to work against it. Things will blow up if you swap it for something different, unless it had exactly the correct signature. As this signature is not something that is part of the GTK API, it is not something we're going to expose; this override is here to prevent you from shooting yourself in the foot.

Overrides:
setModel in class ComboBox
Throws:
UnsupportedOperationException - if called.


java-gnome