ShowMessage - Francois Degrelle
f.degrelle@free.fr
* A dialog box for Forms that allow to output 1 up to 32767 characters
*
* @author Francois Degrelle
* @version 1.0
*/
public class ShowMessage extends VBean {
static String title = "" ;
static String text = "" ;
static String icone = "" ;
static int max = 150 ;
static int icon = JOptionPane.INFORMATION_MESSAGE ;
private IHandler mHandler;
private static final ID pSetTitle = ID.registerProperty("SETTITLE");
private static final ID pSetText = ID.registerProperty("SETTEXT");
private static final ID pSetIcon = ID.registerProperty("SETICON");
private static final ID pSetSize = ID.registerProperty("SETLINESIZE");
private static final ID pShow = ID.registerProperty("SHOW");
private static final ID pClear = ID.registerProperty("CLEAR");
public ShowMessage() {
super();
}
public void init(IHandler handler) {
super.init(handler);
mHandler = handler;
}
/**
* Set the properties from Forms
**/
public boolean setProperty(ID id, Object value) {
if (id == pSetTitle) { /** Set the title **/
title = (String)value ;
return true;
}
else if (id == pSetText) { /** Set the message **/
text += (String)value ;
return true;
}
else if (id == pClear) { /** Clear the text **/
text = "" ;
return true;
}
else if (id == pSetSize) { /** Set max line size **/
max = new Integer((String)value).intValue() ;
return true;
}
else if (id == pSetIcon) { /** Set the dialog box icon **/
icone = (String)value ;
if( icone.equals("I") ) icon = JOptionPane.INFORMATION_MESSAGE ;
else if( icone.equals("E") ) icon = JOptionPane.ERROR_MESSAGE ;
else if( icone.equals("P") ) icon = JOptionPane.PLAIN_MESSAGE ;
else if( icone.equals("W") ) icon = JOptionPane.WARNING_MESSAGE ;
return true;
}
else if (id == pShow) { /** Display the dialog box **/
text = Wrap_Text( text ) ;
ShowDialog();
return true;
}
else {
return true;
}
}
/**
* Display the dialog box
*/
public static void ShowDialog() {
JOptionPane.showMessageDialog(null, text, title, icon);
}
/**
* Wrap the text if lines are too long
*/
private String Wrap_Text( String sText )
- http://fdegrelle.over-blog.com/
{