Here you can find the source of showMessage(Component parent, String msg, String title, int flags)
Parameter | Description |
---|---|
parent | a parameter |
msg | a parameter |
title | a parameter |
flags | a parameter |
public static void showMessage(Component parent, String msg, String title, int flags)
//package com.java2s; /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import java.awt.Component; import javax.swing.JOptionPane; public class Main { /**//from w w w . j a v a 2s.com * Shows a message dialog, wrapping the {@code msg} at 60 columns. * * @param parent * @param msg * @param title * @param flags */ public static void showMessage(Component parent, String msg, String title, int flags) { if (msg != null && msg.length() > 60) { StringBuilder buf = new StringBuilder(); final int L = msg.length(); for (int i = 0, j = 0; i < L; i++, j++) { final char c = msg.charAt(i); buf.append(c); if (Character.isWhitespace(c)) { int k; for (k = i + 1; k < L; k++) { if (Character.isWhitespace(msg.charAt(k))) { break; } } if (k < L) { final int nextWordLen = k - i; if (j + nextWordLen > 60) { buf.append('\n'); j = 0; } } } } msg = buf.toString(); } JOptionPane.showMessageDialog(parent, msg, title, flags); } }