java - How Can I Make a JTextField's Width Static? -


i have jtextfield in jframe , set text in jtextfield.

when text long, jtextfield gets text's length , jtextfield's new width equal text. changes window's shape , other components' places. how can make jtextfields have static width won't resized based on length of text pass in?

the simplest thing can set column width, during initialization of jtextfield, e.g.:

new jtextfield("hello world!", 5); new jtextfield(10); 

but container have layout manager -- if didn't specify explicitly, has default. jframe starts borderlayout in content pane, although if you've added other panels between jframe , jtextfield, we'd need know have better sense of layout manager.

some layout managers constrain width of field well, way might address problem.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -