• Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing layout

 
Thai Son Cung
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all

I have a big problem getting my JPanel Layout done. I dont know how to set it at all I try grid, gridbag,... and all are so so difficult to set.

SWT have from but Swing.

I wonder if there any easy way to do

HELP!!

Regards
Tyson
 
Sravan Kumar
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the components in the JPanel are so complex, Why don't you set the layout to null and then add them with custom-defined size?

You can use setBounds() method on the components (available in java.awt.Component) and add them to the panel. That's the easiest solution.
 
Sunil Kumar Gupta
Ranch Hand
Posts: 824
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't u try some IDE's like NetBeans or JDeveloper

create custom layout there by setting the layout

of ur containers null.......


Hope u would not fear of java layout then


 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whoa there Sravan and Sunil! Those ideas aren't really going to help Thai Son Cung learn much are they. Layouts are very difficult no matter what GUI toolkit you use. But they are essential. More so in Java than in any other language because Java runs on multiple platforms and different platforms don't calculate pixals the same way.

If Thai Son Cung were to use a null layout it might look find in windows but when he ran it on linux or mac it would be messed up. And gui builders are fine once you know what you are doing and understand what the gui builder is doing for you. I still don't use them and I have been developing Swing for 6 years.

Thai Son Cung, the best thing for you to do right now is tell us exactly what problems you are having. Show us some code and tell us the way you are trying to lay your components out. That way we can push you in the right direction as to the best way to solve your problem.
 
Thai Son Cung
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

Thank you very much. I just have some simple form need to do. But my button and textbox always get mess up. I am using eclipse VE but there is no way to set the layout of the JPanel. I am trying to do it manualy but it's also difficult since this my first time with Swing.

Regard
Tyson
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Thai Son Cung:
Hi all

Thank you very much. I just have some simple form need to do. But my button and textbox always get mess up. I am using eclipse VE but there is no way to set the layout of the JPanel. I am trying to do it manualy but it's also difficult since this my first time with Swing.

Regard
Tyson


So, do you have any questions?
 
Stephen Boston
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps this Tutorial will help.
Sun Swing Trail
 
Thai Son Cung
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Gregg Bolinger

I have some questions but my code is highly confidencial, I am not allow to post it here. I have spent last night to master GridBagLayout, very complecated but also very powerful. You are right! All visual tool cant help you everything, there is some part we need to put our own code. Now I prefer to code my own GUI, not using any visual tool.

Thank you very much

Regards
Tyson
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!