# System.gui.confirm - Text Formatting

**URL:** <https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [September 5, 2022, 3:17am UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750 "2022-09-05T03:17:16Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [September 5, 2022, 3:17am UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750/1 "2022-09-05T03:17:16Z")

</div>

Hi, I am using the below script in button. But alignment of the text is not good. Any way to adjust my script?

```auto
i = 0
tag_check_neagtive = ["[default]Montreal/Weather/Description","[default]Montreal/Weather/Description","[default]Montreal/Weather/Description"]

negative_message = 'Minimum and Maximun retrieval modes for data extraction are unavailable for string type data. \nIf you want to proceed with other retrieval methods click OK. To remove these tags from the order click REMOVE.'
for y in tag_check_neagtive:
	
		negative_message = negative_message +'\n'+ str(tag_check_neagtive[i])
		
system.gui.confirm(negative_message,"Confirm")

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/1/9184b13c9ce6050aa7c1e21a6d828aa47f2ad5d2.png)

can any help me for text formatting

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [September 5, 2022, 3:56am UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750/2 "2022-09-05T03:56:40Z")

</div>

You could try adding `<html>` to your string:

```auto
i = 0
tag_check_neagtive = ["[default]Montreal/Weather/Description","[default]Montreal/Weather/Description","[default]Montreal/Weather/Description"]

negative_message = '<html>Minimum and Maximun retrieval modes for data extraction are unavailable for string type data. \nIf you want to proceed with other retrieval methods click OK. To remove these tags from the order click REMOVE.'
for y in tag_check_neagtive:
	
		negative_message = negative_message +'\n'+ str(tag_check_neagtive[i])
		
system.gui.confirm(negative_message,"Confirm")

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/1/415793ad7c312b437ee6060c09791b9c25959b18.png)

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [September 5, 2022, 4:19am UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750/3 "2022-09-05T04:19:28Z")

</div>

One question  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/e/7ecb8d6d92f0962e589ff0ee41bb2c7620a24b34.png)

is there any way to **rename yes and no button** - instead of confirm and remove?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [September 5, 2022, 4:28am UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750/4 "2022-09-05T04:28:55Z")

</div>

Not that I am aware of. Creating a custom pop-up window would probably be the simplest approach.

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [September 5, 2022, 4:29am UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750/5 "2022-09-05T04:29:56Z")

</div>

Custom popup any script you have with you?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [September 5, 2022, 4:46am UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750/6 "2022-09-05T04:46:20Z")

</div>

Replace your current button code with something like this:  
`system.nav.openWindow('YourPopupPath/removeTagConfirm')`

Then, create a custom popup window with the buttons you want. You will have to use a label in the popup for your message, The code will look something like this:

```auto
i = 0
tag_check_neagtive = ["[default]Montreal/Weather/Description","[default]Montreal/Weather/Description","[default]Montreal/Weather/Description"]

negative_message = 'Minimum and Maximun retrieval modes for data extraction are unavailable for string type data. \nIf you want to proceed with other retrieval methods click OK. To remove these tags from the order click REMOVE.'
for y in tag_check_neagtive:
	
		negative_message = negative_message +'\n'+ str(tag_check_neagtive[i])
		
event.source.parent.getComponent('tagDeleteConfirmationLabel').text = negative_message

```

Then you can program the confirm and remove buttons to do whatever you need them to do, and you can change the text properties of the buttons to whatever you want

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [September 5, 2022, 4:49am UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750/7 "2022-09-05T04:49:27Z")

</div>

I assume that you will probably want to run the above script from the window’s internalFrameOpened event handler

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 6, 2022, 3:40pm UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750/8 "2022-09-06T15:40:37Z")

</div>

Another option would be to create your own JOptionPane instances. This requires some more scripting know-how, but is more powerful:  
[https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/javax/swing/JOptionPane.html](https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/javax/swing/JOptionPane.html)

> **[How to Make Dialogs (The Java™ Tutorials \>        
            Creating a...](https://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html#features)**
>
> This Swing Java Tutorial describes developing graphical user interfaces (GUIs) for applications and applets using Swing components

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [September 21, 2022, 6:49am UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750/9 "2022-09-21T06:49:45Z")

</div>

Paul Griffith’s suggestion was actually pretty simple to implement. Now that I’ve used it, I remembered this post, and I’ve reformatted the code to fit the context of this question. Here it is:

```auto
from javax.swing import JOptionPane
i = 0
tag_check_neagtive = ["[default]Montreal/Weather/Description","[default]Montreal/Weather/Description","[default]Montreal/Weather/Description"]
negative_message = '<html>Minimum and Maximun retrieval modes for data extraction are unavailable for string type data. \nIf you want to proceed with other retrieval methods click OK. To remove these tags from the order click REMOVE.'
for y in tag_check_neagtive:
		negative_message = negative_message +'\n'+ str(tag_check_neagtive[i])
JOptionPane.showOptionDialog(None, negative_message, "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, None, ["Confirm", "Remove"], "Confirm")

```

The preceding code produces this result:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/2/f27e822cf01e482b0c1f52052440b16cf7e402ac.png)

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [January 30, 2023, 8:35am UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750/10 "2023-01-30T08:35:36Z")

</div>

Hi,  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/0/506a0177cf1a99350df11529ff0a7abf5e73cf5c.png)

can you please help in doing this type of Alert message box? as shown in fig.

Thank you

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 30, 2023, 8:47am UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750/11 "2023-01-30T08:47:11Z")

</div>

