The problem occurs when -fx_background-position:0 -40 is set either by a loaded style.css or in code via an action handler.
In my example the background image is set on an hbox width one cell. When adjusting position the background image, the image moves outside of the limits/borders of the hbox, up in this case, and covers an area over the position of the hbox. In my case it covers action buttons so they don't fire.
How to not show the part of the background image that is outside of hbox?
If your overlapping hbox should not react on MouseEvents at all, you can add hbox.setMouseTransparent(true);
Hope that helps.
Related
I'm trying to create a javafx application (in scenebuilder).
How to get transparent stage, with solid items (buttons etc) on it? As it is done in Windows 10 calculator. The buttons are solid but the rest of the pane is transparent.
Thanks in advance.
To do that, first, you need to put the scene in a transparent Stage :
myStage.initStyle(StageStyle.TRANSPARENT);
Be aware: if you do this, you need to use your own exit button, minimize buttons, because the titlebar will be gone.
Then, change the alpha channel of your scene to your desired, say 0.5:
scene.setFill(Color.rgb(0,26,0,0.5));
and finally, the root node's Background needs to be empty:
root.setBackground(Background.EMPTY);
You are done. Now you can change the translucency of your application through the alpha variable.
I have a pane that contains image content which changes during scrolling. The content is properly updated via a scrollwheel event because I implemented a wheel listener which repaints the image before setting the new scroll value.
However, when the user drags the scrollbar handle with the mouse, the image content was not being updated during the manual drag-scroll. So I implemented a timer which grabs the current scroll value and repaints the content given the new scroll position.
This solution however (despite 10 millisecond adjustments) results in a jumpy scroll experience. The image moves (without the necessary image adjustments) and then gets corrected after-the-fact every 10 milliseconds.
I had originally tried an adjustmentlistener, but it only gets the event after the handle is released. How can I live-update the pane content during a jscrollbar handle drag BEFORE the scrollbar machinery starts to simply move my content as if it was a static image? Can I somehow give the scrollbar machinery a clue that content has changed or something every time it tries to redraw the content? Or can I disable the scrollbar's ability to move the image and just rely on my timer to do it?
I would recommend that you add a ChangeListener to the JScrollBar's model, a BounderedRangeModel, and then based on the value of the model as well as its maximum and minimum, change your image. If you're swapping images, the easiest way to do this is by swapping a JLabel's ImageIcon.
I am creating a desktop application in Java with lots of customized UI.
It also has a breadcrumb.
I've extended JButton class to customize it for my Breadcrumb buttons.
This is the screenshot of expected breadcrumb.
http://puu.sh/4MtvZ.jpg
The background of this breadcrumb is an ImageIcon.
But now, I am not able to perfectly align the JButton text over this background icon.
This is the screenshot of actual breadcrumb.
http://puu.sh/4MtDc.png
I've used following code to align the text.
setHorizontalTextPosition(CENTER);
setVerticalTextPosition(CENTER);
So, is their a way that I can move this text in pixels to its right position?
And also, I want root breadcrumb button "Schemes" to overlap some part of its preceding breadcrumb button "2000 Avenues" as shown in expected breadcrumb screenshot!
How can I achieve that?
Check out the Overlap Layout for one solution.
So, is their a way that I can move this text in pixels to its right position?
I don't understand this question. Why are you setting the alignment to center if you want it aligned to the left.
Edit:
I see. You are just using an Icon for the button outline and are then painting the text on top of the Icon. I thought your were using a custom shaped button with text). You can just use the default vertical/horizontal text position settings.
To shift the text to the left you can use:
button.setIconTextGap(10 - button.getIcon().getIconWidth());
In windows, Java, etc, the scroll pane scrolls the widgets inside. What I'm wondering is, how exactly does it do its scrolling? Does it change the location of each nested widget, or does it have a content widget that it moves around? Or is it something else? Also, when both scrollbars are present, how does it mask that little square at the bottom right? That square is sometimes used to resize. Is it a separate nested widget?
Thanks
I think it just changes the location of the widget, button, or thing-a-ma-bober.
But my second guess would be it just draws the components "outside" of the scroll pane without being seen and when you scroll it just redraws dynamically.
I want button in vertically, for that i can extend the height and shrink the width of that button. But the text of the lable of buttons are in the form of horizontal only. For that can i rotate the whole button vertically and is it possible?
Rotated Icon shows how the text and icon can be rotated on the button (or any component that uses icons.
The easiest way to do this would be to pre-rotate the labels and just have it as an image on the button.
You might also want to take a look at this solution given in sun's forum for rotating a JButton.
You should be able to do this with scene graph: https://scenegraph.dev.java.net/