Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
<java> UChat

 
Post new topic   Reply to topic Printable version
 View previous topic  <py> br (bounty rabbit) Post :: Post how to make a python module for ASSS  View next topic  
Author Message
BDwinsAlt
Agurus's Posse


Age:33
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Fri Dec 21, 2007 8:50 pm    Post subject: <java> UChat Reply to topic Reply with quote


I have been working on a chat client. I know there are already some out there. I felt like making one tongue.gif

Does anybody know of any way to easily change the color of text on the screen? The screen shot should clear up any questions. Right now I'm using a TextArea. I thought I read that the text color could only be changed to one color. I want to be able to change the colors depending on if it's a Private message, chat message, public message, or team message.

Also, I need to find a better user's online thing at the far right. Right now it is also a textarea (Uneditable). I need something that will allow me to select different names so someone can just type "/" instead of ":name:" each time.

Lastly, I need a way to edit the textfield where the chat is typed. I need to make it edit itself when :: is typed to display :name:. Right now it only displays :name: after someone hits enter. This could be confusing.

Any ideas? I've already got most of the stuff done. Also, is a hashtable the best thing to use for online user management? I'm using a hashtable to put and remove people from the list, then reloading the list.

Thanks.

P.S. Once this is done, I will finish it up by making the mobile edition. Dr Brain can be in Hyperspace on his cell biggrin.gif




Screenshot-13.png - 40.81 KB
File downloaded or viewed 385 time(s)
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Fri Dec 21, 2007 9:47 pm    Post subject: Reply to topic Reply with quote

You could always take a look at the ChatNut Applet source. I'm sure there's a link to it somewhere, or I could upload it if you can't find one. I already solved all those UI issues in it. I don't recall the exact manner though.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Sat Dec 22, 2007 12:20 am    Post subject: Reply to topic Reply with quote

i know in some components you can embed html tags
_________________
SubSpace Discretion: A Third Generation SubSpace Client
Back to top
View users profile Send private message Add User to Ignore List AIM Address
BDwinsAlt
Agurus's Posse


Age:33
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Sat Dec 22, 2007 6:15 am    Post subject: Reply to topic Reply with quote

I read that, too. I know TextAreas won't use html tags. There was something about JComponent, but I never found much about it. I'll look at the ChatNut source when I get home from work today.

Edit: I got the color working. I'm using a JTextPane. Now all I have to do is: append(Color c, String str);

Now I need to figure out the whole select player thing.

For future reference:
Code: Show/Hide

public static JTextPane chatText = null;

...

chatText = new JTextPane();

...

     public static void append(Color c, String s) {
       StyleContext sc = StyleContext.getDefaultStyleContext();
       AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY,
                                           StyleConstants.Foreground, c);
    
       int len = chatText.getDocument().getLength(); // same value as getText().length();
       chatText.setCaretPosition(len);  // place caret at the end (with no selection)
       chatText.setCharacterAttributes(aset, false);
      chatText.setEditable(true); // Won't print text unless it's enabled
       chatText.replaceSelection(s); // Adds the new line (with Color)
      chatText.setEditable(false); // Disable so you can't backspace chat.
     }

Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Wed Dec 26, 2007 5:39 pm    Post subject: Reply to topic Reply with quote

I think you can figure out the player list (the hint is in the name).

