Here you can find the source of showWarningMessage(String title, String message, java.awt.Component parent)
public static void showWarningMessage(String title, String message, java.awt.Component parent)
//package com.java2s; //License from project: Open Source License import javax.swing.JOptionPane; public class Main { public static void showWarningMessage(String title, String message, java.awt.Component parent) { JOptionPane.showMessageDialog(parent, splitIntoLines(message), title, JOptionPane.WARNING_MESSAGE); }//from w w w . jav a 2 s. c om /** * Splits a given string into lines comprised of 15 words each. Line breaks * added to {@code message} by the user will be honoured and treated as * paragraphs. * * @param message a string. * @return a {@code String} split into lines. */ public static String splitIntoLines(String message) { String[] messageSplitLineBreak = message.split("\n"); StringBuilder mainBuilder = new StringBuilder(); for (int i = 0; i < messageSplitLineBreak.length; i++) { String[] whiteSpaceSplit = messageSplitLineBreak[i].split(" "); StringBuilder tempBuilder = new StringBuilder(); for (int j = 0; j < whiteSpaceSplit.length; j++) { tempBuilder.append(whiteSpaceSplit[j]).append(" "); if (j != 0 && j % 14 == 0 && message.length() > tempBuilder.length() + mainBuilder.length()) { tempBuilder.append("\n"); } } mainBuilder.append(tempBuilder).append("\n"); } return mainBuilder.toString(); } }