# How to make a widget float?

Is there an option or way to make a GUIKit window remain in on top of other application's windows?

In[1]:= Needs["GUIKit"]
ref = GUIRun[Widget["Label", { "text" -> "Stay afloat!"}]]


I've looked through the docs and I can't find a way to do this yet.

In[3]:= Options@Widget
Out[3]= {InitialArguments -> None, Name -> None,
ExposeWidgetReferences -> Automatic, WidgetLayout -> Automatic}


But I suspect it is possible, because it is based on Java and it is poosible to do in java's Window class.

Window.setAlwaysOnTop(boolean)


If anyone knows what gui libraries that JLink is using under the hood here for GUIKit windows - that would be a really great place to start!

• But you have seen that the source of GUIKit  comes with your Mathematica installation and you even have all java sources available, yes? – halirutan Apr 30 '15 at 2:29
• Yes, and I was surprised that the source was exposed - but I haven't yet found a solution. – M.R. Apr 30 '15 at 2:46
• Does my answer work for you too? – halirutan Apr 30 '15 at 3:07
• A glass of soda and two scoops of widget? – Daniel Lichtblau Apr 30 '15 at 13:46

## 1 Answer

I guess all the important information can be found in the tutorial, specifically in the subsection

There, you see that you can easily extract the class that is used for widgets

<< GUIKit
ref = GUIRun[Widget["Label", {"text" -> "Stay afloat!"}]]

First[ref]
(* « JavaObject[com.wolfram.guikit.swing.GUIKitJFrame]» *)


As shown in the tutorial, you can call methods on the java object directly, which makes it possible to do the following

First[ref]@setAlwaysOnTop[True]
`

On my machine this works and I cannot cover the window with another one any longer.