Results 1 to 5 of 5
  1. #1
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    292
    Rep Power
    3

    Default Problem while calling method of another class which implemented by Runnable class

    Hi!

    i am having a problem while calling a method


    i am having a class

    Java Code:
    public class MySer implements Runnable {
    
    ...
    
    public void getMessage(String msg)
    {
    ...,
    }
    
    ..,
    }
    i use the above class in another class

    Java Code:
    MySer chat = new MySer(port, frame);
                    Thread t = new Thread(chat);
                    t.start();
    But when i calling the method like

    Java Code:
    chat.getMessage("BlockIt");
    The thread is started and running well. But while calling the method only it showing error.

    In which part i have made the mistake & where i have to correct my code..,

    Guide me please!

    Thank You!

    Have A Happy Day..,
    - Raj

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Problem while calling method of another class which implemented by Runnable class

    "But while calling the method only it showing error."

    You haven't given us the error, or (as far as I can see) the code with the problem.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    292
    Rep Power
    3

    Default Re: Problem while calling method of another class which implemented by Runnable class

    Thank You for your Response Mr.Tolls!

    I have receiving the error at line : 109

    Java Code:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    	[COLOR="#FF0000"]at remoteserver.ServerInitiator$1.mnu_itm_send_fileActionPerformed(ServerInitiator.java:109)[/COLOR]
    	at remoteserver.ServerInitiator$1.actionPerformed(ServerInitiator.java:100)
    	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    	at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
    	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
    	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
    	at java.awt.Component.processMouseEvent(Component.java:6505)
    	at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    	at java.awt.Component.processEvent(Component.java:6270)
    	at java.awt.Container.processEvent(Container.java:2229)
    	at java.awt.Component.dispatchEventImpl(Component.java:4861)
    	at java.awt.Container.dispatchEventImpl(Container.java:2287)
    	at java.awt.Component.dispatchEvent(Component.java:4687)
    	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    	at java.awt.Container.dispatchEventImpl(Container.java:2273)
    	at java.awt.Window.dispatchEventImpl(Window.java:2719)
    	at java.awt.Component.dispatchEvent(Component.java:4687)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    	at java.awt.EventQueue.access$200(EventQueue.java:103)
    	at java.awt.EventQueue$3.run(EventQueue.java:694)
    	at java.awt.EventQueue$3.run(EventQueue.java:692)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    	at java.awt.EventQueue$4.run(EventQueue.java:708)
    	at java.awt.EventQueue$4.run(EventQueue.java:706)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
    - Raj

  4. #4
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    292
    Rep Power
    3

    Default Re: Problem while calling method of another class which implemented by Runnable class

    Hi!

    It is working Mr.Tolls!

    it was my problem only..,

    just i have create an object for the class already in above, by mistakenly i have created once again (it was read the empty object) like..,

    Java Code:
    
    MySer chat; // global variable
    
    
    MySer chat = new MySer(port, frame);
                    Thread t = new Thread(chat);
                    t.start();
    now i have correct my code as

    Java Code:
    MySer chat; // global variable
    
    
    chat = new MySer(port, frame);
                    Thread t = new Thread(chat);
                    t.start();
    Thank You Mr.Tolls!

    Have A Happy Day..,
    - Raj

  5. #5
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    292
    Rep Power
    3

    Default Re: Problem while calling method of another class which implemented by Runnable class

    Dear Forum Tram!

    Thank You For your Guide..,

    Now successfully i have created the application

    By ServerSocket & Scoket

    Access remote system (in LAN)
    (1-many & many -1 )

    • mouse & key board control from remote,
    • Chat,
    • File Sharing,
    • Screen Sharing,
    • By JNA i can control the remote system processor. monitor & all..,


    Thank You!

    Have A Happy Day..,
    - Raj

Similar Threads

  1. Replies: 8
    Last Post: 04-18-2012, 05:58 PM
  2. Child-Class Calling a Method in a Parent-Class
    By Blah_ in forum New To Java
    Replies: 5
    Last Post: 09-29-2009, 03:48 AM
  3. Calling a class method from another class
    By caro in forum New To Java
    Replies: 4
    Last Post: 06-10-2009, 02:12 AM
  4. Replies: 29
    Last Post: 09-25-2008, 08:55 PM
  5. Calling a method on original class from created class
    By kpedersen in forum Advanced Java
    Replies: 4
    Last Post: 08-20-2008, 01:25 AM

Posting Permissions

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