Bookmark Topic Watch Topic
  • New Topic

Positioning scroll bar

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
when one opens an application that displays something larger then the visible size, the horizontal scroll bar makes its appearence, totally moved to the left side
i wonder if there is some programatically manner of, by default, the scrollPane bar being completely placed to the right side

thanks in advance
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
You can get hold of a JScrollPane's scroll bars using getHorizontalScrollBar and getVerticalScrollBar. Check what methods those have.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
Rob Prime wrote:You can get hold of a JScrollPane's scroll bars using getHorizontalScrollBar and getVerticalScrollBar. Check what methods those have.

thanks Rob
i had aleady checked all available methods for JScrollPane and also for JScrollBar, but none seems to answer to my reuqest...

a bit offtopic remark: people who write from right to left must have the initial scroll position at exactly where i want it to be
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
I think you've missed the methods of JScrollBar about the current, minimum and maximum value.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
Rob Prime wrote:I think you've missed the methods of JScrollBar about the current, minimum and maximum value.

getMaximum
int getMaximum()Gets the maximum value of the adjustable object.

Returns:
the maximum value of the adjustable object

is this intended to set how much scroll bar moves away from its original position?
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
The maximum indicates the maximum position for the scroll bar.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
Rob Prime wrote:The maximum indicates the maximum position for the scroll bar.

as these methods arent clear enough to me, i wrote:

but didnt notice any chage in my aplication

could you please elaborate a bit on what you said about "value"? am i missing something?

NOTE: just in case i'm not explaining myself clearly enough, i attach two images: the default behaviour, with scroll at left side, and the other like i wanted it to be: the scroll is totally moved towards right side
default.PNG
[Thumbnail for default.PNG]
default behaviour
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
another post just to show the 2nd image - the one which shows how i'd like it to be when opening thw aplication
my goal.PNG
[Thumbnail for my goal.PNG]
scroll bar programatically right aligned - is it possible?
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Report post to moderator
A picture tells us nothing about your code. You've been asked for a SSCCE before.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
Rob Camick wrote:A picture tells us nothing about your code. (...)

pictures are to make clear my requirement, not to ilustrate any code
Rob Camick wrote:A(...)You've been asked for a SSCCE before.

when and where?
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Report post to moderator
pictures are to make clear my requirement, not to ilustrate any code


But the problem is with your code, not the picture. So how can we help you fix your code if we can't see it?

when and where?


Do you actually read the suggestions you've been given in previous postings?. Apparently not and apparently you don't want any help because you still haven't posted one. Too late now. I'm not going to repeat myself every time I try to help you.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
Rob Camick wrote:
pictures are to make clear my requirement, not to ilustrate any code


But the problem is with your code, not the picture. So how can we help you fix your code if we can't see it?

when and where?


Do you actually read the suggestions you've been given in previous postings?. Apparently not and apparently you don't want any help because you still haven't posted one. Too late now. I'm not going to repeat myself every time I try to help you.


again, if you read carefully, i've no problem what so ever with my code
i just want to know if there is any available way of achieving my requirement, which is decribed with words and images
i'm not worried at all with your bad temper!
and, again, you are not trying to help - its obvious! - else you would answer in simple ways: there is, there is not, read this, go this or that way, but no, once again the bad temper prevails
have a merry christmas
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Report post to moderator
You've already been given the answer. If it doesn't work, then there is something wrong with your code and I know I'm not a mind reader so I can't solve it without seeing the code.

I've already helped you several times in the past, apparently you don't want my help in the future.

If you don't want the help thats fine with me, but I find that strange since you are the one that asked the question?



 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
Rob Camick wrote:You've already been given the answer. If it doesn't work, then there is something wrong with your code and I know I'm not a mind reader so I can't solve it without seeing the code.

I've already helped you several times in the past, apparently you don't want my help in the future.

If you don't want the help thats fine with me, but I find that strange since you are the one that asked the question?




>>You've already been given the answer
if you refer to value, i didnt get it, so i asked for further explanation (which so far i didnt get)
>>I've already helped you several times in the past, apparently you don't want my help in the future.
>>If you don't want the help thats fine with me, but I find that strange since you are the one that asked the question?
that's half true - i dont intend to be tortured anymore
you should remember that in one ocasion you needed ten posts to finally understand what i wanted; here you have it by words and images
if you dont want to help, that's your problem
by the way: i guess you still dont understand what i'm looking for...
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Report post to moderator
you should remember that in one ocasion you needed ten posts to finally understand what i wanted


I have answered many thousands of questions in my time. If I don't understand a question its generally because its a poorly worded question. By the way I was the only person who even made an attempt to uderstand what you where asking in that question, so again don't blame me, look in the mirror.

