public class Statusbar extends HBox
A Statusbar should generally be present at the bottom of a GNOME application's main Window by being the first Widget to be packed with respect to the end of the VBox used to vertically layout such a Window:
status = new Statusbar(); vbox.packEnd(status, false, false, 0); window.add(vbox);in fact, this is so much a convention that a Statusbar should be present regardless of whether or not you plan to have messages to display. Make sure you pack it into the top level VBox with expand and fill set to
falseas shown. Statusbars somewhat by definition should stay narrow; they shouldn't grow thicker if the user resizes vertically.
The text in the Statusbar is set with
setMessage(). Most applications leave the Statusbar empty as a default
state, but if you wish to inform the user of things being in a normal
state, you can certainly do so:
status.setMessage("Ready");or similar words appropriate to your program.
Statusbars are excellent for providing hints to the user about what the
user can do next (see
Inkscape as a terrific example),
or to update the user with what the application is up to when processing.
Keep in mind, however, that this is considered only an assistance; people
don't necessarily look to the Statusbar when wondering what is going on
(and further, many applications allow the user to turn the Statusbar off
entirely). If you need to provide urgent information to the user then use a
As a Box subclass, you can pack other Widgets into the Statusbar. This is a great place for a ProgressBar if you have a long running worker thread that needs to report its percentage completion. Widgets so added will be packed after the Label that is (obviously) internally present to display the status messages. If it is a small Window you may want to constrain the size of the ProgressBar lest it blot out the message:
status = new Statusbar(); bar = new ProgressBar(); bar.setSizeRequest(30, -1); status.packEnd(bar, false, false, 0);then later:
status.setMessage("Sending all your files to the CIA..."); bar.setFraction(0.35);
A visible Statusbar usually drawn with a grip in the bottom right corner
which most users will recognized as a stylized visual indication that the
Window can be resized. If necessary, it can be suppressed by calling
The underlying API in
GtkStatusbar is ridiculously
complicated for absolutely no good reason. We have therefore compressed its
hideous stack-based mechanism into the simple single-message interface
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.QueryTooltip, Widget.ScrollEvent, Widget.SizeAllocate, Widget.UnmapEvent, Widget.VisibilityNotifyEvent
|Constructor and Description|
Construct a new Statusbar.
|Modifier and Type||Method and Description|
Set the message showing in the Statusbar.
getOrientation, getSpacing, packEnd, packStart, reorderChild, setOrientation, setSpacing
activate, addEvents, connect, 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
public void setMessage(String text)
If you want to clear the message, simply pass the empty string,