javafx make button fill width - java

i have one button in a borderpane. I want the button to be stretched out horizontally so it fills the entire width.
how can i do that?

Just set the maxWidth property of the button to MAX_VALUE.

Related

How can I make a dashed shaped Tab selection using buttons in Android?

I am using the button as the side tab menus for item like 'Home','Games',etc. I can't figure out how to get such rectangle shape selection when button is pressed.
Can I use drawable res for the same. Please help.
You should use a custom drawable with left margin rectangle drawable 1dp to 5dp width. I think you already have the logic for toggling the current tab's button to only have this drawable.

Java: How to center a button in a layout manager and have it rejust to the center upon resize?

I have a button inside a JPanel with both, a width and a height of 70 and I can only seem to center it while keeping it's size in a null layout. While I want it centered like that when resizing the button will stay at it's exact cords. Is there a better layout that can easily acheive this or am I able to do it in a null layout?
Use GridBagLayout with anchor=GridBagConstraints.CENTER, fill=NONE, weightX, weightY=0
UPDATE:
See e.g. here

javafx background image position outside of hbox

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.

GWT - How to center contents inside ScrollPanel

I have a FormPanel inside a ScrollPanel. The ScrollPanel is located in the center part of DockLayoutPanel. I want to vertially and horizontally center the FormPanel inside the ScrollPanel. I tried a few ways to do this but no success.
I have tired putting a verticalPanel/horizontalPanel inside the scroll panel, and use it to wrap the formPanel. I set both scroll panel and horizontal panel to 100% width and height. However, the scroll panel is automatically resized according to the size of center part of DockLayoutPanel whereas the horizontal panel's size is always equals to the size of its child- form panel. So I cannot center the formpanel inside of horizontalPanel since their height and width are the same. I try to make the horizontalPanel's size be always the same as scrollPanel, but I have no idea how to do this. Setting horizontalPanel's size to 100% is not working.
So My question is this:
1.How do you center something in scrollPanel. I don't mind using css method if you know how to achieve this.
2.In my case above, is it possible to make the horizontalPanel to be always the same size as its parent container - scroll panel. If it is possible, my 1st question is solved then.
I had to center an image inside a horizontal scroll-panel. Sometimes I just have one image and sometimes there is a list of images to be centered and shown. I have fixed the size of the GWT image object and the width of the scroll panel.
I computed the scroll position inorder to center all the items and I used set scroll position (position can be -ve or +ve values).
When user scrolls the items then I would respect the user's decision and scroll them accordingly. However, if the user scrolls to extreme right of left, I would ensure that the scrolling positions are re-adjusted to scroll back to the boundary and not exceed it.
When the page is refreshed by scroll panel centres the items automatically.
In short, you need to center the items programmatically and by default the scroll panel would keep the items on one side (left and top).

can I rotate the button or label into vertically in java?

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/

Categories