• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with scrollbar

 
GnanaPrakasam Rathinasabapathi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am trying to insert the textboxes inside the panel. I have problem with the scrollbar. Only few boxes are viewed through scrollpane.My code goes here


Please guide me.Thanks in adance.
Regards,
Gnanaprakasam
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
label.setSize(100, 100);

does not work if the panel has a layoutManager

as it is a JTextArea, it should be inside a JScrollPane, and, if necessary,
give the scrollPane a preferredSize, as you did with jPanel1
 
Rob Spoor
Sheriff
Posts: 20820
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JTextArea has a constructor that takes a number of rows and columns. If you use that, it will use that as its preferred size which will be honoured by some layout managers (like FlowLayout which is used by JPanel if you don't specify a layout manager).
 
GnanaPrakasam Rathinasabapathi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have tried the setpreferredsize() ,setautoscrolls() property also as you told. I cannot view the textarea boxes below the preferredsize of the panel in which the textarea are added.Please help me for viewing. Whether i need to check the size of the panel after the textarea components are added.(or)Is there any method to check the panel's prefferredsize after the components are added.Really got stuck with this .Thanks in advance.
Regards,
Gnanaprakasam
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also give the scrollpane a preferredSize (smaller than the panel's preferredSize)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!