Java : Scroll Over JScrollPane - java

I've got a vertically scrolling JPanel, on that JPanel are a couple of JScrollPanes, when the user scrolls down through the panel, if the users mouse goes over the JScrollPane they are no longer able to scroll the JPanel, the have to move their mouse off the JScrollPane and back onto the panel. It gets quite annoying after a while.
To this end is there any way to tell java to continue scrolling the parent JPanel unless the user clicks on the child JScrollPane and specifically tries to scroll it?

I believe what you're looking for is JScrollPane#setWheelScrollingEnabled(boolean handleWheel)

Related

Java - Scrolling JPanel with keyboard using Viewport doesn't work

I have a little issue with my program, so I ask for your help.
I added a JScrollPane in a JFrame and in that JScrollPane I added a JPanel. Scrolling that JPanel with my mouse works normally.
But, in an other script, there's a while(true) running, and it detects when I press the keys: W,S,A,D. And if it detect a key press, it uses:
mainWorldScrollPane.getViewport().setLocation();
//mainWorldScrollPane is my JScrollPane
to scroll the JPanel , but the problem is that it does not scroll the JPanel, it scrolls the ViewPort of the JScrollPane.
And this is what I get:
So, my question is:
Can somebody tell me how do I scroll the JPanel with those keys, not the //JScrollPane's ViewPort?
Thanks for your help!

How to view components outside the JFrame?

I have some JLabels which are not in view on the JFrame. My JFrame has the dimensions: 1366x by 750y. I want to put a few JLabels that are below these dimensions, i.e. at position 800y. It will be a JLabel which has the size 100x by 50y.
I want to have the label already declared and customised from the swing class. But I want to only add it to a scroll panel when I press a button. That way, the scroll panel will not scroll until you press the button. This is how it will work:
Panel scroll panel which doesn't scroll
Button is clicked
The label is added to the scroll panel
The scroll panel can now scroll. It will scroll because it is set to ASNEEDED for the verticalscrollbarpolicy.
The problem I have is that I can't see the label when it is under the JFrame in the design view of eclipse. Here is a photo:
How can I do this? Please ask for clarification if required.
EDIT
Now If I clicked on some other component above the currently selected label, the eclipse workbench area would scroll up and I wouldn't be able to scroll down to it. To find this label, I would have to find it in the Component Structures list on the left side. I want to be able to scroll the actual workbench area and I want to be able to see the text in that label which is circled.

JLabels move with border change

Basically I want to hover over a jLabel and change its border to Bevel (raised) so as to appear clickable. The problem is when I hover over it the border changes but it moves all my other jlabels, as soon as I remove the mouse pointer from it they move back to where they were. Been driving me nuts can't seem to figure this out.
The only way I've found to stop this from happening is using absolute layout, problem is when I resize my window it eats some of the jLabels. Also tried putting that panel with absolute layout inside another panel which has another layout like box or border layout.
This happens with any of my jLabels, what am I missing?

Netbeans GUI development sizing issue

I'm having trouble using CardLayout with a JPanel inside of a JScrollPane. Basically I have a main JFrame and a JPanel inside of a JScrollpane, and then a whole bunch of different JPanels that are acting as 'cards' and pop up on different button clicks. The issue is, that some panels aren't scrollable all the way down to the bottom in the JScrollPane, they only scroll to the point of the initial panel.
Can anybody with some experience with NetBeans tell me how to make sure that each panel is fully scrollable in the scroll pane? If you only know the java code for setting this option I'd appreciate that too.
Thanks.

gwt scroll pane that takes it size from the other components

I have a screen in gwt where a portion of the screen has a scroll panel. There is a header bar at the top and the rest of the screen is in a scroll panel.
Problem is I can only get the scroll bars to appear if I set the absolute height of the scroll panel. The content in the scroll panel is bigger than the scroll panel but the scroll bars don't appear unless I specify the size of the scroll panel absolutely. The problem with this is it does not take into account the size of the browser window...
Thanks, this answer helped me gwt-layoutpanel-size.
Basically, the bottom line is that if you want the scroll panel to resize and maintain the scroll bars all your parent containers must implement RequiresResize so that the scroll panel can listen for the event and act accordingly.
Your flexibility is severely limited when requiring this behaviour as you can only put the scroll panel inside elements that implement RequiresResize/Provides Resize which are the *LayoutPanels...

Categories

Resources