# 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:** 1\
**Showing post:** 16

<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…

---

_[View the full topic](https://forum.inductiveautomation.com/t/system-gui-confirm-text-formatting/63750)._
