Universal Robots Forum

Is it possible to create a custom popup message

Hello everyone.

As you can see in the title I want to create a popup who can work when the program is stop.

This popup will be used for confirm one action. In my case, I have created a Delete button for my parameters and I want a popup for saying " Would you really delete theses parameters" and I need a button OK and a button Cancel.

Is it possible ?

Thanks for the help, Defferrard Arnaud

Hello Arnaud,
you could use the script command: ‘var_1 = request_boolean_from_primary_client("")’ for your problem.

1 Like

Thanks for this quick answer I will try .

I have to put the script into “public void generateScript (ScriptWriter writer)” right?

if it’s the case how can I take a variable from my Java part and use this variable into the script?

Yes, the script command belongs in the generateScript()-Method.

If you want to make the received variable displayed for the user you can take a look at the cyclecounter-example and read into the ‘working_with_variables.pdf’ manual.

2 Likes

Hello everyone!

Is it possible to create a custom popup message with custom buttons (e.g. Save and Cancel)?

Thanks in advance for any help!

Hey I use the sendScriptWithButton samples for this .

If you have any question I am here for you.

Regards,

Arnaud

1 Like

Thanks for your reply!

In the sendScriptWithButton sample a simple popup created. Is there a way to rename buttons on the popup?
I need to create a popup with two custom buttons (Cancel and Start) and handle clicks on them.
Is there a way to do this?

Mh… You will have to create your own custom popup for this . the sendscriptwithbutton is using the popup from polyscope and if I’m right you can’t “modify” this popup.

Your popup has to work when the program is running or not?
If it’s not the case I can suggest you to create a div and show the div when your value is changed and once than you have pressed start or cancel the div will be hided.

I am using this functionality for having different window by example.

And to be honest I don’t know how to create a custom popup. (I started working on JAVA one month ago).

I think hiding and showing a div is better option than creating my own custom popup.
Thanks a lot!

1 Like

html 的按钮怎么绑定弹窗,我想点击按钮触发一个弹窗

You can create it like this
public static void setErrorPopup(String message, String title){
JOptionPane pane=new JOptionPane();
pane.showMessageDialog(new JFrame(),message,tittle,JOptionPane.ERROR_MESSAGE);
}
it work fine but the grafic of the popup is horrible. If you can fix this you solved your problem