import java.awt.Component; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JComponent; public class CustomizableMessageDialog { public CustomizableMessageDialog(Component comp, String message){ String txt = "
" + message + "
"; JLabel label = new JLabel(txt); JOptionPane.showMessageDialog(comp, label); } public static void main(String[] args) { new CustomizableMessageDialog(null, "Dies ist ein
zentrierter Text"); } }