Skip to main content

Tab binding question

5 replies [Last post]
blasky
Offline
Joined: 2008-05-21
Points: 0

NetBeans 6.1 with compiler...

I've tried to distill my code down to the bare bones for clarity. But I've verified that the problem I was seeing occurs in this basic example as well.

Namely, when I've got a couple of tabs on screen and Tab Two's title (or other attributes) is bound to something, it's Tab One's title that gets updated. (I've tried with 3 tabs and different bindings...but it's always the first tab that acts as if it was bound, which it is not.)

Is this a compiler bug? Or am I not binding the second Tab the way I think I am?

Thanks.

package tabtest;

import javafx.ui.*;

class ClickerModel {
attribute count: Integer
}

var clicker = ClickerModel {
count: 0
}

Frame {
title : 'Tab Binding Test'
visible: true
width : 300

content: TabbedPane {
selectedIndex: 0
tabs: [
Tab {
title: 'Tab One'
},
Tab {
title: bind 'Tab Two w/Bind {clicker.count}'
content: Button {
text: 'Click'
action: function() { clicker.count++; }
}
}
]
}
}

Message was edited by: blasky

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sleep
Offline
Joined: 2008-05-26
Points: 0

This is not exactly the same thing, but I am having a similar tab attribute binding issue. Put briefly, I display graphs using canvases on tabs, so I have custom tabs that have a graph attribute and a custom TabbedPane that has both an array of graphs that it displays and, supposedly, a bound attribute for the current graph.

My first attempt was:

[code]
public class GraphTab extends Tab {
attribute graph: Graph;
}

public class GraphTabbedPane extends TabbedPane {
attribute graphs: Graph[];
override attribute selectedIndex = 0;
attribute currentGraph: Graph = bind (tabs[selectedIndex] as GraphTab).graph;
...
[/code]

This does not compile:

[echo] Graph Tab Classes
[exec] src/GraphTabs.fx:16: cannot find symbol
[exec] symbol : method element(com.sun.javafx.runtime.location.SequenceVariable,com.sun.javafx.runtime.location.DoubleVariable)
[exec] location: class com.sun.javafx.runtime.sequence.BoundSequences
[exec] attribute currentGraph: Graph = bind (tabs[selectedIndex] as GraphTab).graph;
[exec] ^
[exec] 1 error

Now if I simply bind it to the first tab's graph, it works:

[code]
public class GraphTabbedPane extends TabbedPane {
attribute graphs: Graph[];
override attribute selectedIndex = 0;
attribute currentGraph: Graph = bind (tabs[0] as GraphTab).graph;
...
[/code]

... which compiles fine. However, when I outsource the 0 into another Number attribute, it again breaks:

[code]
public class GraphTabbedPane extends TabbedPane {
attribute graphs: Graph[];
attribute selected = 0;
attribute currentGraph: Graph = bind (tabs[selected] as GraphTab).graph;
...
[/code]

... with the same message:

[exec] src/GraphTabs.fx:16: cannot find symbol
[exec] symbol : method element(com.sun.javafx.runtime.location.SequenceVariable,com.sun.javafx.runtime.location.DoubleVariable)
[exec] location: class com.sun.javafx.runtime.sequence.BoundSequences
[exec] attribute currentGraph: Graph = bind (tabs[selected] as GraphTab).graph;
[exec] ^
[exec] 1 error

Is this a compiler problem as well or am I not using the bindings properly?

Thanks in advance!

topley
Offline
Joined: 2004-07-02
Points: 0

Maybe this will work:

attribute currentGraph: Graph = bind (tabs[selectedIndex [b]as Integer[/b]] as GraphTab).graph;

sleep
Offline
Joined: 2008-05-26
Points: 0

Yes it did! Thanks so much, topley!

blasky
Offline
Joined: 2008-05-21
Points: 0

Nobody else has run into any problems binding a Tab attribute? Weird...

alexsch
Offline
Joined: 2007-07-12
Points: 0

It seems that it is an issue in the current UI library or in the compiler.
Please, file a JIRA issue on it: http://openjfx.java.sun.com/jira