scrollpane

JavaFX How to scroll ScrollPane to have node in the middle of view port?

痞子三分冷 提交于 2019-12-08 20:56:40
问题 I have to create timeline with line showing current time. I'm using AnchorPane with added line placed in ScrollPane. I need to simulate 1 day, scrollpane width is ( 2880px, every 60px is one hour). My limits are ( previous day 12hour, and next day 12 hour). Moving my line is working fine. All I need to do is to set line in the middle of view port and move content under it. For moving line i'm using this method: scrollPane.setHvalue( line.getStartX() - anchorPane.width); It is working "kind of

How to access ScrollBar in a ScrollPane? (JavaFX)

纵然是瞬间 提交于 2019-12-08 13:22:44
问题 I want to access the ScrollBar within a ScrollPane to find the values and do some operations such as increment on click and some other stuff. I cannot find any way of accessing the horizontal and vertical scroll bars. I have tried the solutions to this link but I had no success: How to access the Scrollbars of a ScrollPane 回答1: Your problem is that the solution in your link works only after you added the ScrollPane to the stage. Try this: ScrollPane scrollPane = new ScrollPane(); primaryStage

Get shown component in JScrollPane

微笑、不失礼 提交于 2019-12-07 06:56:23
问题 I have a JScrollPane containing a JPanel. I fill this JPanel with many buttons. Is there any possibility to get the currently shown buttons? I know I can access the children of a JPanel via jpanel.getComponents() but those are all components in this pane; I want only the ones that are currently on screen. 回答1: I assume that this container is already visible on the screen, then I suggest 1) to extract JViewPort from JScrollPane, 2) addChangeListener to JViewPort 3) each visible JComponent(s)

JavaFX - Zoom relative to mouse position

Deadly 提交于 2019-12-06 10:37:06
I can't get working zoom relative to mouse position in JavaFX. I've read and tried rewrite this and this , but it's not working. Can't scroll viewport using scrollPane.setViewportBounds() . I must use scrollPane.setHvalue() and scrollPane.setVvalue() , but can't get right recalculation to keep the same pixels under the mouse cursor. Current code keeps scrollbars positions: ZoomHandler.java import javafx.event.EventHandler; import javafx.scene.control.ScrollPane; import javafx.scene.input.ScrollEvent; import javafx.scene.layout.Pane; public class ZoomHandler implements EventHandler<ScrollEvent>

Scrollpane line chart with fixed view y axis JavaFX

我们两清 提交于 2019-12-06 09:05:04
问题 I'm trying to make a scrollable chart where the Y-axis stays in view regardless of the cursor position in the scrollbar (by default since the Y-axis informations is at the end of the view, you would only see it after you scroll enough to see the end) Here is an example what Im trying to accomplish: Notice that even though the scrollbar position is midway-through, the Y-axis text(price) still remains in view I looked around the web and was only able to find a single example of something

Get shown component in JScrollPane

南楼画角 提交于 2019-12-05 10:13:57
I have a JScrollPane containing a JPanel. I fill this JPanel with many buttons. Is there any possibility to get the currently shown buttons? I know I can access the children of a JPanel via jpanel.getComponents() but those are all components in this pane; I want only the ones that are currently on screen. I assume that this container is already visible on the screen, then I suggest 1) to extract JViewPort from JScrollPane , 2) addChangeListener to JViewPort 3) each visible JComponent(s) returns Rectangle 4) and Rectangle#intersects returns Boolean value if is JComponent(s) visible or not in

JavaFX 2: Making a ScrollPane automatically scroll to the edge after adding content

纵然是瞬间 提交于 2019-12-04 13:59:58
问题 Using JavaFX 2, I have a basic example of a ScrollPane that contains an HBox of Label s. I want to be able to add a Label to the HBox , and simultaneously scroll to the right edge of the ScrollPane so that the newly added Label is visible. My current method uses the setHvalue() to set the scroll position and getHmax() to get the maximum scrolling distance allowed. The problem is that when I set the scroll position using getHmax() , it is as if the just-added Label is not computed in the

JavaFX setFitHeight()/setFitWidth() for an image used within a scrollPane disables panning

北城余情 提交于 2019-12-04 04:44:17
问题 So I am creating a map in JavaFX and I would like to have the whole map visible at times. However, the issue is that after I set the imageView to fit the screen size then adding it to the scrollPane my zoom function works fine, but once I zoom in I am not allowed to pan around the image. Below is the code that I have written. package gameaspects; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import javafx.application.Application; import javafx.scene.Scene; import javafx

JavaFX 2: Making a ScrollPane automatically scroll to the edge after adding content

只谈情不闲聊 提交于 2019-12-03 08:47:23
Using JavaFX 2, I have a basic example of a ScrollPane that contains an HBox of Label s. I want to be able to add a Label to the HBox , and simultaneously scroll to the right edge of the ScrollPane so that the newly added Label is visible. My current method uses the setHvalue() to set the scroll position and getHmax() to get the maximum scrolling distance allowed. The problem is that when I set the scroll position using getHmax() , it is as if the just-added Label is not computed in the ScrollPanel 's scroll width. Is there a way that I can update this inner width before trying setHvalue ?

Sizing a JScrollPane in a JTabbedPane in a JFrame

a 夏天 提交于 2019-12-02 11:44:43
I understand from this post Don't Set sizes on a JComponent that you dont set preferred sizes on any component and instead let the layout manager do this for you. My question is, I have a JPanel that I put into a JTabbedPane into a JFrame like this JFrame frame=new JFrame(); JTabbedPane pane=new JTabbedPane(); pane.addTab("Tab 1",new JScrollPane(getJPanel1())); pane.addTab("Tab 2",new JScrollPane(getJPanel2())); frame.setContentPane(pane); Now in this case the JTabbedPane will take the size of the maximum sized component you add to it. Because of this my JScrollPane does not show up at all. I