Skip to main content

Setting x and y attributes on swing components in ComponentView

2 replies [Last post]
vi5in
Offline
Joined: 2008-08-08
Points: 0

Hello,

I'm just learning JavaFX and I have a script with the following structure:

<br />
Frame {<br />
   stage: Stage {<br />
      content:<br />
         [Group {<br />
            //nodes<br />
          },</p>
<p>          Group {<br />
             content: ComponentView {<br />
                             component: TextField { x:10 y:75 ... }<br />
                         }<br />
         }<br />
        ]<br />
     }<br />
}<br />

The nodes in the first group are regular node elements (rectangles and a text node) and have x and y attributes for them. I'm trying to set the x and y attributes for the swing element (which I'm adding by using componentview), but it still shows up at the top left of the frame. I even tried adding it as part of the other group and that doesn't work either. Any idea what I'm doing wrong?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexsch
Offline
Joined: 2007-07-12
Points: 0

Use the transform attribute of ComponentView class:

[code]
Frame {
width: 200
height: 300
stage: Stage {
content: [Group {
//nodes
},Group {
content: ComponentView {
transform: Translate{ x: 10 y: 75}
component: TextField { text: "Press Me!"}
}
}
]
}
visible: true
}
[/code]

vi5in
Offline
Joined: 2008-08-08
Points: 0

Thanks alexsch! That worked perfectly.