Hey guys!

Would some kind soul please be able to tell me how i can add some form of text field (for user input) which can be positioned anywhere easily with X and Y values and has no border (or the border is removable)..

I've seen it many many many times, i have just completely forgotten!

If there is no component which has x and y positioning features but can easily be positioned with X and Y (i HATE grids and layout soooo much - i'm used to VB) please advise me!

Thank you very very very very very much!

7 Years
Discussion Span
Last Post by Olliepop

"Components" don't have any kind of "positioning" features. You place components into layout that is part of a container, and that layout takes care of the positioning. Also, the border is "removable" on all swing elements, see the "sertBorder" method and the "EmptyBorder" class.

For full positioning control use GridBagLayout (you have x/y coordinates there, but probably not how you're thinking of them), but that is the hardest layout manager to use correctly.

If you feel you really must control all features of the layout then google for "Java Swing Null Layout". Be forewarned, however, that the slightest differences from machine to machine (I.E. resolution, OS, system font settings, etc, etc, etc) will probably "break" your GUI using Null Layout.

Edited by masijade: n/a

Votes + Comments
Thanks for the great reply, bookmarked :)

Thank you very much! Does anyone have any examples of how i can position a textfield using GridBagLayout?


Okay thanks again, i'll go through that a few times and see if it has what i'm looking for


Before you leap into GridBagLayout I would strongly advise you to read a little about each of the various Layout Managers. . (GridBagLayout, BoxLayout, GridLayout, etc). I'm pretty sure each of them contains a section explain what they are useful for doing and why. You should choose your layout manager depending on your project's needs. Only choose the harder ones like GridBagLayout if it is necessary for your design.


Thanks for the feedback - i'm just going to use Netbeans WYSIWYG editor for a while until i get more into the JComponents.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.