This week's giveaway is in the Spring forum.
We're giving away four copies of Microservices Testing (Live Project) and have Chris Love & Andres Sacco on-line!
See this thread for details.
Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Swings Problem!!!!

 
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
This problem have been bugging me for last 1.5 days. The problem is like this.

I have a main window Frame and over that i m displaying a JTabbedPane. One of its tab have some labels,combo boxes and text fields. This JTabbedPane extends JPanel. So a panel containg JTabbedPane is displayed over a frame.This i have done but when i am maximizing and minimizing the window then position of labels,combo boxes and text fields is not changing with respect to main frame???

Please tell me how to do it!!!
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use gridbag layout. i tried just now...its working fine
 
Himanshu Rawat
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you please give me the code..just for looking..cos it isnt working on my side...
 
Marshal
Posts: 76075
362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to remember that unlike C#, Java has lots of layout managers. You don't usually specify how many pixels you want a component to be, you let the layout manager sort that out for you.
If you set the layout manager to null rather than the defaults for each component (eg JFrame defaults to Border and JPanel defaults to Flow), then you have to set the exact location and size of every object shown (setBounds() is a quick way to do it). But once you have set the size, reducing the size of the enclosing JFrame will cause some of the components to disappear off the edge of the windiw.
 
Campbell Ritchie
Marshal
Posts: 76075
362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Posted by Shansi Raj

Use gridbag layout.

Agree.

But have a look at this website of Cay Horstmann's. It has a useful class which makes handling GridBag quicker and easier.
 
Himanshu Rawat
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Campbell,

Exactly!! I have set layout to null. To change the position i have written some code that works but not fully . I was thinking that there may be some easier way of doin it???
Campbell should i make Main frame window layout ->> gridBag or Jpanel layout->> gridbag???
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While gridbag layout is nice, it has it's own share of problems. As Campbell said, there are many layout managers for Swing. The good ones aren't even part of the core API.

See This for a chuckle. And then you might want to check out some other layout managers like JGoodies Forms. Do a google search as well and see what else is out there.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic