Skip to main content

Setting the preferredSize of a TextField

2 replies [Last post]
edort
Offline
Joined: 2004-05-04
Points: 0

Naive question ... What's the proper way in the compiler-based version of JavaFX Script to set the preferredSize of a TextField? For instance, if I wanted to set the preferredSize of a TextField to 500, what would the code look like?

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

I typically use the columns attribute of the TextField and let the layout components worry about exact sizing. The columns attribute uses some font metrics based upon current font, size, style, etc. to calculate how wide in pixels that x number of columns should be.

Thanks,
Jim Weaver

shagus
Offline
Joined: 2007-05-10
Points: 0

//Sample.fx
import javafx.ui.*;
import java.awt.Dimension;

Frame {
title: "XXXXXXXX"
content: TextField {
preferredSize:
Dimension {
width:500,
height:20
}
}
visible: true
}

Message was edited by: shagus