Results 1 to 3 of 3

Thread: Java newb: Couple of questions need answering :)

  1. #1

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    Java newb: Couple of questions need answering :)

    Hi,

    OK, i am a total newbie to Java Programming.. i downloaded tons of source code, looked thru the code and am starting to take some of the stuff in.

    I have made a chat system in VB, but now, want to create a java applet for people who dont want to download the full application [IE: People who are at school / college / work etc]

    Now,

    As i said, i have downloaded tons of source and started to understand some of the basic stuff...

    The stuff i really need to know to help me get on my way is:

    1) Is there a site which list's all of the Events of a Socket?
    ---- I need to be able to listen for a data arrival on the socket etc
    Code:
    // Like with listening for a click of a command button
    bSend.addActionListener( new SendButton() );
    // it would be nice to know how to listen for data arriving
    wskSocket.add_DataIncoming_Listener( new DataArrival() );
    2) How do i loop through forms [AKA Frames?] to check for the title of the form?
    VB Code:
    1. Dim frm as form, _
    2.       dForm as frmPMForm
    3. for each frm in forms
    4. if frm.caption="Search caption" then
    5.   set dform=frm
    6.   exit for
    7. end if
    8. next frm
    9. if dform is nothing then exit sub
    10. dform.??????(???)

    3) I think i am knowing how to create the forms from a basic class.

    4) I tried to compile my applet to see if my user interface is working, but get the following messages:

    [ EDIT: i fixed this one, i forgot to add a reference / import import java.awt.event.*; ]
    Code:
                                         ^
    C:\Programming\TheWalks\TheWalksChat\Webbased\JavaClient\JavaInterface.java:84: cannot resolve symbol
    symbol  : variable KeyEvent 
    location: class JavaClient.JavaInterface
    		hlpMenu.setMnemonic(KeyEvent.VK_H);
                                        ^
    C:\Programming\TheWalks\TheWalksChat\Webbased\JavaClient\JavaInterface.java:93: cannot resolve symbol
    symbol  : method setJMenuBar (javax.swing.JMenuBar)
    location: class JavaClient.JavaInterface
    		setJMenuBar( menuBar );
                    ^
    can anyone help explain these?...

    Also, a biggy:

    5) How do i make it so i can change a variable from a <param> tag on the webpage applet code?

    IE: String sRoom in the code is set by the param... ?

    Thanks guys.

    Wayne
    Last edited by wpearsall; Feb 6th, 2004 at 05:23 PM.
    Wayne

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    1) Is there a site which list's all of the Events of a Socket?

    The classes of java.net.*; really dont listen to events. The most typical way of listening for an incomming connection is to create a ServerSocket passing in the port that you want to listen on to the constructor. If the port is already occupied then a BindException will be thrown. There are 65,536 logial ports on most systems so of course you will want to pass an int to the ServerSocket constructor that is within that range. The ServerSocket listens for incommming connections using it's accept() method. accept() blocks until a client attemps to make a connection at which point the accept() method will return a Socket object connecting the client to the server. Depending on which way you are transfering data you would use either the Sockets getInputStream() or get OutputStream() methods.


    Here is a list of all of the forums that Sun provides that you might find helpfull. http://forum.java.sun.com/

    To get any specific information about a class and it's methods you would want to choose the appropriate api specification off of this link. http://java.sun.com/reference/api/index.html

    2.) How do i loop through forms [AKA Frames?] to check for the title of the form?

    java.awt.Frame provides a static method which returns an array containing all frames created by the application. To check for the title you would want to call getTitle() which would return the title of the frame depending on what instance of a Frame object getTitle() was invoked on.

    I have an early logic class tommorow and it's supposed to snow.
    so id better get some zzzzZZZZ's. Ill leave the rest for someone else to help out with. If you need any help writing some code im more than happy to help.

  3. #3

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    don't spose u have any socket clients which keep listening for incoming text do you?...

    i mean, i have got alot of my app working, but i can't really do much more to it until i have figured out how to get text from the server which is being sent..

    I have got the text being SENT to the server ok though...

    thanks.
    Wayne
    Wayne

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width