/*
* Main.fx
*
* Created on 10 Jun, 2009, 10:18:39 AM
*/
package controlskin;
import com.sun.javafx.scene.control.caspian.ButtonSkin;
import com.sun.javafx.scene.control.caspian.CheckBoxSkin;
import com.sun.javafx.scene.control.caspian.HyperlinkSkin;
import com.sun.javafx.scene.control.caspian.ListViewSkin;
import com.sun.javafx.scene.control.caspian.RadioButtonSkin;
import com.sun.javafx.scene.control.caspian.TextBoxSkin;
import com.sun.javafx.scene.control.caspian.ToggleButtonSkin;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextBox;
import javafx.scene.control.ToggleButton;
import javafx.scene.Group;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.Scene;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
/**
* @author Rakesh Menon
*/
var index = 0;
var skin : SkinPalette[] = [
SkinPalette {
palette: [
Color.web("#490A3D"), Color.web("#BD1550"), Color.web("#E97F02"), Color.web("#F8CA00"), Color.web("#8A9B0F")
]
},
SkinPalette {
palette: [
Color.web("#CFF09E"), Color.web("#A8DBA8"), Color.web("#79BD9A"), Color.web("#3B8686"), Color.web("#0B486B")
]
},
SkinPalette {
palette: [
Color.web("#FFEDBF"), Color.web("#F7803C"), Color.web("#F54828"), Color.web("#2E0D23"), Color.web("#F8E4C1")
]
},
SkinPalette {
palette: [
Color.web("#A8AD8D"), Color.web("#94947C"), Color.web("#443838"), Color.web("#E7A84B"), Color.web("#FFCC5F")
]
}
];
var button = Button {
text: "Button"
skin: ButtonSkin {
borderFill: bind skin[index].borderFill
focusFill: bind skin[index].focusFill
highlightFill: bind skin[index].highlightFill
shadowFill: bind skin[index].shadowFill
textFill: bind skin[index].textFill
fill: bind skin[index].fill
}
}
var checkBox = CheckBox {
text: "CheckBox"
skin: CheckBoxSkin {
borderFill: bind skin[index].borderFill
focusFill: bind skin[index].focusFill
heightlightFill: bind skin[index].highlightFill
shadowFill: bind skin[index].shadowFill
textFill: bind skin[index].textFill
fill: bind skin[index].fill
}
}
var radioButton = RadioButton {
text: "RadioButton"
skin: RadioButtonSkin {
borderFill: bind skin[index].borderFill
focusFill: bind skin[index].focusFill
heightlightFill: bind skin[index].highlightFill
textFill: bind skin[index].textFill
fill: bind skin[index].fill
}
}
var toggleButton = ToggleButton {
text: "ToggleButton"
skin: ToggleButtonSkin {
borderFill: bind skin[index].borderFill
focusFill: bind skin[index].focusFill
heightlightFill: bind skin[index].highlightFill
textFill: bind skin[index].textFill
fill: bind skin[index].fill
shadowFill: bind skin[index].shadowFill
}
}
var hyperlink = Hyperlink {
text: "Hyperlink"
skin: HyperlinkSkin {
textFill: bind skin[index].textFill
}
translateY: 210
}
var label = Label {
text: "Label"
textFill: bind skin[index].textFill
}
var listView = ListView {
items: [ "Item 1", "Item 2", "Item 3" ]
skin: ListViewSkin {
backgroundFill: bind skin[index].backgroundFill
alternateFill: bind skin[index].alternateFill
borderFill: bind skin[index].borderFill
focusFill: bind skin[index].focusFill
shadowFill: bind skin[index].shadowFill
}
width: 150
height: 150
translateY: 30
}
var textBox = TextBox {
text: "TextBox"
skin: TextBoxSkin {
backgroundFill: bind skin[index].backgroundFill
borderFill: bind skin[index].borderFill
caretFill: bind skin[index].caretFill
focusFill: bind skin[index].focusFill
highlightFill: bind skin[index].highlightFill
promptTextFill: bind skin[index].promptTextFill
selectedTextFill: bind skin[index].selectedTextFill
shadowFill: bind skin[index].shadowFill
textFill: bind skin[index].textFill
}
}
var updateButton = Button {
text: "Update Skin"
action: function() {
if(index == ((sizeof skin) - 1)) {
index = 0;
} else {
index++;
}
// Workaround: ListView skin is not updated by default
listView.select(1);
listView.select(0);
}
translateY: 270
}
var view = Group {
content: [
HBox {
spacing: 10
content: [ label, textBox ]
},
listView,
HBox {
spacing: 10
content: [ checkBox, radioButton ]
translateY: 190
},
hyperlink,
HBox {
spacing: 10
content: [ button, toggleButton ]
translateY: 230
},
updateButton
]
translateX: 10
translateY: 10
}
var bgRect : Rectangle = Rectangle {
x: 2
y: 2
width: bind scene.width - 4
height: bind scene.height - 4
stroke: Color.ALICEBLUE
fill: Color.BEIGE
}
var scene = Scene {
content: [ bgRect, view ]
}
Stage {
title: "Skin Controls"
scene: scene
resizable: false
//style: StageStyle.UNDECORATED
}
|