-
Bug
-
Resolution: Duplicate
-
P2
-
fx1.2.1
LinearGradient not working inside a VBox or HBox
When there is multiple Rectangales (or shapes) in side in VBox or HBox LinearGradient is not filling for all the rectangles.
Workaround :
Using Group instead of VBox / HBox
Here is the code -
import javafx.stage.Stage;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.scene.paint.Color;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.shape.Rectangle;
import javafx.scene.layout.VBox;
import javafx.scene.Scene;
Stage {
title: "Application title"
width: 250
height: 240
scene: Scene {
content: [
VBox { spacing: 10
content: [
Text {
font : Font {
size : 16
}
x: 10
y: 30
content: "Application content"
},
Rectangle {
width: 50
height: 40
fill: LinearGradient {
startX: 0.0 startY: 0.0 endX: 1.0 endY: 1.0
proportional: true
stops: [
Stop { offset: 0.0 color: Color.GREEN },
Stop { offset: 1.0 color: Color.YELLOW },
]
}
},
Rectangle {
width: 55
height: 45
fill: LinearGradient {
startX: 0.0 startY: 0.0 endX: 1.0 endY: 1.0
proportional: true
stops: [
Stop { offset: 0.0 color: Color.YELLOW },
Stop { offset: 1.0 color: Color.BLACK },
]
}
},
Rectangle {
width: 60
height: 50
fill: LinearGradient {
startX: 0.0 startY: 0.0 endX: 1.0 endY: 1.0
proportional: true
stops: [
Stop { offset: 0.0 color: Color.YELLOW },
Stop { offset: 1.0 color: Color.RED },
]
}
},
]
}
]
}
}
When there is multiple Rectangales (or shapes) in side in VBox or HBox LinearGradient is not filling for all the rectangles.
Workaround :
Using Group instead of VBox / HBox
Here is the code -
import javafx.stage.Stage;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.scene.paint.Color;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.shape.Rectangle;
import javafx.scene.layout.VBox;
import javafx.scene.Scene;
Stage {
title: "Application title"
width: 250
height: 240
scene: Scene {
content: [
VBox { spacing: 10
content: [
Text {
font : Font {
size : 16
}
x: 10
y: 30
content: "Application content"
},
Rectangle {
width: 50
height: 40
fill: LinearGradient {
startX: 0.0 startY: 0.0 endX: 1.0 endY: 1.0
proportional: true
stops: [
Stop { offset: 0.0 color: Color.GREEN },
Stop { offset: 1.0 color: Color.YELLOW },
]
}
},
Rectangle {
width: 55
height: 45
fill: LinearGradient {
startX: 0.0 startY: 0.0 endX: 1.0 endY: 1.0
proportional: true
stops: [
Stop { offset: 0.0 color: Color.YELLOW },
Stop { offset: 1.0 color: Color.BLACK },
]
}
},
Rectangle {
width: 60
height: 50
fill: LinearGradient {
startX: 0.0 startY: 0.0 endX: 1.0 endY: 1.0
proportional: true
stops: [
Stop { offset: 0.0 color: Color.YELLOW },
Stop { offset: 1.0 color: Color.RED },
]
}
},
]
}
]
}
}
- duplicates
-
JDK-8107513 Gradients don't translate correctly w/ JDK6u12
-
- Closed
-