I was creating a GUI using Java Swings.
I decided to add a text box with vertical scroll bar to it. I also have few more other components to be added and my text box with scroll bar comes after some of them.
So I started adding one by one,
//now the turn of description text box
I compiled and ran the program. The output was weird.The descriptionTextbox is coming without scrollbar and as I continue hitting ENTER in it, it is expanding and exceeding even the frame size.And my poor scrollbarForDescriptionTextbox is lying idly next to the descriptionTextbox .
I was surprised why it is happening like this and kept looking at the code over and over again. I spent sometime even yesterday night before going to bed.But I couldn’t get it.
Today morning at 5:30 I just opened my laptop to see it again. I found the mistake I did in less than 2 minutes.
Here is the catch:
Initially I said ,
JScrollPane scrollbarForDescriptionTextbox = new JScrollPane(descriptionTextbox);
now that I created scroll bar for descriptionTextbox,I should only say
instead, I said
which is a blooper! Though its OK for compiler, I didn’t get my expected output.