Chat client sorta

I have to write this Chat client program for a class, not fully functioning, but I can't figure out what to do in order to have text from one window where it is to be entered to copy to another widow were all messages end up.. I tried InputStreamReader to do it, but couldn't get that to work..either it was the way I was triing to do it or it isn't what I should be using.. not sure..Anyway how would I do this? What should I be using?

Make two JFrames. One will hold a JTextArea for the text, the other will send data. Create an instance of that first object in your second, passing a reference to the JTextArea. Like this:
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
     class InputWin extends JFrame {
          private JTextArea refArea;
          private JLabel textLabel;
          private JTextField text;
          private JButton button;
          public InputWin(JTextArea refArea) {
               this.refArea = refArea;
               textLabel = new JLabel("Send:");
               text = new JTextField(20);
               button = new JButton("Send");
               this.getContentPane().setLayout(new java.awt.FlowLayout());
               this.getContentPane().add(textLabel);
               this.getContentPane().add(text);
               this.getContentPane().add(button);
               this.pack();
               this.setResizable(false);
               this.setTitle("Send Text");
               this.setDefaultCloseOperation(EXIT_ON_CLOSE);
               this.setLocationRelativeTo(null);
                    button.addActionListener(new ActionListener() {
                         public void actionPerformed(ActionEvent evt) {
                              sendText();
          private void sendText() {
               refArea.append(text.getText() + "\n");
               text.setText("");
               text.requestFocus();
     public class TextFrame extends JFrame {
          private JTextArea jta;
          private JScrollPane jsp;
          private InputWin inputWin;
          public TextFrame() {
               jta = new JTextArea();
               jta.setLineWrap(true);
               jta.setWrapStyleWord(true);
               jsp = new JScrollPane(jta);
               inputWin = new InputWin(jta); /* pass the JTextArea as a reference to your InputWin class */
               this.getContentPane().add(jsp);
               this.pack();
               this.setSize(400, 400);
               this.setLocationRelativeTo(null);
               this.setTitle("Text Pane");
               this.setDefaultCloseOperation(EXIT_ON_CLOSE);
               inputWin.setVisible(true);
          public static void main(String[] argv) { new TextFrame().setVisible(true); }
     }

Similar Messages

  • Wireless Signal Drops Every Few Minutes; Impossible to Load/Use Chat Client

    Hi,
    I have an iBook G4 laptop with an Airport Card installed under the keyboard (I guess it's Express? Not sure). At home, my roomates have a Windoze PC desktop using Verizon DSL connected with a Westell Modem and a Linksys Router for wireless access. This connection seems stable and is always on, as their AIM client is always running and shows no connection disruption. She also has an IBM laptop, which connects wirelessly through a Linksys card, and while I'm not sure whether she has any connection disruption or not, I don't think so or else I probably would have been asked to take a look at it by now Although, it isn't "always on" like the desktop, so I'm not sure.
    I am accessing her DSL connection wirelessly, as I've mentioned, through my iBook. When I am browsing the Web however, I sometimes try to link to a page just when the connection is resetting, so I receive the "page cannot be displayed because you are not connected to the internet" warning. If I immediately refresh the page, it usually loads right away. Sometimes I have to reload 2-3 times, but it always works without having to tweak any configurations in Network at all.
    This is a little aggravating, but liveable. Except for the fact that I am unable to run a chat client at all, since the signal drops intermittently and the client has to constantly resign on, and holding a chat conversation with constant disconnects would be impossible.
    If I had to guess, I'd say the connection resets itself at least every 15 mins or so, maybe more.
    I'm wondering if anyone else has any problem of this sort? Do I need to tweak some sort of settings? Any help would be appreciated.
    Thank you!

    I am having a similar problem. I am using a Powerbook G4, with three airport expresses (one per floor on the house). Often, I get a messages saying that I am not connected to the internet and sometimes if I wait it will reconnect and sometimes it doesn't. When it doesn't, I check the settings on the Airport Express (AE). It seems that the password to get me on the network had duplicated itself so it's now 26 characters long instead of 13. I have two other computers on the network, a PC on Windows XP and a new iMac (when I say new, I mean two weeks old, already out of date PowerPC). ANYWAY, they work fine. I am thinking that they other computers are using signal from the two remaining AEs that are working closest to the base/internet connection.
    I put a call into Apple three times and we basically just keep throwing out my system configuration files in my user, and then starting from scratch. So far that has not helped the problem.
    I think the most important thing to note is that I have upgraded all three of my AEs to v6.3 and this is when the trouble started.
    Has anyone any solutions?
    Also, what happened to the spell check feature that used to be here for posting messages?

  • Setting up BCM 7.0.6.100 Internet Chat Client

    Hi, everyone!
    I've been struggling with a weird error message when setting up the proof-of-concept chat client for BCM 7.0.6.100
    What I did is set up a fresh system from scratch and configure it just enough to conduct tests. After that I installed the chat client onto the same machine.
    Now the problem is that whenever I rty to initiate a new chat I get the following error message:
    13Chat Server not availablefalse
    System.Web.Services.Protocols.SoapException: com.sap.bcb.common.SoapException
       at ChatPortal.IciContainerService.subscribe(String appUrl, String appId, String channelType, String containerId) in d:\bcm_70_sp6_p1_source\bcm_7\source\source\ExtAppIntegration\WebServices\ChatPortal\IciContainerService.asmx.cs:line 99
    This is a copy-paste from the exact message. Chat server actually is available and I'm pretty much out of ideas what to try to fix.
    Has anyone any ideas on what to try next to get the chat working or better yet does anybody know the exact solution?
    Thanks in advance,
    Jaanus

    Jaanus,
    can you reach this page?
    If "Yes", and after clicking "Submit" you get an error message, check contact filed, e-mail ([email protected] on the screenshot) address must be the same as you assigned to a chat queue.
    BR,
    Anton.

  • I would like to know why, after updating mozilla, my gmail doesn't work properly. Specifically the chat client.

    The chat client doesn't load the option to respond in chat. I can get messages from my friends but am not allowed to type back. This only became an issue after updating my firefox browser. I tried to revert to the prior gmail (as i am testing their newer version) and that didn't resolve the issue.

    ''GMail entire message content missing (blank) after header title''
    In Firefox, if you have "Adblock Plus" extension.
    # "Ctrl+Shift+F" Preferences (or right click on ADP symbol, and choose preferences)
    # 'Filters' menu > "'''Update all subscriptions'''"
    reference: ''https://support.mozilla.com/questions/896267''

  • Multiple chat clients with Webcam support

    Hi;
    I switched to the mac and i was wondering if anyone knows a program that will let me connect to Yahoo, MSN, and AOL at the same time and use multiple accounts. I also want webcam support. Currently i use different programs and i would like to be able to chat from one program instead of 3. SO far i have found aMSN, but only works for msn and not the other chat clients. Anyone can help?
    Thanks

    I use Fire
    It handles like 6 different IM clients.... not sure about the video capabilities, but i use iChat on an AIM client for that.
    Beavis2084

  • Chat client Help

    I am writing a chat client in java and I was wondering how to change the color of the text for each person. What I mean is is it possible to have the text from one user display red and the text from another user display blue. Any help would be nice.

    Is there a way to format text with html using JEditorPane and/or JTextPane; Read the API. You will find links to the tutorials.

  • Chat clients and iSight

    microsoft messenger for mac doesnt support iSight. yahoo does. wat other chat clients support iSight?
    thanks.

    I was going to suggest AMSN. It works well and I use it as my default messenger. Its does video, but is not as good as MSN for the PC.
    I now use SKYPE most of the time. This supports video very well and communicated with PC users fine.

  • Simple Chat Client using Java

    Hi again. I'm thring to implement a simple chat client into my game and I need some help coding it, because it's way over my head. lol thanks

    Well, you have left your question very vague, and people tend to get irritated by it. First of all, you need to really specify what you need. If you have nothing and need everything....you need to start by thinking about what methods will be used to send the messages...the GUI should be the last part. Do you need a server, plan on using a public server, or in a LAN environment. If you need a server, what type? Do you plan on writing your own?
    For example, if you wanted to use an IRC server as your server, you could use PircBot as your backend for the communication and then integrate that into a GUI. If you wanted AOL, there are packages out there you can use.
    If you have things thought out, you need to tell us what you are really asking and what you aready have. Otherwise, you have a lot of things to think about.

  • Building a simple J2ME chat client (for own J2SE-based server) Threading Qs

    Hi!
    I am making my own simple chat / messenger service to use between a couple of friends over GPRS.
    On the server side i have made a multi threaded TCP server that opens a new thread for each connecting client and stores these socket connections in a hashtable for access to send data between each thread.
    So when a client logs on to the server, the server sends a printwriter message to all other clients informing them of what client connected, and the clients can put the username in its out-database. then the clients can send messages to each others using a simple, self build protocol.
    All connection between clients/server happens over a simple printwriter on in/out streams.
    Problem is: it works perfectly most of the time.... However, sometimes a message is mysteriously lost when transferred from the server to a client. Transfer from client to server works flawlessly. I am thinking that it might have something to do with the client side threading, or slow network transfer casuing a TCP read error.
    Client structure is as following:
    start-> Midlet class -> (press connect to server) -> new Client class (impl runnable) -> new thread(this) -> void run() sets up all connections and writers, waits in a while loop for messages from server and takes action according to message type. -> Button(send) uses output stream to send a message to server.
    Do anyone have any suggestions on what I must consider when making a client that will simultaniously be able to listen for data from server as well as send data to server over 1 socket and slow mobile connection without causing any trouble?
    More info can be provided if necessary.
    Thank you!

    Building a simple J2ME chat client (for own J2SE-based server)a. i would like to say that this is a bl00dy brilliant idea. i mean ~ its been done before but building one yourself is quite thrilling.
    b. are u using java 4 or java 5. ?
    sometimes a message is mysteriously lost when transferred from the server to a client. Transfer from client to server works flawlessly.are you using push registry to recieve incoming connections.
    i recommend using a StreamConnectionNotifier connection instead of just a socket connection. you could send your data (xml/plain text) just like a stream (tcp ofcourse). if you want to know how to use a StreamConnectionNotifier connection, here's how
    try{
    // listen at local port 789
    StreamConnectionNotifier notify = (StreamConnectionNotifier) Connector.open(“http://:789”);
    // infinite loop to get incoming connections
    for(;;)
    StreamConnection stream = notify.acceptandOpen();  // return a stream connection when a connection is made
    InputStrean mystream = stream.openInputStream();
    while(mystream!=-1)
    mystream.read();
    ....cheers

  • Chat Client - JTextPane

    I am trying to build a chat client, within an Applet, communicating with a Java server. I have written the server code, and built all communications (prototyped as a command line tool first, and its all working).
    My only problem now is getting the messages displayed correctly in the chat client.
    I have two problems I am trying to solve
    1) I want the username in a different color to the message
    2) I want the message to wrap, if it goes over a single line
    I have been at this for most of the day, trying different techniques, but the text either does not display at all, or I can only get one of the two problems solved, and not both together.
    I have tried lost of tips already, from previous posts, but not sure if I am doing something wrong, or if it is the applet causing the problem.
    All help would be greatly appreciated.
    Thanks
    Wayne

    My only problem now is getting the messages displayed correctly in the chat client.Start simple. Are you able to display both the user name and the chat text in the client, regardless of color and wrapping?
    I have two problems I am trying to solve
    1) I want the username in a different color to the messageIs using HTML an option? Most (all?) Swing components support text with HTML markup for e.g., colors, style,...
    2) I want the message to wrap, if it goes over a single lineMost (all?) JTextComponent subclasses support line wrapping. Well, OK, not JTextField descendants.
    I have been at this for most of the day, trying different techniques, but the text either does not display at all, or I can only get one of the two problems solved, and not both together.
    I have tried lost of tips already, from previous posts,Which tips? What did you try? What didn't work?
    I'm not nit-picking, but there are several ways we could suggest (e.g. JEditorPane), but why spend time describing them if you already have tried them... Have you read [how to use Editor Pane|http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html] (non-editable version) from the Java tutorial?
    Note than a simpler solution could be to display the user name in a JLabel with some color, and the chat text in a JTextPane or in an uneditable JTExtArea, with line-wrapping enabled, in another color. Not sure if that fulfills your requirements in terms of display.
    but not sure if I am doing something wrong, or if it is the applet causing the problem.Probably not "the applet". But for the sake of simplicity, have you tried running the chat client as a standalone Java app?

  • Help needed , e63 chat client!

    when i am trying to access chat client(gtalk) , it displaying error as a 'a nokia messaging is required to activate the services you have chosen.
    http://askct.blogspot.com

    From your question it looks like you don't want to use NM. Get Fring from Ovi store or their website on the E63, it supports G-talk.
    http://www.fring.com/download/
    ‡Thank you for hitting the Blue/Green Star button‡
    N8-00 RM 596 V:111.030.0609; E71-1(05) RM 346 V: 500.21.009

  • P2P chat client and protocol

    Hi everybody, I am a newbie with P2P, so bear with me if I ask dumb. I have been doing some research but P2P part is still not clear to me. I want to implement a chat client that works as P2P (text chat) in Java and my own protocol. As I understand Jxta defines a set of protocols that developers can use to build p2p application , but I have to create and use my own protocol for exchanging chat messages. Am I required to implement all six of Jxta protocols? Is there any open source P2P chat client and protocol? Any pointers on how to do this would be very helpful.

    JXTA is mainly for discovery and session setup as well as mapping.
    As you want to create your own communications protocol, it would b best for you to start from scratch, and not use another API.
    You can create a client application that contains a server and a socket.
    The socket allows you to connect to the remote user, while the server allows you to accept connections from other users. Anytime the two clients are running and attempt to connect to either one, they can setup a session.
    How your client will send/receieve messages is up to you - that would be your protocol.

  • Flash Chat Client

    I came accross a new tutorial for a Flash Chat Client. It
    uses Flash, PHP, MySQL. I found it to be most informative and
    thought there may be others that would be interested. It uses the
    Datagrid and Text Area components and communicates to the MySQL
    database. Oh the Tutorial i'm refering to is at the bottom of the
    page of the following link.
    Click
    here to see the tutorial

    Set the text field options to selectable.
    Dan (Mode) Smith
    --> Adobe Community Expert
    *Flash Helps*
    http://www.smithmediafusion.com/blog/?cat=11
    *THE online Radio*
    http://www.tornadostream.com
    <--check this
    ***Stop Piracy
    http://www.adobe.com/aboutadobe/antipiracy/***
    "linedrivehitter" <[email protected]> wrote
    in message
    news:f9cl1e$oba$[email protected]..
    > we are building a flash chat client and i am wondering
    if there is a way
    > to allow actual text to be rendered in the chat window
    so it can be copied
    > and pasted?

  • Is there a chat client for the iPod Touch or iPhone yet?

    Is there a chat client for the iPod Touch or iPhone yet? I already know about Meebo and JiveTalk which allow me to chat on all the major clients, Yahoo, MSN, and AOL. But how about a standalone app?
    Thanks,
    Jeff

    And so when are we talking about here? That one app and then I think this thing will be complete! Well I suppose we could use another food processor, garbage disposal, answering machine, music player, Swiss Army knife. But I'll be happy if I can just chat with friends!
    Thanks!
    Jeff

  • Connecting problems to chat client (iChat, Adium, Aim)

    My sister and I each have an apple computer, I have an iBook G4 and she just bought a new macbook. I have been having problems with my laptop connecting to ichat, adium, or aim. With each service I receive an error stating in someway that a connection cannot be made. I thought that maybe I could solve this problem when I set up my sister's new computer, however she has the same problems. iChat just pretends to connect for hours and never does, Adium says, "cannot connect to authentication server, socket disconnected" and Aim always says something to the extent of can't connect.
    I know now that this is not a computer problem necessary because both computers are experiencing the same problems. I can use AIM fine on my PC at home and I used to be able to do it on my mac too. Any ideas as to how I can connect to the chat clients? THANKS!

    Hi Tony,
    I hope you're reading this...I can't do audiochat anymore. Whenever I try and invite someone or an invitation is sent to me it doesn't connect. I can instant message and chat regularly, but the audiochat won't work. I tried the 443 port and it still didn't work. When I changed the port, it wouldn't connect to AIM at all, so I had to change it to the default settings. Please help!!!
    Aneka

Maybe you are looking for