This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes mig layout, jscrollpane, and min size Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "mig layout, jscrollpane, and min size" Watch "mig layout, jscrollpane, and min size" New topic
Author

mig layout, jscrollpane, and min size

Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

this is my panel, which is on the bottom half of another panel (also mig layout).
The trouble is this panel always end up with the panel title and the table titles are visible but not the actual data.
i would like not to put the table in a scroll pane, but that appears to be how swing is designed to display tables.
I made a panelClass that overrode getSize and getPreferedSize to make a min height, but they were being ignored.

So my question is: how do i either make the panel big enough using the scroll pane, or make the table display properly not using the scroll pane?



the main panel is defined as:

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

I usually use something like.


or make the table display properly not using the scroll pane

Now that's strange. How do you suppose to display the data if the table contains more rows than the visible area?
Anyway, you can try the following:
1) Define a panel with BorderLayout
2) Add the table to the CENTER
3) Add the table header to NORTH


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

i know the table will never have more than 4/5 rows in it, so am quiet confident about space.

never thought of sticking border layout in the middle, as i was promised mig was the saviour of all my problems


Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Well you can still do it with MigLayout only.



Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

when i do that the left and top table borders get lost.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

The code you have posted cannot be compiled. Can you post a http://sscce.org/ example?
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

just trying to get this done
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

Maneesh Godbole wrote:The code you have posted cannot be compiled. Can you post a http://sscce.org/ example?


nope sorry, i tried to make a standalone program, but failed.
which is bad news, i will take all the layout stuff out of my panel and start again clean
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

You give up too easily
The problem is the layout.
Just create a dummy panel with the layout constraints and post it.
Well to confess I already did it. So don't bother.

But what you can do is post a screenshot indicating the top and left borders which you mentioned.
PS. I presume you know how to explicitly set borders when required,
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

i know how to set borders, just not how to post screenshots to java ranch.

And i decided you were right the scroll pane is the way i should be going so i have concentrated my efforts on that.
And when using images big enough in my demo program i mananged to reproduce the tiny table.



Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Well I can try out that code as soon as I get access to
private static final String MY_PICTURES = "C:\\Documents and Settings\\wendy.gibbons\\My Documents\\My Pictures\\";


In the meanwhile you can try this out.


Its the same code you posted yesterday, which I tweaked to take out the unknown stuff.

When you are posting a reply, there is an attachment tab at the bottom of the text area which you can use to upload the screenshots
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

I figured you would have your own huge pictures you could replace it with , as i needed everything on the screen to need lots of space and images where easiest
And call me a purest but i wanted to know where the outlines that are meant to be there went when I made my own they appeared but...


[Thumbnail for my_table_problem.JPG]

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Nah! I am too lazy to switch to my image folders

Ok. At a risk of sounding daft, I need to clarify things.
1) Are we still talking about the vanishing top and left areas? In your later post you agreed the scroll panel was a good idea. Also, your latest code uses the scroll panel.
2) I looked at the screen shot. I can't figure out what am I supposed to observe in the red oval. Doh!

I am attaching my screen shot. It is from the code snippet I posted.
The only change I did was



[Thumbnail for migLayoutTable.JPG]

Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

sorry talking to me too long confuses people for the 1st 3-4 years then they get the hang of it

Sorry The screen print was showing the old missing borders.

So this screen print shows the tiny usless scroll pane it gives me, an actually usefull picture



[Thumbnail for usless scroll pane.jpg]

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Since the data is not clearly visible, the scrollbar is showing up.
The solution would be to resize the other panels to provide sufficient space for the table.
Since you have not explicitly set any scroll bar policy, they would disappear when the data is properly visible.

Also, please check your private message.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: mig layout, jscrollpane, and min size
 
Similar Threads
JTable
JTable
JTable is not inserting the data
JRadioButton in JTable
JScrollPane within JTable cell issue