java-gnome version 4.1.2

org.gnome.gtk
Class ComboBoxText

Object
  extended by org.freedesktop.bindings.Pointer
      extended by org.freedesktop.bindings.Proxy
          extended by org.gnome.glib.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.ComboBoxText
All Implemented Interfaces:
CellEditable, CellLayout

public class ComboBoxText
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.

Since:
4.0.20
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.Destroy, Widget.Draw, Widget.EnterNotifyEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.MotionNotifyEvent, Widget.PopupMenu, Widget.ScrollEvent, Widget.SizeAllocate, Widget.UnmapEvent, Widget.VisibilityNotifyEvent
 
Constructor Summary
ComboBoxText()
          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, connect, connect, destroy, getAllocatedHeight, getAllocatedWidth, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getPreferredHeightForWidthMinimum, getPreferredHeightForWidthNatural, getPreferredHeightMinimum, getPreferredHeightNatural, getPreferredWidthForHeightMinimum, getPreferredWidthForHeightNatural, getPreferredWidthMinimum, getPreferredWidthNatural, getRequestMode, getRequisition, getSensitive, getStyleContext, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, isSensitive, overrideBackground, overrideColor, overrideFont, queueDraw, queueDrawArea, realize, setAlignHorizontal, setAlignVertical, setCanDefault, setCanFocus, setEvents, setExpandHorizontal, setExpandVertical, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll
 
Methods inherited from class org.freedesktop.bindings.Pointer
toString
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComboBoxText

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

Since:
4.0.20
Method Detail

appendText

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

Since:
4.0.20

getActiveText

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

Since:
4.0.20

insertText

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

Since:
4.0.20

prependText

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

Since:
4.0.20

removeText

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

Since:
4.0.20

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