Crossfire JXClient, Trunk  R20561
GUILabelFailure.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2010 Nicolas Weeger.
19  */
20 
21 package com.realtime.crossfire.jxclient.gui.label;
22 
27 import java.awt.Color;
28 import java.awt.Font;
29 import org.jetbrains.annotations.NotNull;
30 import org.jetbrains.annotations.Nullable;
31 
36 public class GUILabelFailure extends GUIMultiLineLabel {
37 
41  private static final long serialVersionUID = 1;
42 
46  @NotNull
48 
53  @NotNull
55 
56  @Override
57  public void failure(@NotNull final String command, @NotNull final String arguments) {
58  setText(arguments.replaceFirst("^([0-9]+ )?", ""));
59  }
60 
61  @Override
62  public void clearFailure() {
63  setText("");
64  }
65 
66  };
67 
78  public GUILabelFailure(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final Font font, @NotNull final Color color, @Nullable final Color backgroundColor) {
79  super(tooltipManager, elementListener, name, null, font, color, backgroundColor, Alignment.LEFT, "");
80  this.crossfireServerConnection = crossfireServerConnection;
81  this.crossfireServerConnection.addCrossfireFailureListener(crossfireFailureListener);
82  }
83 
87  @Override
88  public void dispose() {
89  super.dispose();
90  crossfireServerConnection.removeCrossfireFailureListener(crossfireFailureListener);
91  }
92 
93 }
void dispose()
Releases all allocated resources.
void setText(@NotNull final String text)
The label text.
A AbstractLabel that renders the text as a list of plain strings.
final TooltipManager tooltipManager
The TooltipManager to update.
final CrossfireFailureListener crossfireFailureListener
The CrossfireFailureListener registered to receive failure messages.
static final long serialVersionUID
The serial version UID.
final GUIElementListener elementListener
The GUIElementListener to notify.
final Color backgroundColor
If set, the opaque background color.
final CrossfireServerConnection crossfireServerConnection
The CrossfireServerConnection to monitor.
A GUIHTMLLabel that displays the last received "failure" message.
Interface for listeners interested in the "failure" messages received from the Crossfire server...
GUILabelFailure(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final Font font, @NotNull final Color color, @Nullable final Color backgroundColor)
Creates a new instance.
void removeCrossfireFailureListener(@NotNull CrossfireFailureListener listener)
Removes a listener to be notified of failure messages.
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.
void addCrossfireFailureListener(@NotNull CrossfireFailureListener listener)
Adds a listener to be notified of failure messages.