Added ability to remove the "Send" button for chat boxes in cramped
spaces. Modified getPreferredSize() to return a width that isn't pathologically skinny and to avoid allowing the underlying JTextPane from requesting a ridiculously large width when it gets a nice long string of text to display. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@497 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
//
|
||||
// $Id: ChatPanel.java,v 1.4 2001/10/11 04:13:33 mdb Exp $
|
||||
// $Id: ChatPanel.java,v 1.5 2001/10/18 20:52:58 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.client;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.*;
|
||||
import java.util.StringTokenizer;
|
||||
@@ -69,6 +72,19 @@ public class ChatPanel
|
||||
_entry.requestFocus();
|
||||
}
|
||||
|
||||
/**
|
||||
* For appliations where the chat box has extremely limited space, the
|
||||
* send button can be removed to leave more space for the text input
|
||||
* box.
|
||||
*/
|
||||
public void removeSendButton ()
|
||||
{
|
||||
if (_send.isVisible()) {
|
||||
// _send.getParent().remove(_send);
|
||||
_send.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected void createStyles (JTextPane text)
|
||||
{
|
||||
StyleContext sctx = StyleContext.getDefaultStyleContext();
|
||||
@@ -228,6 +244,18 @@ public class ChatPanel
|
||||
// nothing doing
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize ()
|
||||
{
|
||||
Dimension size = super.getPreferredSize();
|
||||
// always prefer a sensible but not overly large width. this also
|
||||
// prevents us from inheriting a foolishly large preferred width
|
||||
// from the JTextPane which sometimes decides it wants to be as
|
||||
// wide as its widest line of text rather than wrap that line of
|
||||
// text.
|
||||
size.width = PREFERRED_WIDTH;
|
||||
return size;
|
||||
}
|
||||
|
||||
protected CrowdContext _ctx;
|
||||
protected ChatDirector _chatdtr;
|
||||
|
||||
@@ -240,4 +268,7 @@ public class ChatPanel
|
||||
protected Style _msgStyle;
|
||||
protected Style _errStyle;
|
||||
protected Style _noticeStyle;
|
||||
|
||||
/** A width that isn't so skinny that the text is teeny. */
|
||||
protected static final int PREFERRED_WIDTH = 200;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user