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!

Recommended Answers

All 6 Replies

"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.

commented: Thanks for the great reply, bookmarked :) +1

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.