Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Spring layout and AWT

 
Yura Vyrovoy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!

Give some advise please. Is it good idea to use Spring layout manager with AWT components without Swing?

It looks like it works good but sometimes I encounter problems that I don't know how to resolve.

Yura
 
Campbell Ritchie
Marshal
Posts: 52632
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could never understand Spring Layout anyway. Why are you using AWT? That was superseded about 15 years ago. The methods of SpringLayout, however, take Components or Containers as their parameters; since those appear to be superclasses of JComponent, I can see no reason why spring layout should not work with AWT Components, too.
 
Yura Vyrovoy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I decided to try pure AWT just to learn it. I've recently started Java programming so I decided to try different approaches. As I understand JavaFX now become standard.

Regarding my question Let me show you my code.

I found that if I put two panels within the frame, set Spring layout manager to arrange them, and then if I set another spring manager for one of these panels it's height become 0. It happens anyway - either I use awt or swing. Than I found that I can set panel height manually. But it works only with swing. When I call .getPreferredValue() in awt version result is 0. I'm afraid that I miss some important knowledge but I can't find what is it. Probably you can give me some hint.

Not OK.jpg
[Thumbnail for Not OK.jpg]
No manual height adjustment
Ok.jpg
[Thumbnail for Ok.jpg]
With manual height adjustment
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!