Keeping it simple would look like this:

```auto
from javax.swing import JOptionPane
title = 'Your alert title'
message = 'Alert message here'
JOptionPane.showOptionDialog(None, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, None, ["Close"], title)

```

**Result:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/6/06c241c9255be776a1f28caf161729afa5498fc6.png)

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [January 30, 2023, 8:54am UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750/12 "2023-01-30T08:54:54Z")

</div>

Thank you so much.  
need to learn JAVA for Ignition scripting?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 30, 2023, 9:07am UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750/13 "2023-01-30T09:07:09Z")

</div>

Here is a more complex example, that shouldn't be too difficult for you to further develop into exactly what you are looking for. There really are no limitations when you are building these things from scratch:

```auto
from javax.swing import JOptionPane, JPanel, JLabel, JButton
from java.awt import Dimension, BorderLayout, FlowLayout, Color, Font
text = JLabel("Your alert title", JLabel.CENTER)
text.setForeground(Color.black)
text.setFont(Font("Serif", Font.BOLD, 34))
secondtext = JLabel("Alert message here", JLabel.CENTER)
secondtext.setForeground(Color.black)
secondtext.setFont(Font("Serif", Font.BOLD, 24))
button = JButton("Close")
button.background = Color.blue
button.foreground = Color.white
panel = JPanel()
panel.setPreferredSize(Dimension(400,110))
panel.setLayout(BorderLayout())
panel.add(text,BorderLayout.NORTH)
panel.add(button,BorderLayout.EAST)
buttonPanel = JPanel()
buttonPanel.setLayout(FlowLayout())
buttonPanel.add(secondtext)
buttonPanel.add(button)
button.setSize(100, 50)
panel.add(buttonPanel, BorderLayout.CENTER)
panel.setBackground(Color.white)
pane = JOptionPane
pane.showOptionDialog(None, panel, '', JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, None, [], "")				

```

**Result:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/2/a253f34a80c37602f1399f7d69c2e21e673692df.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 30, 2023, 9:35am UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750/14 "2023-01-30T09:35:43Z")

</div>

> [@kavya\_shree](#):
>
> need to learn JAVA for Ignition scripting?

At a minimum add the [java docs](https://docs.oracle.com/javase/7/docs/api/overview-summary.html) to your bookmark bar. Ignition's [class directory](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.20/allclasses.html) is quite useful as well.

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [January 30, 2023, 9:46am UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750/15 "2023-01-30T09:46:16Z")

</div>

Cool. And how to close now this dialog, when the blue 'Close' button is pressed...?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 30, 2023, 9:56am UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750/16 "2023-01-30T09:56:51Z")

</div>

> [@zxcslo](#):
>
> And how to close now this dialog, when the blue 'Close' button is pressed...?

You'll have to add an action listener.

Here is the above example with an action listener added that closes the dialog:

> **Source Code:**
>
> ```auto
> from javax.swing import JOptionPane, JPanel, JLabel, JButton
> from java.awt import Dimension, BorderLayout, FlowLayout, Color, Font
> from javax.swing import SwingUtilities
> def actionPerformed(event):
> parent = event.source
> parent = SwingUtilities.getRoot(parent)
> getWindows = parent.getWindows()
> for disposableWindow in getWindows:
> try:
> if disposableWindow.title == '':
> disposableWindow.setVisible(False)
> except:
> pass
> text = JLabel("Your alert title", JLabel.CENTER)
> text.setForeground(Color.black)
> text.setFont(Font("Serif", Font.BOLD, 34))
> secondtext = JLabel("Alert message here", JLabel.CENTER)
> secondtext.setForeground(Color.black)
> secondtext.setFont(Font("Serif", Font.BOLD, 24))
> button = JButton("Close", actionPerformed=actionPerformed)
> button.background = Color.blue
> button.foreground = Color.white
> panel = JPanel()
> panel.setPreferredSize(Dimension(400,110))
> panel.setLayout(BorderLayout())
> panel.add(text,BorderLayout.NORTH)
> panel.add(button,BorderLayout.EAST)
> buttonPanel = JPanel()
> buttonPanel.setLayout(FlowLayout())
> buttonPanel.add(secondtext)
> buttonPanel.add(button)
> button.setSize(100, 50)
> panel.add(buttonPanel, BorderLayout.CENTER)
> panel.setBackground(Color.white)
> pane = JOptionPane
> pane.showOptionDialog(None, panel, '', JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, None, [], "")
> 
> ```

Here is another example I've done in the past where the custom dialog automatically closes:

> [@Customized Message Box - Vision](https://forum.inductiveautomation.com/t/customized-message-box-vision/64578/17):
>
> Yes, but you will have to add a JPanel to the dialog box. Here is an example using your custom method: def disposeDialog(self): """ Arguments: self: A reference to the component instance this method is invoked on. This argument is automatic and should not be specified when invoking this method. """ def disposeDialog(): def closeWindow(): from javax.swing import SwingUtilities parent = self parent = SwingUtilities.getRoot(parent) getWindows = parent.getWindows() for di…

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [January 30, 2023, 10:16am UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750/17 "2023-01-30T10:16:25Z")

</div>

> [@justinedwards.jle](#):
>
> `from java.awt.event import ActionListener`

Why this? It's not used anywhere...?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 30, 2023, 10:20am UTC](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750/18 "2023-01-30T10:20:01Z")

</div>

> [@zxcslo](#):
>
> Why this?

Thanks. You are correct; it's not needed in this example. I'll delete it from the source code above.
