0

I want scrollable panes.

Please, have a look at the picturepicture As you can see at the Navigator, I used Tabbed Pane, then placed Scroll Panes on it. Then placed Panel on it. And then added Lables. Looks like I'm trying to reach my left ear with my right foot. But without the jPanel1 my lable occupied the whole panel size.

Well now my scrollable panel doesn't work well.

It is visible at this picture.

Well, I made the window narrow. But the scroll bar at the bottom doesn't allow me to reach what is behind the border further on the right. And this scrollbar seems strange. It has only t left arrow. No right one. And no vertical scroll bar if I make the window less high.

Could you give me a hint how to make scrollable windows?

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
Trts
  • 985
  • 1
  • 11
  • 24
  • I'm not exactly sure what you're doing, but first you said that you placed a scroll pane, then a panel in the scroll pane, then a label in the panel. That should work. Then you said _"But without the jPanel1 my lable occupied the whole panel size."_ Those two things kind of contradict. The first part is the right way to do it. `ScrollPane -> JPanel -> Components`. Without the panel, you're making the label the viewport of the scroll pane. – Paul Samsotha Feb 22 '14 at 15:36
  • @peeskillet, I can't organise Tabbed Panels. I tried what you suggested. It works, but without tabs. – Trts Feb 22 '14 at 15:46
  • So you want to have each tab have it's own scroll pane? I don't get what the problem is. – Paul Samsotha Feb 22 '14 at 15:50
  • @peeskillet, about occupying the whole panel size. It looks likt this [link](http://yadi.sk/d/jPRIMBXGJMbwo) As you can see, the lable is vertically centered. And one can't move it anyhow. So, it is glued to its place and occupies the whole pane. You seem to be unable to add anything. – Trts Feb 22 '14 at 15:52
  • Each tab will only hold one component. That's why you need to use a container like JPanel or JScrollPane with JPanel. With a JLabel, that will be the only component. – Paul Samsotha Feb 22 '14 at 15:54
  • Well, now I tried to do what you suggest. ScrollPane first. Then everything else (look at the Navigator). Here is what I get: [link](http://yadi.sk/d/tOBSB5mWJMdNa). Look, no scroll bars. – Trts Feb 22 '14 at 16:02
  • The default scroll bar policy is to only show when needed. The scroll pane currently doesnt have enough components for the scroll bar to be _"needed"_. If you always want it to show, set the property of the scroll pane `verticalScrollBarPolicy` and `horizontalScrollBarPolicy` to `ALWAYS` – Paul Samsotha Feb 22 '14 at 16:06
  • @peeskillet, why the horizontal scroll bar is not needed now? You can see in the picture that there are two lables. The right one is outside the visible area. I tried to make scroll bars always visible. But here is what I have got: [link](http://yadi.sk/d/8kdf3eICJMfPf). If I make the window a bit narrower, the vertical scroll bar will disappear completely. But why should it behave like this? The window is not the smallest possible. It looks like it is of a normal size. So, again this behaviour is not understandable to me. – Trts Feb 22 '14 at 16:17

1 Answers1

0

I'm not sure what you're doing wrong this is the results I get when I do only this and nothing more.

  1. Drag and drop a tabbed pane to the frame
  2. Drag and drop a scroll pane to the tabbed pane
  3. Drag and drop a panel to the scroll pane
  4. Drag and drop a label to the panel, and another label to the bottom.

enter image description here

Resize to smaller frame and scroll bars appear

enter image description here

Navigator Window

enter image description here

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
  • the problem seems to be that my JFrame and the actual window in Windows don't coincide. My JFrame is about a quarter of the screen size. Please, have a look at what I get (pictures for you to download): [link](http://yadi.sk/d/ssbwEEoqJMkVi). In other words, your method seems to be working. But the result is not satisfactory: I want any frame coincide exactly with the window in Windows. Now I face the situation when I don't have scroll bars depending on the window size in Windows. Could you recommend anything? – Trts Feb 22 '14 at 16:49
  • I don't think I understand your requirements exactly. – Paul Samsotha Feb 22 '14 at 16:58
  • please, have a look at the pictures [link](http://yadi.sk/d/ssbwEEoqJMkVi). Let us scrutinize what we have at the picture ScrollBarsAppear. Well, the scroll bars really appear. We can see the second lable at the bottom right corner (half hidden). But the border of the whole Windows window is far further to the right. It is not good by itself. Then let's have a look at the picture ScrollBarDisappear. We again can see the half-hidden lable2 at the bottom right corner. But now without any scroll bars. At the picture AppearAgain we can see that scroll bars really appear again. – Trts Feb 22 '14 at 17:04
  • Well, what I want to say is that I would like the JFrame border to coincide with the border of the window in the operating system. Maybe then scroll bars appearance will not depend on the size of the Windows window. – Trts Feb 22 '14 at 17:05