|
Replies:
3
-
Last Post:
Oct 5, 2008 12:52 AM
by: rperfect
|
Threads:
[
Previous
|
Next
]
|
|
|
|
|
|
binding problem and hyperlink question
Posted:
Oct 2, 2008 3:02 AM
|
|
|
Hi There,
I just started using JavaFx and I got stuck on two problems:
- I've got a CustomNode, CollapsibleBox which has a variable height depending on a variable bobHeight. I created two of those boxes in a Widget and now I want the second box to move down when the first one opens (to prevent the first box from overlapping the second). The plan is to add the boxHeight to the y attribute of the second like this:
CollapsibleBox{ x:10, y: bind (box1.boxHeight) + 40 closeLabel: "label2" content: "content2" }
where box1 is defined outside the Widget in the same way as this one because I couldn't assign a normal reusable id...
var box1 = bind CollapsibleBox{ x:10, y:30 closeLabel: "label1" content: "content1" };
This doesn't work! The attribute boxHeight is 25 as it should be when the box is not open, but doesn't change when the box opens.
The second question mmight be a simpler one. How can I create a hyperlink in javafx. I have this widget and I want to add some links to it that open a browser and go to the address specified.
Can anyone help me on these problems??
Thanks in advance,
Sjoerd
|
|
|
|
|
|
|
Re: binding problem and hyperlink question
Posted:
Oct 2, 2008 7:08 PM
in response to: sjoedzj
|
|
|
Hi Sjoerd,
What exactly is the "CollapsibleBox" class? Are you sure the boxHeight property of the object box1 is actually changing?
|
|
|
|
|
|
|
|
Re: binding problem and hyperlink question
Posted:
Oct 3, 2008 1:48 AM
in response to: sjoedzj
|
|
|
My CollapsibleBox component is a CustomNode with an onMouseClicked event handler that opens the box to fit the content (So its a box that slides open when you click on it) The boxHeight property is changed in the TimeLine so I'm sure that it changes (because the sliding works and it worked before I made it a component). The code:
package jfallwidget.components;
import javafx.scene.CustomNode; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.text.*; import javafx.scene.geometry.Rectangle; import javafx.scene.paint.Color; import javafx.scene.Font; import javafx.scene.FontStyle; import javafx.input.MouseEvent; import jfallwidget.vo.UserVO; import javafx.animation.Timeline; import javafx.animation.Interpolator; import javafx.scene.layout.VBox;
public class CollapsibleBox extends CustomNode { public attribute x:Integer; public attribute y:Integer; public attribute closeLabel:String; public attribute content:String[]; public attribute boxHeight:Integer = 25; public attribute boxOpen:Boolean = false; public function CollapsibleBox(x:Integer, y:Integer, closelabel:String, content:String[]){ this.x = x; this.y = y; this.closeLabel = closeLabel; this.content = content; } public function create(): Node { var colBox = this; var tOpen = Timeline { keyFrames: [ at(0s) { boxHeight => 25 }, at(0.5s) { boxOpen => true; boxHeight => content.size()*28 tween Interpolator.EASEBOTH; } ] }
var tClose = Timeline { keyFrames: [ at(0s) { boxOpen => false; boxHeight => content.size()*20 }, at(0.5s) { boxHeight => 28 tween Interpolator.EASEBOTH; } ] } return Group { content: [Rectangle { opacity:0.8 x: x, y: y width: 280 height: bind boxHeight fill: Color.WHITE stroke: Color.rgb(227,51,39) strokeWidth:2 arcHeight:15 arcWidth:15 onMouseClicked : function(e:MouseEvent):Void{ if(boxOpen){ tClose.start(); }else{ tOpen.start(); } } },VBox{ spacing:10 content:for (i in content){ Text { visible:bind boxOpen font: Font { size: 15 style: FontStyle.PLAIN } x: x+5, y:y+18 fill:Color.BLACK content: i } } },Text { visible:bind not boxOpen font: Font { size: 15 style: FontStyle.PLAIN } x: x+5, y:y+18 fill:Color.BLACK content: closeLabel }] }; } }
|
|
|
|
|
|
|
|
Re: binding problem and hyperlink question
Posted:
Oct 5, 2008 12:52 AM
in response to: sjoedzj
|
|
|
I can't quite understand your first question it might be easier if you post your code with the code formatting markup [ code ] and [ / code ]
The second question might be a simpler one. How can I create a hyperlink in javafx. I have this widget and I want to add some links to it that open a browser and go to the address specified.
..If you've got a pure Java HyperLink component then I'd just use that - you can wrap Swing components in a ComponentView class and display them within a Scene graph. Otherwise you'd probably do something along the lines of formatting a Text node to look like a hyper link and then in it's onMouseClicked() event handler do the launching of the browser which isn't very easy in a cross platform manner and you'll probably need to read up on that somewhere.
|
|
|
|
|