JFXPanel resizing - javafx-2

I'm currently testing the integration of some JavaFX2 components in to a swing application.
I have a JFXPanel which contains an HBox Pane which holds a list of buttons. What I'm trying to achive is to hide and show some buttons and resize the HBox and the JFXPanel. Problems I'm facing:
When a hide some buttons, the HBox does not resize itself.
I can modify HBox size (using resize method) but I must specify the
dimensions (no automatic resize) the underlying JFXPanel does not
resize. The autosize method does not seem to acomplish this either.
So, How can I resize it ? I'm using FXML and controllers so I see no easy way of resizing the JFXPanel but I'm trying to see how can I manually set it, but how can this be done automatically ?
By the way, I'm not using absolute positioning in swing (no layout manager).

Try to remove the button from the HBox, not just hide it.
I have done the same with a ToolBar & it update its size when buttons are added or removed.

Related

Vaadin 8 View: No horizontal scrollbar on window resizing

I have a Vaadin 8 application with several views.
public class ViewName extends Panel implements View {
There is a VerticalLayout as main layout in the panel.
public ViewName() {
setSizeFull();
VerticalLayout mainLayout = new VerticalLayout();
setContent(mainLayout);
Then I have many different layouts (HorizontalLayout, GridLayout) or Components such as Label being added as components to the mainLayout. For the HorizontalLayouts I often do the following to use the full width of the screen:
hLayout.setWidth("100%");
I have a lot of icons, grids etc. Everything is OK as long as I don't resize the window.
When I resize the window to a small size I get a mess (icons, text etc. on top of each other) and no horizontal scrollbar. (However, the grids get horizontal scrollbars.) I have tried many things to fix this. If I add
mainLayout.setSizeFull();
or
mainLayout.setWidth("100%");
I have a mess on the big screen already. I also tried the CSS for the mainLayout as described here. I get several scrollbars but none for the window itself!
The only component that resizes correctly is a Label added to the mainLayout, e.g.:
Label title = new Label("Some text",ContentMode.HTML);
title.setWidth(100, Unit.PERCENTAGE);
mainLayout.addComponent(title);
mainLayout.setComponentAlignment(title, Alignment.MIDDLE_CENTER);
I also noticed that anything in a GridLayout seems to stay in place after resizing but is not vissible since I have no scrollbar. However, icons in a HorizontalLayout get on top of each other.
What is wrong? Please, I need a general instruction on which layout I should use as main layout for my view panel, how to size the components and how to get ONE horizontal scrollbar for the main window if necessary.
The problem is that you are setting the width of your mainLayout to the width of your view. This means, that your mainLayouts width will never be bigger than your views width. So no scroll bar will appear.
According to the information you posted, changing your mainLayouts width to undefined should fix the problem.
mainLayout.setWidth("-1px");

What is QT-Creator's equivalent to WinForms Dock-Fill?

I have a QTreeView widget placed inside a QDockWidget:
I want to set the properties of the QTreeView, that it automatically fills the whole available client drawing area (similar as WinForms DockFill property).
How can this be achieved with the QT-Designer?
Note: I've been playing around with the QTreeViews sizePolicy properties. If these are set to Expanding (as is the default) the accepted answer works out out of the box.
In Qt Designer, right-click the dock-widget, and then select Lay out -> Lay Out Vertically from the menu. Or you can just click on the dock-widget to select it, and then use the equivalent layout toolbar buttons.
If you want to maximise the space taken up by the tree-view, select the first child widget of the dock widget (it will probably be shown as dockWidgetContents in the Object Inspector pane). Then scroll down to the bottom of the Property Editor, and reset all the margins to zero.

Android UI: Button with shape inside?

I need to create a button that looks like this:
button
I was hoping to create it without using images. To create the pink part, I wanted to use a drawable.
How can I include a shape drawable within a button?
You can create a Layout, set background color for that layout as you wish. In that layout add two textviews. Set background for one layout pink. add another under the first textview. Then you can set onClickListener on layout. It'll work same as that of button and it'll be easy to change colors and text programatically.
Try using an ImageButton and setting android:src to point to your ShapeDrawable resource.

PyQt4 Qt Designer making dynamic GUIs

I'm trying to figure out a way of using Qt Designer to make a dynamic GUI. For example, let's say I have a main window with a horizontal layout. I have a push button on one side and an empty area on the other. When I click the button the empty area will be filled with a widget that I've made in Qt Designer. When the button is pressed again the widget will be replaced with another widget that I've made in Qt Designer. Would I have to go about making all my widgets, to fill the empty area, custom widgets?
I've tried setting the parent to the empty are, but on the second change I get this
QLayout: Attempting to add QLayout "" to QWidget "t2", which already has a layout
So then I tried deleting the layout but still see the old widget underneath the new one and the layout is now messed up.
help please
Never mind, figured it out. Simple really. Use QStackedWidget and as for the UIs made in Qt Designer wrap that in a class that inherits from QWidget.

Horizontal button group inside anchor layout

There is a panel with anchor layout used for vertical sizing.
Inside the panel there is a horizontal buttongroup.
Is there a way to set fixed width or better make the width depend on buttons?
In my case it is always stretched to the size of the window.
There is the same problem with the grid inside the panel.
Thank you.
Making the width dependent on the buttons is handled by the layout itself. If you have an hbox layout, each of the items inside the container (say, buttons) will automatically occupy the width.

Resources