From: <Jan...@us...> - 2007-02-26 20:46:36
|
Revision: 579 http://svn.sourceforge.net/magicmap/?rev=579&view=rev Author: Jan_fride Date: 2007-02-26 12:46:14 -0800 (Mon, 26 Feb 2007) Log Message: ----------- mada the console a console ;-) (a list) Modified Paths: -------------- trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/ConsoleView.java Modified: trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/ConsoleView.java =================================================================== --- trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/ConsoleView.java 2007-02-25 22:21:37 UTC (rev 578) +++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/ConsoleView.java 2007-02-26 20:46:14 UTC (rev 579) @@ -4,19 +4,29 @@ package net.sf.magicmap.client.gui.views; +import java.awt.Color; + +import javax.swing.DefaultListModel; import javax.swing.JComponent; +import javax.swing.JList; import javax.swing.JPanel; +import javax.swing.JScrollPane; import net.sf.magicmap.client.gui.MainGUI; import net.sf.magicmap.client.gui.utils.GUIBuilder; import net.sf.magicmap.client.gui.utils.GUIConstants; import net.sf.magicmap.client.gui.utils.GUIUtils; +import com.jgoodies.forms.layout.CellConstraints; +import com.jgoodies.forms.layout.FormLayout; + /** * @author thuebner */ public class ConsoleView extends View { + private JList list; + private DefaultListModel listModel; /** * serial version id */ @@ -26,9 +36,10 @@ super(); this.setFrameIcon(GUIBuilder.getToolIcon(GUIConstants.ICON_CONSOLE)); MainGUI.getInstance().registerJComponent(this, name); + } - /* (non-Javadoc) + /** * @see java.awt.Component#getName() */ @Override @@ -36,13 +47,34 @@ return GUIUtils.i18n("console", false); } - /* (non-Javadoc) + /** * @see net.sf.magicmap.client.views.View#buildViewComponent() */ @Override protected JComponent buildViewComponent(){ JPanel panel = new JPanel(); + listModel = new DefaultListModel(); + list = new JList(listModel); + panel.setLayout(new FormLayout("p:grow", "p:grow")); + final JScrollPane scrollPane = new JScrollPane(list, + JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + list.setBackground(Color.WHITE); + + panel.add(scrollPane, new CellConstraints().xy(1,1, CellConstraints.FILL, CellConstraints.FILL)); return panel; } - + /** + * Adds a new message to the list + * @param message + */ + public void append(String message){ + synchronized (listModel) { + listModel.addElement(message); + } + } + public void clear(String message){ + synchronized (listModel) { + listModel.removeAllElements(); + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |