Skip to main content

Setting x and y attributes on swing components in ComponentView

2 replies [Last post]
Joined: 2008-08-08


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>          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.
Joined: 2007-07-12

Use the transform attribute of ComponentView class:

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

Joined: 2008-08-08

Thanks alexsch! That worked perfectly.