Does the panel to which you are adding the table, has a BorderLayout?
It will help us help you better if you tell the details Also check out this link on how to get the most out of the Ranch.
> but I already tried everything......and nothing is helpful for me........
then you're possibly using a null layout, and not giving anything a size.
we can continue to play 20 guesses, or, if you really want a solution, post your code.
Rohit Aggarawal
Ranch Hand
Joined: Jun 26, 2009
Posts: 36
posted
0
Use this. It will work ..
JScrollPane scrollPane = new JScrollPane(instance_of_Table);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_ALWAYS);
add(scrollPane, BorderLayout.CENTER); (Add should be called for any container....FRame or JPAnel)
Please see my comments.
Recommendations:
1) You do not need p. Discard it.
2) Use p1.add(scrollPane)
3) Use c.add(p1)
4) Even, c.add(scrollPane) will do, if your UI shows only the table.
janavi patel wrote:
but i tried that one also. when i use BorderLayout() it shows empty frame and nothing in it...
Like you have been told before, unless you show us your code, we cannot really help you..and even people will get fed up and stop helping you.
So, show us your code
Vandre Caetano
Greenhorn
Joined: Dec 19, 2007
Posts: 13
posted
0
I changed a few things in the code, here is one that works:
This message was edited 2 times. Last update was at by Vandre Caetano
janavi patel
Greenhorn
Joined: Jul 01, 2009
Posts: 13
posted
0
Here is my another code....
Rob Camick
Ranch Hand
Joined: Jun 13, 2009
Posts: 1644
posted
0
Why are you trying to write an entire program when you are trying to learn a new concept?. Your question is about a JTable and a scrollbar. People have told you to use a JScrollPane. So only include those two classes in your test programa and keep it simple. Something like this:
This message was edited 1 time. Last update was at by Rob Camick
janavi patel
Greenhorn
Joined: Jul 01, 2009
Posts: 13
posted
0
Are yaar*.... all things are related and impacting each other...thats why....
*Are yaar=="Hey dude" or "Man"
[MG]
Janavi,
We got people from all over the world here.
Please use real words [/MG]
This message was edited 2 times. Last update was at by Maneesh Godbole
Rohit Aggarawal
Ranch Hand
Joined: Jun 26, 2009
Posts: 36
posted
0
Code is slightly modified for the method MyFrame8 and that works now. Please use this piece of code...
This message was edited 3 times. Last update was at by Rohit agl
Yes, I tried that.....
It works when there is only container and not panel and it hides all other components....
And when panel is used all positions are proper bue there is no scrollbar....
Michael Dunn
Rancher
Joined: Jun 09, 2003
Posts: 3610
posted
0
> Yes, I tried that.....
and, as usual, it worked.
> It works when there is only container and not panel and it hides all other components....
> And when panel is used all positions are proper bue there is no scrollbar....
then, why don't you post your (altered Rob Camick's) code to prove the above?
Rohit Aggarawal
Ranch Hand
Joined: Jun 26, 2009
Posts: 36
posted
0
Dear janavi patel
You can use the modified code that was posted by me earlier and It will run like anything. I took not more than 1 minute to modiffy and run your code.
I am still wondeing why that does not work on your machine.
"Rohit agl",
Please check your private messages for an important administrative matter.
janavi patel
Greenhorn
Joined: Jul 01, 2009
Posts: 13
posted
0
Hi Rohit
I tried your code snippet in my program as follows:
1. Now it adds scrollpane to the table but not showing other components.
2. Also shows srollable table for full frame. For this I tried pane.setBounds() but no effect.
3. Doesn't matters panel's layout even whether panel is used or not.
janavi patel wrote:
1. Now it adds scrollpane to the table but not showing other components.
2. Also shows srollable table for full frame. For this I tried pane.setBounds() but no effect.
3. Doesn't matters panel's layout even whether panel is used or not.
manish
this is last time I am telling to you I tried all hints and every other thing that I can do...
if you cant help or dont want to help then its more better for both of us that you just stay away from this matter.......
janavi patel wrote:manish
this is last time I am telling to you I tried all hints and every other thing that I can do...
if you cant help or dont want to help then its more better for both of us that you just stay away from this matter.......
To start with I am a volunteer here and I do not get paid for this work. Even if I was getting paid, I still do not have any reason to put up with this kind of language.
I do not see you trying out my suggestions which I gave here I wonder if you found time to go through the links I had provided.
Michael Dunn (another volunteer) had requested you to
then, why don't you post your (altered Rob Camick's) code to prove the above?
. You did not respond to it. BTW, Rob Camick is another volunteer.
If you want to learn, it might be a good idea to try out suggestions. You can always ask why. If you want ready made solutions (and the learning is not really important), then you are in the wrong place. All volunteers here are entitled to some respect.
Have a nice day and best of luck with your code.
janavi patel
Greenhorn
Joined: Jul 01, 2009
Posts: 13
posted
0
sorry for that.....
actually I never behave like this with anyone but everytime manish replied against me.....
everytime i said i tried and you just opposed me and nothing else thats why...........
and in my code i did too many changes so its not possible for me to send the code......
and I want to learn thats why I am doing all these things.......
sorry once again......
and I m saying sorry not because you are a volunteer but because of this is not in my nature.......
Rob Camick
Ranch Hand
Joined: Jun 13, 2009
Posts: 1644
posted
0
I did too many changes so its not possible for me to send the code......
You learn by walking, not running. Forget about your real program, you are just trying to learn basic concepts, so you start with a basic program.
Why do you think I gave you the 10 line complete example program?
That program shows how to display a table with scrollbars. The next step is to add a couple of text fiields. If it works great, if not, then you have a 10-15 line program to post in the forum that we can look at. Once that works you move on to the next step.
Finally, when you understand how LayoutMangers work and how to you add components to a panel you go back to your real program to figure out what you did wrong. We are not here to debug you program for you. Frankly, if you can't figure out how to add components to a panel then you shouldn't be doing Swing programming. This should be the first think you learn because it only gets more difficult.
Michael Dunn
Rancher
Joined: Jun 09, 2003
Posts: 3610
posted
0
> actually I never behave like this with anyone but everytime manish replied against me.....
you've missed the point, totally. There's nothing 'personal' in it.
all everyone is doing is trying to get you to think about what you're doing, how you're going about it,
giving you some hints/nudges in the right direction.
This makes it much easier for you the next time you have a problem.