Leopard Client Properties

If you want to do a L&F targeted to Mac Leopard, here’s an example solution with various objects modified.

Note that you have to call the property code before a form loads.

Cheers Harjo :)

//JComponent.sizeVariant
//MEMO: valid options: regular, small, mini

//push buttons
elements.btn_regular.putClientProperty('JComponent.sizeVariant','regular')
elements.btn_small.putClientProperty('JComponent.sizeVariant','small')
elements.btn_mini.putClientProperty('JComponent.sizeVariant','mini')


//checkboxes
elements.check_regular.putClientProperty('JComponent.sizeVariant','regular')
elements.check_small.putClientProperty('JComponent.sizeVariant','small')
elements.check_mini.putClientProperty('JComponent.sizeVariant','mini')


//combobox
elements.combo_regular.putClientProperty('JComponent.sizeVariant','regular')
elements.combo_small.putClientProperty('JComponent.sizeVariant','small')
elements.combo_mini.putClientProperty('JComponent.sizeVariant','mini')
elements.combo_square.putClientProperty('JComboBox.isSquare',true)


//search
elements.fld_search.putClientProperty('JTextField.variant','search')

//circular progress
elements.progressBar.indeterminate = true
elements.progressBar.putClientProperty("JProgressBar.style", "circular")


//more buttons
elements.btn_square.putClientProperty('JButton.buttonType','square')
elements.btn_gradient.putClientProperty('JButton.buttonType','gradient')
elements.btn_bevel.putClientProperty('JButton.buttonType','bevel')
elements.btn_texture.putClientProperty('JButton.buttonType','textured')
elements.btn_roundrect.putClientProperty('JButton.buttonType','roundRect')
elements.btn_recessed.putClientProperty('JButton.buttonType','recessed')
elements.btn_help.putClientProperty('JButton.buttonType','help')

leopard_client_property.servoy (6.85 KB)

Thanks David, for sharing this! :D :D

great. as one would expect :-)

kazar

Harjo & David - this is AWESOME! Thanks very much for sharing!

David, I have 2 questions:

  1. Can I set the element property only once for ALL buttons, instead of every single element?
  2. In Leopard you see many times, this kind of comboboxes:

[attachment=0]Afbeelding 11.png[/attachment]

Do you know if this is possible in Servoy?

Afbeelding 11.png

1- Since these are runtime client properties you’re setting, each element needs to be set individually when they are created. Some Java guru may have a slick way to override L&F at startup but I would just do something like this and call it from each form onLoad method. Save a ton of time not having to call each element by name:

// fun-ction to set client properties on all form objects (call from form onLoad)

var formName = arguments[0]

for ( var i = 0 ; i < forms[formName].elements.length ; i++ ) {
	try {
		switch( forms[formName].elements[i].getElementType() ) {
			
			case "COMBOBOX" :
				forms[formName].elements[i].putClientProperty('JComboBox.isSquare',true)
				break
			
			case "BUTTON" :
				forms[formName].elements[i].putClientProperty('JButton.buttonType','square')
				break
				
			case "CHECK" :
				forms[formName].elements[i].putClientProperty('JComponent.sizeVariant','small')
				break
				
			case "TEXT_FIELD" :
				//
				break
				
			default:
		}
	}
	catch (e) {}
}

2- Doesn’t look like its available on Mac Java. The list of available properties to date:

Sorry, had a lazy coding moment there. Better without the try statement:

// fun-ction to set client properties on all form objects (call from form onLoad)

var formName = arguments[0]

for ( var i = 0 ; i < forms[formName].elements.length ; i++ ) {
	if ( forms[formName].elements[i].getElementType ) {
		switch( forms[formName].elements[i].getElementType() ) {
			
			case "COMBOBOX" :
				forms[formName].elements[i].putClientProperty('JComboBox.isSquare',true)
				break
			
			case "BUTTON" :
				forms[formName].elements[i].putClientProperty('JButton.buttonType','square')
				break
				
			case "CHECK" :
				forms[formName].elements[i].putClientProperty('JComponent.sizeVariant','small')
				break
				
			case "TEXT_FIELD" :
				//
				break
				
			default:
		}
	}
}
  1. Can I set the element property only once for ALL buttons, instead of every single element?

Yes: application.setUIProperty() should do the trick.

Paul

ah, cool! :-)

thanks Paul!

Paul, I have tried this, but this does not work: (I do this in the onOpen method)

	application.setUIProperty('JComboBox.isSquare',true)
	application.setUIProperty('JButton.buttonType','textured')

am I doing something wrong?

Harjo:
am I doing something wrong?

UI and client properties are two different things. There is some property overlap but there is no direct mapping of most of the “custom” apple leopard client properties at the UI level.

application.setUIProperty() function also takes java code in its parameters:

http://www.servoy.com/forum/viewtopic.php?f=3&t=11217

oke, thanks David.