MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: GUIKit: Color?

  • To: mathgroup at
  • Subject: [mg50177] Re: [mg50160] GUIKit: Color?
  • From: Jeff Adams <jeffa at>
  • Date: Thu, 19 Aug 2004 06:28:06 -0400 (EDT)
  • References: <>
  • Sender: owner-wri-mathgroup at

On Aug 18, 2004, at 12:20 AM, Andrew Dabrowski wrote:

> Another GUIKit question.
> With palettes the foreground and background colors of most objects can 
> be set.
> Is that possible with GUIKit?
> Also buttons in palettes can be made inactive.  Is that possible with 
> widgets?
>  From the available documentation I'm guessing the answer on both 
> counts is
> currently no.


Since GUIKit widgets are implemented with Java Swing classes, anything 
you can
do with Java components you should be able to do equally well with 

The documentation is initially trying to highlight some of the more 
common properties
you might use, and some of the examples do show things like changing 
foreground and
background colors as well as enabling and disabling widgets.

For a complete listing of all properties of widgets check out the 
documentation of GUIInformation
and how you can get a complete listing of a widget's properties.

To address your two specific questions,
it is possible to change the "foreground" and "background" properties 
of most widgets,
but on some platforms this setting may not actually display because the 
underlying Java look and feel
is attempting to match your operating system's native look (and colors) 
for dialogs and buttons.

Here is an example where some background and foreground colors are 

   Widget["Frame", {
       "background" -> Widget["Color", InitialArguments -> {0, 255, 0}],
       Widget["TextField", {
           "text" -> "Some Text",
           "background" -> Widget["Color", InitialArguments -> {255, 0, 
       Widget["Button", {
           "text" -> "OK",
           "foreground" -> Widget["Color", InitialArguments -> {0, 0, 

Regarding your second question, most widgets support the "enabled" 
property which
should give you the inactive appearance you desire.

Here is an example that demonstrates this using a checkbox to turn the 
properties on/off:

   Widget["Frame", {
       {Widget["TextField", {"text" -> "Some Text"}, Name -> "myText"],
         Widget["Button", {"text" -> "OK"}, Name -> "myButton"]},
       Widget["CheckBox", {"text" -> "Widgets Enabled", "selected" -> 
               activeQ = PropertyValue[{"myCheckBox", "selected"}];
               SetPropertyValue[{"myText", "enabled"}, activeQ];
               SetPropertyValue[{"myButton", "enabled"}, activeQ];
               ]]}, Name -> "myCheckBox"]

Jeff Adams
Wolfram Research

  • References:
  • Prev by Date: Wolfram Research présente sa première conférence Mathematica à Paris
  • Next by Date: Re: Re: FindMinimum and the minimum-radius circle
  • Previous by thread: GUIKit: Color?
  • Next by thread: General expression of this definite integral ?