For tracking when text is typed you could use a DocumentListener and the insertUpdate() callback. Naap's chat tab uses something like:
Code: Show/Hide
JTextArea inputarea;
...
myeventhandler = new EventHandler();
inputarea.getDocument().addDocumentListener(myeventhandler);
...
class EventHandler implements DocumentListener
{
   public void insertUpdate(DocumentEvent evt)
   {
...

_________________
ss news
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
BDwinsAlt
Agurus's Posse


Age:33
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Wed Dec 26, 2007 5:51 pm    Post subject: Reply to topic Reply with quote

Thanks. Now I know what to do. I had no idea what to search to find it. I'll take a look at NAAP to see if I missed anything with my client.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
BDwinsAlt
Agurus's Posse


Age:33
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Thu Dec 27, 2007 4:00 pm    Post subject: Reply to topic Reply with quote

New problem. I can get it to recognize what I type and append a message when I type something, but I can't edit the actually textfield where the chat is typed. I tried setting editable to false, but no luck.

FIXED: I had to modify it outside of the document listener. I have to remove the DocumentListener then re-add it after I use setText.

Nasty hack :X
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Fri Dec 28, 2007 9:47 am    Post subject: Reply to topic Reply with quote

I always use http://java.sun.com/docs/books/tutorial/ui/features/components.html when i'm looking for components...

did you try setting editable to true? (if it's editable it can be edited... can be changed)
Back to top
View users profile Send private message Add User to Ignore List AIM Address
BDwinsAlt
Agurus's Posse


Age:33
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Fri Dec 28, 2007 7:43 pm    Post subject: Reply to topic Reply with quote

First thing I tried.

Internet was out all day, sorry. For some reason my Mac ID on my modem was removed from the account. Charter makes me sick.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Sun Dec 30, 2007 4:08 pm    Post subject: Reply to topic Reply with quote

BDwinsAlt wrote:
I had to modify it outside of the document listener.
That might be because you're not supposed to modify gui stuff outside of the gui thread. To run something inside the gui thread you can use SwingUtilities.invokeLater().

The setEditable stuff is probably only for user functionality, for example graying out the text area and not allowing the user to type into it. I doubt it has anything to do with the setText function.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
BDwinsAlt
Agurus's Posse


Age:33
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Mon Dec 31, 2007 1:55 pm    Post subject: Reply to topic Reply with quote

I don't really know what else to add. I want it to stand out from the rest of the clients. I don't expect anyone to really use it. It helps me learn at least.

Here is what it looks like now. As far as GUI goes, there is color, player select, and menus.

For some reason it took off the title bar thing and the border around it when I screenshotted only the window.




newuchat.png - 30.27 KB
File downloaded or viewed 51 time(s)
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Mon Dec 31, 2007 3:24 pm    Post subject: Reply to topic Reply with quote

Does it connect to multiple zones at once?
EDIT: That even possible when zones use the same biller?
_________________
It's a shark! Oh my god! Unbelievable!
Back to top
View users profile Send private message Add User to Ignore List
BDwinsAlt
Agurus's Posse


Age:33
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Mon Dec 31, 2007 3:36 pm    Post subject: Reply to topic Reply with quote

It is possible. You just can't be in the same zone at once. It would be cool to have tabs in different zones. Then again, there aren't many asss zones.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Mon Dec 31, 2007 4:28 pm    Post subject: Reply to topic Reply with quote

But it would make you stand out form the rest...
Besides, handling multiple socket connections can be quite interesting. For a server at least...
Back to top
View users profile Send private message Add User to Ignore List
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:36
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Mon Dec 31, 2007 8:25 pm    Post subject: Reply to topic Reply with quote

If you REALLY wanted to stand out, you could use your code to write a tutorial on chatnet clients.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Mon Dec 31, 2007 8:37 pm    Post subject: Reply to topic Reply with quote

Just to let you know my biller will kick off other user sessions so only 1 player id can be logged in at once.
_________________
Performance is often the art of cheating carefully. - James Gosling
Back to top
View users profile Send private message Add User to Ignore List
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:36
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Tue Jan 01, 2008 1:15 am    Post subject: Reply to topic Reply with quote

That makes me sad, Cypher. =\
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Tue Jan 01, 2008 2:18 am    Post subject: Reply to topic Reply with quote

Best thing to add is a way to determine if a zone is online or not; sortable user list (by freq, ship, user name, pid (?))...
Back to top
View users profile Send private message Add User to Ignore List
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Fri Jan 04, 2008 7:45 pm    Post subject: Reply to topic Reply with quote

What about writing a module that can send the news.txt to the chat client somehow. Or even better, a link to a website that gets loaded in part of the window, that way you can have more control over the layout of the news.txt.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:36
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Mon Jan 07, 2008 8:17 pm    Post subject: Reply to topic Reply with quote

Smong wrote:
What about writing a module that can send the news.txt to the chat client somehow. Or even better, a link to a website that gets loaded in part of the window, that way you can have more control over the layout of the news.txt.


Too many people uses .rtfs for their news.txt.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Mon Jan 07, 2008 8:31 pm    Post subject: Reply to topic Reply with quote

Animate Dreams wrote:
Too many people uses .rtfs for their news.txt.

If designed correctly, can have mostly plain text up front that is invisible in the richtext box, for Win9x users. They'll see a bit of random junk up top, and a whole bunch on the bottom.

Personally, I'm a plaintext kind of guy.
Back to top
View users profile Send private message Add User to Ignore List Send email
AJ
Novice


Age:113
Gender:Gender:Male
Joined: Jun 19 2007
Posts: 33
Offline

PostPosted: Thu Jan 17, 2008 10:30 pm    Post subject: Reply to topic Reply with quote

Thats pretty cool BDwinsalt i wish i could code like that xD.
Back to top
View users profile Send private message Add User to Ignore List Send email
BDwinsAlt
Agurus's Posse


Age:33
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Thu Jan 17, 2008 10:41 pm    Post subject: Reply to topic Reply with quote

You have to start somewhere. Just google some examples. I learned by downloading simple code and editing it to see what it would do. TWCore helped me a lot. At first my code was functional, but a lot of things were done the wrong way.

Try some java. I used http://javaalmanac.com for a quick reference.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Custom Projects All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 973 page(s) served in previous 5 minutes.

phpBB Created this page in 0.494130 seconds : 50 queries executed (90.6%): GZIP compression disabled