aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How I can have dynamic multiple Component across a JPanel or JFrame without going out of Screen Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How I can have dynamic multiple Component across a JPanel or JFrame without going out of Screen " Watch "How I can have dynamic multiple Component across a JPanel or JFrame without going out of Screen " New topic
Author

How I can have dynamic multiple Component across a JPanel or JFrame without going out of Screen

Kr. Pallav
Ranch Hand

Joined: Mar 06, 2010
Posts: 32

I want to create a JFrame or JPanel ,I am able to generate multiple component getting required value from database value objects.It's working good but problem is if the number of component are more and since there setBounds are dynamically set ,they are going out of screen. How can I add them to a Pane so that it automatically gets scollbar with if number of component increases .
I am setting size of screen using Toolkit and Dimension .


~|>@//@\/~
Kumar Pallav
-------------------
SCJP 5: 86 %, SCWCD: 91%
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

Instead of using setBounds you should be using layout managers


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Kr. Pallav
Ranch Hand

Joined: Mar 06, 2010
Posts: 32

Thanks a lot bro, but using such layout increases the size of the JTextFields and Buttons and all ,I am using GridLayout ,Any suggestions
Kr. Pallav
Ranch Hand

Joined: Mar 06, 2010
Posts: 32

Hey I solved it ,using
GridBagConstraints gbc=new GridBagConstraints();
and then
setting Layout as FlowLayout
the code that helped me is like



this code i got from http://www.jchq.net/tutorial/08_01Tut.htm

thanks for help
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

That is what GridLayout does, tries to size all components equally.

If you follow through the link which I had provided earlier, you will notice you have an option of various other layouts. You can even nest containers with different layouts, or even have one complex layout with the GridBagLayout.
If you are not satisfied with these layouts you might want to consider MigLayout

Kr. Pallav
Ranch Hand

Joined: Mar 06, 2010
Posts: 32

Maneesh Bhai,Thanks a lot for the help ,you guys are awesome ,doing a tremendous job of sharing the knowledge ,I will try my level best to contribute to open source technology ,Your team is really helpful and inspiring many like me.Hats off to coderanch
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2203
    
    7
I want to create a JFrame or JPanel ,I


In the solution you posted above you are using a Frame and a Panel. I suggest you stick with the Swing components (JFrame and JPanel) since more development is done in Swing than AWT.
Kr. Pallav
Ranch Hand

Joined: Mar 06, 2010
Posts: 32

Dear Rob Camick , I am sorry for little wrong approach while answering , I am using JFrame and JSwing only , I only used the GridBagConstraints and modified accordingly
,dear .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How I can have dynamic multiple Component across a JPanel or JFrame without going out of Screen