At any rate, I've already stated I'm not a mind reader, that is why a SSCCE should be included with every question. Seeing the "incorrect behaviour" and the code you used to produce this behaviour clears up the question and leaves no doubt about what you are doing.

How about the last question you asked? It took two of us and multiple replies to get you to understand. I already told you in that posting I wasn't going to help without a SSCCE, yet here we are again, nothing has changed.

by the way: i guess you still dont understand what i'm looking for...


We understand and you've been given the answer. If its not working then you are doing something wrong and I'm not here to play 20 questions, guessing what it is that you are doing wrong.

if you dont want to help, that's your problem


If I didn't want to help I wouldn't have replied. However, instead of spending time creating a SSCCE you are wasting your time with these useless conversations that solve nothing. You are the one who is not making any effort!
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
miguel lisboa wrote:
Rob Prime wrote:The maximum indicates the maximum position for the scroll bar.

as these methods arent clear enough to me, i wrote:

You are now changing the maximum value to the current maximum value. Is it the maximum value you want to change, or some other value? The minimum value perhaps, or the current?
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
>>If I don't understand a question its generally because its a poorly worded question. By the way I was the only person who even made an attempt to uderstand what you where asking in that question, so again don't blame me, look in the mirror

your arrogance blinds you - go back again and check how clearly stated (since the begining) was what i intended; you'r the one who is a poor reader - my luck...

>> I already told you in that posting I wasn't going to help without a SSCCE, yet here we are again, nothing has changed.

so why even bother appearing?

>> However, instead of spending time creating a SSCCE you are wasting your time with these useless conversations that solve nothing.

you'r the one who mantains the conversation - i already wished you a merry christmas...
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
Rob Prime wrote:
miguel lisboa wrote:
Rob Prime wrote:The maximum indicates the maximum position for the scroll bar.

as these methods arent clear enough to me, i wrote:

You are now changing the maximum value to the current maximum value. Is it the maximum value you want to change, or some other value? The minimum value perhaps, or the current?

being totally frank i dont understand what "maximum" or else really means, so i really cant answer you - when i ready the API it seems to me increment and value are the same

can you please explain me in a few words this:
the maximum value of the adjustable object

what is this maximum value? means the width? or perhaps the increment?
thanks in advance
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
miguel lisboa wrote:>>If I don't understand a question its generally because its a poorly worded question. By the way I was the only person who even made an attempt to uderstand what you where asking in that question, so again don't blame me, look in the mirror

your arrogance blinds you - go back again and check how clearly stated (since the begining) was what i intended; you'r the one who is a poor reader - my luck...

Guys, be nice. I will have no more of these attacks, no questions asked.


Miguel, I tried to let you find out by yourself, but apparently you are not getting my hints.
The value for a scroll bar is the amount by which it has scrolled. The minimum is 0, the maximum is determined by the preferred size of the component inside the JScrollPane*. To scroll all the way to the left from code you set the value to be equal to the minimum. To scroll all the way to the right from code you set the value to be equal to the maximum.


* For JScrollBars that are not part of JScrollPanes you need to set both the minimum and maximum manually.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
Rob Prime wrote:(...)
Miguel, I tried to let you find out by yourself, but apparently you are not getting my hints.
The value for a scroll bar is the amount by which it has scrolled. The minimum is 0, the maximum is determined by the preferred size of the component inside the JScrollPane*. To scroll all the way to the left from code you set the value to be equal to the minimum. To scroll all the way to the right from code you set the value to be equal to the maximum.


* For JScrollBars that are not part of JScrollPanes you need to set both the minimum and maximum manually.

thank you Rob - i'm gonna try it right now and let you know
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
there is still something i'm missing here, though this code answers my basic requirement:

in this code i manually set the label's preferredSize
but, as the images i display have ramdom sizes, i tried setting it programatically:

and now i get it all messed up
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
Don't set the minimum or maximum of the scroll bars, those determine how much you can scroll. The out-of-the-box settings are good enough. Change only the value itself:
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
oops - i have a typo in line 18: its label, not labelGrafico, but the result the the same
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
I just found that my code works - after the component has already been shown. Consider the following example:
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
thank you again, Rob
from what i understand we got it going when manually setting label's preferred size: but, is there a way of adapting it to ramdom fotos sizes?
i tried my way of using foto width and height but it doesnt work
the problem is that i need an automated way of setting label's preferred size, else i get some pictures truncated - if i set preferred size much wider then i get blank zones in display area
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Report post to moderator
Miguel, I tried to let you find out by yourself, but apparently you are not getting my hints.


You did the exact same thing in his last posting. You ended up spoonfeeding the answer as he yet again refused to post a SSCCE.

I just found that my code works - after the component has already been shown. Consider the following example:


And in order to come to that realization YOU had to write your own SSCCE. Again spoonfeeding the answer. You should NOT have to spend that time.

