/** A message area displays text in a scrollable text widget. It is a singleton.Otherobjectscanaccessitdirectlytodisplaymessages.
*/ publicclass MessageArea extends JScrollPane
{ publicstaticsynchronized MessageArea Instance ()
{ if (saInstance == null)
saInstance = new MessageArea (); return saInstance;
}
/** Create a new message area. This method is private because the class is asingletonandmaythereforenotbeinstantiatedfromtheoutside.
*/ private MessageArea ()
{
maText = new JTextArea();
maText.setBackground (new Color (255,250,240));
maText.setFont (new Font ("Helvetica", Font.PLAIN, 9));
setViewportView (maText);
setVerticalScrollBarPolicy (JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
setHorizontalScrollBarPolicy (JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
/** Show the given string at the end of the message area and scroll to make itvisible.Indentthestringasrequested.
*/ privatestaticsynchronizedvoid print (int nIndentation, String aMessage)
{ while (nIndentation-- > 0) {
aMessage = " " + aMessage;
}
Instance().printMessage(aMessage);
}
/** Show the given string at the end of the message area and scroll to make itvisible.
*/ publicstaticvoid println (String aMessage)
{
println (0, aMessage);
}
/** Show the given string at the end of the message area and scroll to make itvisible.
*/ privatestaticvoid println (int nIndentation, String aMessage)
{
print (nIndentation, aMessage+"\n");
}
/** Append the given string to the end of the text and scroll so that it becomesvisible.Thisisaninternalmethod.Useoneofthestatic andpublicones.
*/ privatesynchronizedvoid printMessage (String aMessage)
{
maText.append (aMessage);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.