Documentation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
jvx:client:gui:custom_dialog [2020/06/15 10:07]
cduncan
jvx:client:gui:custom_dialog [2025/08/20 10:01] (current)
admin
Line 2: Line 2:
 ~~Title: Open a Custom Dialog~~ ~~Title: Open a Custom Dialog~~
  
-Sometimes you want to show dialogues instead of workscreensbecause a dialog is a simple popup that shows details about a selected record or requests input from the user. Another reason could be that a workscreen shows different dialogues on button clicks.+Sometimes you want to show dialogues instead of workscreens because a dialog is a simple popup that shows details about a selected record or requests input from the user. Another reason could be that a workscreen shows different dialogues on button clicks.
  
 It's very easy to show a dialog in your application or workscreen. Use the dialog class and use it as follows: It's very easy to show a dialog in your application or workscreen. Use the dialog class and use it as follows:
Line 18: Line 18:
 //dialog with Ok button //dialog with Ok button
 Dialog dlg = new Dialog(panContent);​ Dialog dlg = new Dialog(panContent);​
 +dlg.setTitle("​Dialog test"​);​
 +dlg.setModal(true);​
 //show dialog as frame //show dialog as frame
-Dialog.openInternalFrame(this, "​Dialog test", true, dlg);+Dialog.openInternalFrame(getApplication());
 </​file>​ </​file>​
  
Line 28: Line 30:
 The title is an optional attribute. If you don't set the title, the name of the dialog will be used. The dialog itself has a default preferred size. You should change the default setting if you need a different size. The title is an optional attribute. If you don't set the title, the name of the dialog will be used. The dialog itself has a default preferred size. You should change the default setting if you need a different size.
  
-Above dialog looks like this:+The above dialog looks like this:
  
 {{:​jvx:​client:​gui:​dialog.png?​nolink|}} {{:​jvx:​client:​gui:​dialog.png?​nolink|}}
Line 35: Line 37:
  
 {{:​jvx:​client:​gui:​dialog_ok_cancel.png?​nolink|}} {{:​jvx:​client:​gui:​dialog_ok_cancel.png?​nolink|}}
 +\\ 
 +\\ 
  
 +Here's an example dialog:
 +
 +<file java>
 +private UINumberField nfValue;
 +
 +public void doShowDialog()
 +{
 +    nfValue = new UINumberField();​
 +    nfValue.setPrecision(3);​
 +    nfValue.setScale(0);​
 +               
 +    UIFormLayout flDialog = new UIFormLayout();​
 +               
 +    UIPanel panDialog = new UIPanel(flDialog);​
 +    panDialog.add(new UILabel("​Value"​),​ flDialog.getConstraints(0,​ 0));
 +    panDialog.add(nfValue,​ flDialog.getConstraints(1,​ 0, -1, 0));
 +    panDialog.setPreferredSize(200,​ 40);
 +               
 +    Dialog dialog = new Dialog(panDialog);​
 +    dialog.setModal(true);​
 +    dialog.setTitle("​Enter a numeric value"​);​
 +    dialog.setPreferredSize(null);​
 +    dialog.getOkButton().eventAction().addListener(this::​doAfterDialog);​
 +               
 +    dialog.open(getApplication());​
 +}
 +    ​
 +public void doAfterDialog()
 +{
 +    showInformation("​Value = " + nfValue.getValue());​
 +}
 +</​file>​
 +
 +The dialog can be opened by button press or another action. It opens a simple dialog which shows a label and a number field. The number can be max. 3 digits. If you press OK button in the dialog, an information message with the entered number will be shown.
This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information