This repository has been archived on 2025-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
citylimitsj/src/micropolisj/gui/MessagesPane.java
jason@long.name ed6795dfca Importing source code for MicropolisJ, the Java rewrite of Micropolis.
This edition of Micropolis, written for the Java desktop platform,
is fairly feature complete. I believe the only missing functionality
is that of loading the built-in scenarios, and this can be implemented
if there is any demand for it.

I will soon update the home page at http://code.google.com/p/micropolis/
with downloadable packages of this edition of the software.


git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@528 d9718cc8-9f43-0410-858b-315f434eb58c
2013-02-14 21:02:42 +00:00

44 lines
1.1 KiB
Java

// This file is part of MicropolisJ.
// Copyright (C) 2013 Jason Long
// Portions Copyright (C) 1989-2007 Electronic Arts Inc.
//
// MicropolisJ is free software; you can redistribute it and/or modify
// it under the terms of the GNU GPLv3, with additional terms.
// See the README file, included in this distribution, for details.
package micropolisj.gui;
import java.util.*;
import javax.swing.*;
import javax.swing.text.*;
import micropolisj.engine.*;
public class MessagesPane extends JTextPane
{
static ResourceBundle cityMessageStrings = ResourceBundle.getBundle("micropolisj.CityMessages");
public MessagesPane()
{
setEditable(false);
}
public void appendCityMessage(MicropolisMessage message)
{
appendMessageText(cityMessageStrings.getString(message.name()));
}
void appendMessageText(String messageText)
{
try {
StyledDocument doc = getStyledDocument();
if (doc.getLength() != 0) {
doc.insertString(doc.getLength(), "\n", null);
}
doc.insertString(doc.getLength(), messageText, null);
}
catch (BadLocationException e) {
throw new Error("unexpected", e);
}
}
}