1 package de.mud.telnet.modules;
2 /* "In case you would like to use the packages as libraries please
3 * apply the GNU Library General Public License as documented in the
4 * file COPYING.LIB." (from Telnet/Documentation/index.html)
8 * TextLabel -- A module to display a Label on the applet.
10 * $Id: TextLabel.java,v 1.1 1997/07/09 20:12:05 leo Exp $
11 * $timestamp: Wed Jul 9 17:37:28 1997 by Matthias L. Jugel :$
13 * This file is part of "The Java Telnet Applet".
15 * This is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2, or (at your option)
20 * "The Java Telnet Applet" is distributed in the hope that it will be
21 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this software; see the file COPYING. If not, write to the
27 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28 * Boston, MA 02111-1307, USA.
31 import de.mud.telnet.*;
32 import java.awt.Panel;
33 import java.awt.Label;
34 import java.awt.GridLayout;
38 * This small module lets you display text somewhere in the applets area.
42 * <DD><PRE><PARAM NAME=labelRows VALUE="<B><I>rows</B></I>"></PRE>
43 * <DD>Defines the how many rows the label will have.
44 * <DD><PRE><PARAM NAME=labelCols VALUE="<B><I>cols</B></I>"></PRE>
45 * <DD>Defines the how many columns the label will have.
46 * <DD><PRE><PARAM NAME=labelFont VALUE="<B><I>font[,size]</B></I>"></PRE>
47 * <DD>The font for displaying the label text. If the <I>size</I> is left out
48 * a standard size of 14 points is assumed.
49 * <DD><PRE><PARAM NAME=label#<I>number</I> VALUE="<B><I>text</I></B>"></PRE>
50 * <DT>The labels are enumerated and displayed in rows and columns.
52 * @version $Id: TextLabel.java,v 1.1 1997/07/09 20:12:05 leo Exp $
53 * @author Matthias L. Jugel, Marcus Meißner
56 public class TextLabel extends Panel implements Module
61 * Set the applet as module loader and configure.
62 * @param o the object that is the applet (must be an Applet)
64 * @see java.applet.Applet
66 public void setLoader(Object o) {
69 int rows = 1, cols = 1;
71 String tmp = applet.getParameter("labelRows");
72 if(tmp != null) rows = Integer.parseInt(tmp);
73 if((tmp = applet.getParameter("labelCols")) != null)
74 cols = Integer.parseInt(tmp);
76 setLayout(new GridLayout(rows, cols));
78 Font labelFont = null;
79 if((tmp = applet.getParameter("labelFont")) != null) {
80 int idx = tmp.indexOf(",");
82 if(idx != -1) size = Integer.parseInt(tmp.substring(idx+1));
83 labelFont = new Font(tmp, Font.PLAIN, size);
87 while((tmp = applet.getParameter("label#"+no++)) != null) {
88 Label text = new Label(tmp);
89 if(labelFont != null) text.setFont(labelFont);
95 * Do nothing upon connect.
96 * @param host remote hostaddress - not used
97 * @param port remote port - not used
99 public void connect(String host, int port) {}
102 * Do nothing upon disconnecton.
104 public void disconnect() {}
107 * Do nothing when receiving text. Be removed upon first call.
108 * @param s The string received.
109 * @see peer.InputPeer
111 public String receive(String s) { return null; }