Properties

Try this:
  set cal [java::new java.util.GregorianCalendar]
  java::info properties $cal
This will print
    lenient time minimum greatestMinimum class maximum
    minimalDaysInFirstWeek leastMaximum gregorianChange
    firstDayOfWeek timeZone {{}}

(The last element in this list is a bug in Tcl Blend, so we'll just ignore it.) Now, if we go

  java::prop $cal firstDayOfWeek
we will get "1." Look familiar? It should: all we are doing is calling the getFirstDayOfWeek method of the calendar object. If we go
  java::prop $cal firstDayOfWeek 4
then we are calling the setFirstDayOfWeek method (and setting the start day of the week to Wednesday).

Basically, that's all a property is: if a class has a method getSomething, then "something" is a property of objects of that class. If the property is not read-only, then there is also a setSomething method, or, if the object is a boolean type, an isSomething method.

Bogon alert!
If an object has a setSomething method but no corresponding getSomething method, then java::info properties will still return it as a property. If you try to read it, it will return the rather curious error "write-only property."

Here's a simple class that you can use to experiment with properties:

package tutorial.tcltk98;
public class Props {
  boolean red = false;
  int value = 5;
  public void setRed (boolean r) {
    red = r;
  }
  public void isRed () {
    return red;
  }
  public int getValue () {
    return value;
  }
}

(After compiling it, create an instance of this class with java::new, and query and set its properties with java::info properties and java::prop.)

To give all this a little more realism, here's some Tcl code that creates a button in a window.

  set button [java::new java.awt.Button]
  set window [java::new java.awt.Frame]
  $window setLocation 100 100
  $window {add java.awt.Component} $button
  $window pack
  $window show
The button has no label, which is of course useless. If you look at the properties of the button, you will see, among others, the property label. So set it:
  java::prop $button label "Push me!"
You might like to mess around with some of the other properties, such as visible and enabled, and see how the button responds.