If Miguel had spend 5 minutes to create a SSCCE like that he would have had the answer hours ago. It should not take 20 questions to solve a problem.

i tried my way of using foto width and height but it doesnt work


Even with your working SSCCE, Miguel still has problems because we don't know exactly what he is trying to do. So once again he is verbally trying to describe the problem. It never ends...

How does that describe the problem? We have no idea what the foto width and height are. Or what layout manager is used etc., etc..

"If you give someone a fish, they eat for the day. If you teach someone to fish they eat for life".
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
Bartender Rob: please get me rid of this arrogant blind man!
Rob Camick wrote:(...)

i tried my way of using foto width and height but it doesnt work


Even with your working SSCCE, Miguel still has problems because we don't know exactly what he is trying to do. So once again he is verbally trying to describe the problem. It never ends...

How does that describe the problem? We have no idea what the foto width and height are. Or what layout manager is used etc., etc..

"If you give someone a fish, they eat for the day. If you teach someone to fish they eat for life".

he doesnt ever care to read what people posts!!!:
miguel lisboa wrote: (...)
but, as the images i display have ramdom sizes, i tried setting it programatically:

 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Report post to moderator
he doesnt ever care to read what people posts!!!:


You posted a few random lines of code. It is not a SSCCE. We don't know the context of how that code is used in the program. It may not seem important to you, but it is important in the context of problem solving.

You where given a working example which proves it works. If your code doesn't work then its is up to you to compare the differences. We can't do that because you haven't posted your SSCCE showing how you have applied the suggestions given in this posting.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
you were again caught twistting (to say the least) the facts:
>>We have no idea what the foto width and height are
now you come talking about random code

i'm really tired of you, Camick - you have to solve your inner problems elsewhere, i'm not gonna help you in any way
for one last time: have a merry christmas!
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Report post to moderator
I don't have any problems to work on. You are the one with the problem and its not going to get solved because we don't have enough information to work with. Why are you wasting out time posting a question if you won't provide the information we need to help you?

Again, by definition when you have a problem you don't know what is causing the problem. Therefore you don't know what code is or isn't important. You already know that order of code execution is important as Rob has demonstrated in his SSCCE. Your SSCCE is different, but for some reason you are keeping the code top secret (not that is matters to me if you post it because I've given up, but it might matter to someone else).
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
miguel lisboa wrote:thank you again, Rob
from what i understand we got it going when manually setting label's preferred size: but, is there a way of adapting it to ramdom fotos sizes?
i tried my way of using foto width and height but it doesnt work
the problem is that i need an automated way of setting label's preferred size, else i get some pictures truncated - if i set preferred size much wider then i get blank zones in display area

i got it solved though not in the fanciest way
the one catch is that i need to setPreferredSize twice, one of which manually

here it goes:
scroll creation:

i just needed a width equal or more then scroll's width in order to avoid blank zones when displaying random sized images
method i use to display the images:
this way i have a case solved, thanks to you, Rob Prime
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Report post to moderator
So you got some hack to work, but you don't know what the original problem is or why the hack works? So the next time you have a problem you still won't know how to solve it because the problem will manifest itself differently.

Its amazing that a problem that should take 5 minutes to solve took a couple of days and 15 replies.

Great solution, keep up the good work.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
Rob Camick wrote:So you got some hack to work, but you don't know what the original problem is or why the hack works? So the next time you have a problem you still won't know how to solve it because the problem will manifest itself differently.

Its amazing that a problem that should take 5 minutes to solve took a couple of days and 15 replies.

Great solution, keep up the good work.

this forum should have a garbage collector to clean your sick and useless posts: for example, in this topic you posted 8 valueless times and forced me to correct you another handuful of times
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Report post to moderator
Sorry, almost every posting I've made has been helpfull because it tried to explain the value of a SSCCE.

You still don't get it and you still haven't learned anything about Java or has Swing works for future problems.

Your solution is terrible, there is absolutely no reason to be playing around with the preferred size of the label (especially doing it twice). That was a bad example Rob gave you and will lead you to bad habits, like the solution you've come up with.

If you had spent half the time that you wasted with all you useless comments towards me you would have been able to create and post a reasonable SSCCE and you might actually have learned something.

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
Rob Camick wrote:Sorry, almost every posting I've made has been helpfull because it tried to explain the value of a SSCCE.
(...).

sorry, but this first sentence made me laugh a lot, thank you

you'r totally incoherent: first you said i had no ssscce, that i described things only verbally, then i already had a sscce, now you'r talking about a reasonable sscce...
as anyone can conclude from your last ten posts you'r absurdly obssessed with sscce's - but that's your option
Rob Camick wrote:(...)Your solution is terrible, there is absolutely no reason to be playing around with the preferred size of the label (especially doing it twice). That was a bad example Rob gave you and will lead you to bad habits, like the solution you've come up with.(...)

