My other recommendation is to learn and use the more basic layouts first such as GridLayout, BoxLayout, BorderLayout, and FlowLayout. Save the GridBagLayout for later. Also, understand that you can nest JPanels each using a different layout, and by so doing build a complex layout.
Best of luck.
adeeb alexander wrote:Thanks for replying.
But i have added components using only the setBounds method. I can do with layout managers also. But main problem is that i am unable to resize components on window resize.
Is it possible to achive component resizing without any layout managers
This my friend is one of the reasons for the existence of layout managers. For those of us who've used them, your problem is screaming for their use. I'm curious why you seemingly insist on not using the right tool for the job?
Isn't there a way to solve my problem with just few lines of code because i have written much code already.
adeeb alexander wrote:Heres the code which i used for arranging the components. this is actually very easy to arrange components. Easier than the layouts like grouplayout and gridbag layout. the only problem i face is the resizing of the components.
Perhaps, but much harder to adjust and enhance. For instance, what if you want to add another JTextField to your program?
Here's an example that goes against my previous rec in that it uses GridBagLayout, but I felt that I had to use this to accommodate the label you have between the JTextFields, the one that states Enter Date in....
Please run the and you'll see that it looks somewhat similar to your program:
Yes, it's a bit complex, and I'm sorry for that, but it was created in a bit of a rush. You'll notice that it is somewhat resizeable, though not very pretty when resized. This can all be tweaked.
The real power and beauty of layout managers comes when you want to extend your code. Say you'd like to add another textfield at the bottom that allows one to enter comments. In you're program, you'd have to change the location of all components below this field. In mine, all you'd have to do would be to add one String to a String array. You'd simply change this:
Try it and see.