4
$\begingroup$

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!

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

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.