when you were corrected by Rob Prime, you had a typo; now, is Prime who gives bad examples... hmm...

i still stand were i was: your posts are totally useless, and, as long as you keep in that mood, i consider my conversation with you terminated
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Report post to moderator
first you said i had no ssscce, that i described things only verbally


Correct, you have NOT posted a SSCCE.

then i already had a sscce, now you'r talking about a reasonable sscce...


No, you still have not at any time posted a SSCCE. None of the code you have posted is COMPILEABLE. So you obviusly haven't read the link provided. If you forget where the link is then you can search on Google, it the first link, that how common the usage of a SSCCE is, to every one except for you apparently.

when you were corrected by Rob Prime, you had a typo


No idea what you are talking about.

now, is Prime who gives bad examples


Well, it wasn't a bad example at the time, but it turned out to be a bad example because you don't understand the example. There is no reason to set the preferred size of the label. It will default to the size of the Icon. Rob just did a "quick and dirty" example to manipulate the preferred size of the component to force the scrollbars to appear. You apparently don't understand that concept and are now manipulating the preferred size in your solution, which as I mentioned earlier is the wrong approach.

Again every posting I have made has been constructive, but you choose to ignore the advice.

"You can lead a horse to water, but you can't force it to drink".
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
Rob Camick wrote:
when you were corrected by Rob Prime, you had a typo


No idea what you are talking about.

i'll refresh your selective memoire:
here:
Rob Camick wrote:(...)
You will need to use the table.convertRowIndexToView(...) method to make sure your code is changing the view colors.

If you need further help then you need to create a SSCCE (Short, Self Contained, Compilable and Executable, Example Program), that demonstrates the incorrect behaviour.

Rob Camick wrote:(...)
you don't understand the example. There is no reason to set the preferred size of the label.

too late again: a few hours ago i private messaged Prime telling him all about nullLayout and setSize() - just check with him

dont be stubbornly arrogant, dont play games - go just right ahead with the info the poster needs
you know? not everyone is a good teacher - being a good teacher is a gift (something you obviouly miss); he has to have the delicate sensibility to clearly understand the boundaries of pupil's knowledge as to give him the strickly (and) necessary info in order to put him on the right track, not the opposite - demanding absurd amounts of knlowledge the pupil obviously lacks

"Whoever undertakes to set himself up as a judge of Truth and Knowledge is shipwrecked by the laughter of the gods."
Abert Einstein
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Report post to moderator
too late again: a few hours ago i private messaged Prime telling him all about nullLayout and setSize() - just check with him


I have no idea what this has to do with anything, you don't use a null layout the label when you add it to a scroll pane so that comment makes no sense.

But anyway you are yet again you are proving my point that we don't have the complete picture, becuase you are releasing the details of you code one step at a time. So there is no wonder we can't follow what you are doing.

go just right ahead with the info the poster needs


What part about I can't provide you with a solution, because I can't see your code do you not understand? The problem with your code could be any number of reasons. It is not our job to guess what you are doing. It is your responsibility to post a coherent question with all the information, hence the need for a SSCCE.

you know? not everyone is a good teacher


All I asked was for you to post your code so we can see it. What is so difficult about that to understand.

For the tenth(?) time you have not done this. The only thing I'm trying to teach you is how to post code. So you are right I'm a flop.

And by the way, you seem to have forgotten Rob's quote:

Miguel, I tried to let you find out by yourself, but apparently you are not getting my hints.


So two regulars of the forum who have helped numerous other aren't able to communicate with the pupil and its the teachers fault? Yet when we ask for more information and you don't provide it, it is still our fault? Simply amazing!
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
and again, you'r tiring me

dont you understand i already fixed my code?
werent you told to check with Rob Prime?
as a consequence of using nullLayout, i 'm actually using setSize() (and just once) to fix all my problems - and in a clean manner
and, as i said before, that was done hours ago - so i'm not asking for any kind of help from you - i was just suggesting a few good practices when helping others - in general, see?

>>All I asked was for you to post your code so we can see it
for what purpose? remember your "help" when i posted code? - i do

Rob, you must admit - its not name calling, but the sheer truth: you are arrogant with people, you misread people's posts, you'r obssessed with ssscce or whatever, and most important, what you call "help" most of the time is pure torture - so, useless, to say the least
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Report post to moderator
i posted before reading your edit

i agree: its amazing how you, time and time again, keep twistting things - but, yes, Prime gave me a hint that wasnt enough for me, and he (very correctly) went on giving furhter information; nothing compared with you

and also its a bit sad that you have to hide behind Prime to (try to) atack me once again
no problem, i understand it - you lack of arguments when by yourself
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!