If I create a button in scenebuilder and want to use this button in my javacode, what is the ID of this button?
I've tried with writing a fx:id, lets say button1.
when trying Button button1 = new Button(); I cant access this ID, is there any possible way to do this?
Related
I have a QWizard with 2 custom buttons (on top of the Back\Next buttons).
I wish that a click on my custom button will change to another QWizardPage.
How do I do that?
Thanks
That would be doable by connecting the custom buttons clicked signal with a slot which handles moving to next page.
QWizard wizard;
wizard.setButtonText(QWizard::CustomButton1, "Custom button");
wizard.setOption(QWizard::HaveCustomButton1, true);
QObject::connect(&wizard, &QWizard::customButtonClicked, [&]
{
wizard.next();
});
The code above would create a wizard with a custom button which would function like the default "next" button. If you want to create a dynamic (as opposed to linear wizard which it is by default) you would need to reimplement QWizard::nextId(). Please see:
https://doc.qt.io/qt-5/qwizard.html#nextId
I have 64 buttons.
I want when click on one of Button change color other button and other Button each time diffrent from Previous.
I want make ottlo game and this part of code for offer Authorized houses.
thanks
You can create an onClick method, and set this all of your buttons.
In the onClick method, you can get all of your buttons by scene.lookup() method - you need to set styleclass for this buttons. For example: the css class is my-colored-buttons, then you can call scene.lookup(".my-colored-buttons");
Another solution is add all of yout buttons to your controller. This is not too good solution I think, hard to maintain.
#FXML
private Button btn1;
#FXML
private Button btn2;
#FXML
private Button btn3;
...
After you get all of the buttons, get current button from event variable, and change only the other buttons color. So the currently clicked button will not change.
Is there any way to create a custom PopUp in JavaFX? I can't use tooltip, since I would like it to appear on double click, also I would like a different style than the standard tooltip.
My demands for the popup are:
1. If the user double click, show the popup
2. if the user clicks outside the popup, hide it
See this guide on all the different types of popups.
Use Popup.
Popup popup = new Popup();
// add content (you can add as many nodes as you want)
popup.getContent().add(new Label("Hello Popup!"));
// show (move this to the double-click listener)
popup.show(primaryStage);
// hide (move this to the click listener)
popup.hide();
I have dynamically created link buttons in grid view and assigning event for it,
lb.Click += new EventHandler(LinkButtonClicked);
Event is not firing if I change page index change (on click of '2' below grid view) and click on link button present in grid view.
It is working fine if I do not change the page index i.e. without clicking on '2' of grid view, clicking on link button present in grid view
I am not able to find out reason for this. Please help
Thanks in advance!
I think it is better to create the linkbutton inside markup in a grid template column.
if you have to do it in code, try to unsubscribe the event handler then subscribe again:
lb.Click -= new EventHandler(LinkButtonClicked);
lb.Click += new EventHandler(LinkButtonClicked);
I would like to know how we can write buttion press event in controller.
i.e. if the condition is satisfied, button is pressed.
this.getView().byId("idHeadBtn").press
I hope that I understand you correctly. You want to add a button handling for a particular button right? If so, you could do this:
var btn = this.getView().byId("idHeadBtn"); //or sap.ui.getCore().byId("idHeadBtn");
btn.attachPress(/*pressHandler*/);
For more information you could double check it: https://ui5.sap.com/#/api/sap.m.Button/methods/attachPress