Skip to main content

how to get control

3 replies [Last post]
jeganathanp
Offline
Joined: 2008-04-24
Points: 0

I am new to javafx.

i created two classes.

one is for link
second one is for details.

I am displaying some thing like this...

----------Link1--------------
----------Link2--------------
----------Link3--------------

I have to get the following event, When i click on link2, Link3 should move and link2 should show detail

---------Link1--------
---------Link2--------
$$$$$$$$$$$$$$
$$$Detail$$$$$$
$$$$$$$$$$$$$$
------Link3----------

Depending upon Detail-enable i have to bind y values of link3..

I have coded something like this
==========================================================

var name1 = NamesInPhoneBook{
valx : bind this.xpos
valy : bind this.ypos
}

var details1 = ContactDetails{
xPos : bind name1.getX
yPos : bind name1.getY+25
isVisible: bind tst1.isContactVisible
}
var name2 = NamesInPhoneBook{
valx : bind this.xpos
valy : bind this.ypos+40+(i need to assign some value depending upon isVisible of details1)
}

=============================================================

How this can be achieved.

Thanks
Jegan

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jim_weaver
Offline
Joined: 2007-05-18
Points: 0

Can you show all of your code (e.g. the ContactDetails class, and the UI portions). That would help me answer your question.

Thanks,
Jim Weaver

jeganathanp
Offline
Joined: 2008-04-24
Points: 0

Hi Jim,
Thanks for response..

Here is my code

=========================================================
/*
* PhoneBookName.fx
*
* Created on Apr 23, 2008, 3:00:21 AM
*/

package javafxapplication1;

/**
*
*
* @author Jeganathan
*/
import javafx.ui.*;
import javafx.ui.canvas.*;
import java.lang.System;

public class NamesInPhoneBook extends CompositeNode{
//contentVal - set Value for Content
attribute contentVal : String;
//font - set font Color
attribute font : Font;
//defaultColor - set default Color
attribute defaultColor : Color;
//overColor - set Over Color
attribute overColor : Color;
//exitColor - set Exit Color
attribute exitColor :Color;
attribute valx : Number;
attribute valy : Number;
attribute getX : Number;
attribute getY : Number;
attribute clicked : Number;
attribute isContactVisible : Boolean;
}

function NamesInPhoneBook.composeNode() = Group{
content : Text{
font: bind this.font
fill : bind this.defaultColor
x : bind this.valx
y : bind this.valy

content : bind this.contentVal

onMouseEntered: operation(e){
defaultColor = overColor;
}
onMouseExited: operation(e){
defaultColor = exitColor;
}
onMouseClicked : operation(e){
getX = currentX;
getY = currentY;
if(clicked == 0){
clicked = 1;
isContactVisible = true;
}
else {
clicked = 0;
isContactVisible = false;
}
System.out.println(getX);
System.out.println(getY);
System.out.println(clicked);
}
}
};

===============================================================
/*
* NameList.fx
*
* Created on Apr 23, 2008, 4:25:22 PM
*/

package javafxapplication1;

/**
* @author Jeganathan
*/
import javafx.ui.*;
import javafx.ui.canvas.*;
import contactdet.ContactDetails;

class NameList extends CompositeNode{
attribute xpos : Number;
attribute ypos : Number;
attribute name1 : NamesInPhoneBook;
attribute ypos_1 : Number;
attribute expand : Boolean;
attribute move : Number;
}
trigger on NameList.expand = newValue{
if(newValue){
this.move = 50;
}
else{
this.move = 0;
}
}
function NameList.composeNode()= Group{
var tst1 = NamesInPhoneBook{
valx : bind this.xpos
valy : bind this.ypos
font: Font {
size: 20
}
defaultColor: green
overColor: blue
exitColor: green
contentVal: "Name 1"

}

var tst2 = ContactDetails{
xPos : bind tst1.getX
yPos : bind tst1.getY+25
isVisible: bind tst1.isContactVisible
}

var tst3 = NamesInPhoneBook{

}

content : [
tst1,tst2
]
};
Frame {
height : 200
width : 200
visible : true
content : Canvas{
content :[
NameList {
xpos : 20
ypos : 40
}
]
}
}
===============================================================
/*
* ContactDetails.fx
*
* Created on Apr 24, 2008, 11:18:57 AM
*/

package contactdet;

/**
* @author Jeganathan
*/

// place your code here
import javafx.ui.*;
import javafx.ui.canvas.*;
public class ContactDetails extends CompositeNode{
attribute xPos : Number;
attribute yPos : Number;
attribute isVisible : Boolean;
attribute opacityValue : Number;
}
function ContactDetails.composeNode()= Group{
visible: bind this.isVisible
opacity: 1

content : [
Rect{
height : 80
width : 150
x : bind this.xPos
y : bind this.yPos
arcHeight: 20
arcWidth: 20
fill: cyan
stroke: blue

},
Text{
x : bind this.xPos+10
y : bind this.yPos+10
content : "Tel 1: 040-27089000"
},
Text{
x: bind this.xPos+10
y: bind this.yPos+ 30
content : "mob 1 : 9989554627"
},
Text{
x: bind this.xPos+10
y: bind this.yPos+50
content : "Email : jp@phono.com"
}
]
};
var tst = ContactDetails{
xPos : 10
yPos: 10
//opacityValue: [0.00,0.01 .. 1.00] dur 1000
isVisible: true

};

Thanks
Jeganathan Palanisamy

jeganathanp
Offline
Joined: 2008-04-24
Points: 0

Hi Jim,
i sorted out the problem i will post new code here soon.
Thanks
Jegan