java - add a scrollable jpanel to a gridlayout -


I am creating a label-filled grid. One of them has html-text and the maximum format should be resized and should be scrolled. I found out how to add an JScrollPane but it stays at a height of one row, even if I give it a size of 400x400 it can not be resized ...

By removing GetViewport () The same gives results.

  JPNEL grid = new zpn (new grid layout (1,2)); // First Grade of Grid Grid. (New JLab ("title")); // Second cell of the grid, this should be one of the scrolling JScrollPane scroll = new JScrollPane (); Scroll.getViewport (). SetSize (400, 400); Scroll.getViewport (). Add (new jlab (" long 
html
text ;)); Grid.ed (scrollworse, border layout.c.a.);

Any ideas?

Thanks a lot ...

Grid layout is the preferred size of those components Does not respect who keeps it out. Its aim is to make all grid cells equal size. One option is to use GridBagLayout, although I personally would suggest that (in my opinion) is as easy as you can not go wrong with the more powerful and more intuitive ones.

Border layout, as a side note. Sean is a border used for border layout and it is not compatible with the grid layout. When an ingredient is added to the owners of the grid layout, you do not need to provide obstacles. The ingredient is added to the left to start from the upper left corner cell using gridlayout.


Comments