[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Java networked whiteboard

Posted on 2007-10-04
9
Medium Priority
?
493 Views
Last Modified: 2013-12-17
I have a client server code for a network base whiteboard application. I have tried running and debugging this code, however I came across alot of errors on the client side. The code can be downloaded from: http://www.cs.umd.edu/class/spring2005/cmsc433/p5/p5.jar

The errors I obtain while running the client side is:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at Drawing.getShapes(Drawing.java:21)
        at Drawing.paintComponent(Drawing.java:62)
        at javax.swing.JComponent.paint(JComponent.java:1006)
        at javax.swing.JComponent.paintChildren(JComponent.java:843)
        at javax.swing.JComponent.paint(JComponent.java:1015)
        at javax.swing.JComponent.paintChildren(JComponent.java:843)
        at javax.swing.JComponent.paint(JComponent.java:1015)
        at javax.swing.JLayeredPane.paint(JLayeredPane.java:559)
        at javax.swing.JComponent.paintChildren(JComponent.java:843)
        at javax.swing.JComponent.paint(JComponent.java:1015)
        at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4972)

        at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4925)
        at javax.swing.JComponent._paintImmediately(JComponent.java:4868)
        at javax.swing.JComponent.paintImmediately(JComponent.java:4675)
        at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)

        at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(System
EventQueueUtilities.java:114)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:242)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at Drawing.getShapes(Drawing.java:21)
        at Drawing.paintComponent(Drawing.java:62)
        at javax.swing.JComponent.paint(JComponent.java:1006)
        at javax.swing.JComponent.paintChildren(JComponent.java:843)
        at javax.swing.JComponent.paint(JComponent.java:1015)
        at javax.swing.JComponent.paintChildren(JComponent.java:843)
        at javax.swing.JComponent.paint(JComponent.java:1015)
        at javax.swing.JLayeredPane.paint(JLayeredPane.java:559)
        at javax.swing.JComponent.paintChildren(JComponent.java:843)
        at javax.swing.JComponent.paint(JComponent.java:1015)
        at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4972)

        at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4925)
        at javax.swing.JComponent._paintImmediately(JComponent.java:4868)
        at javax.swing.JComponent.paintImmediately(JComponent.java:4675)
        at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)

        at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(System
EventQueueUtilities.java:114)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:242)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)


The server on the other hand keeps showing this message:

Starting remote canvas on rmi://home-527d:10880/Board

How do I solve this problem?

Your help is kindly appreciated.

Regards

Eugene
0
Comment
Question by:eugene007
  • 5
  • 4
9 Comments
 
LVL 13

Accepted Solution

by:
Bart Cremers earned 420 total points
ID: 20016355
I assume you're running without a "local" parameter. In that case you're not assigning anything to the temp variable in the main method in the Whiteboard class.

So, the ShapeBuffer passed to the createAndShowGUI method references "null" which in the end results in a NullPointerException on the line given in the stack trace.

You'll need to fix more of those problems allover the code.
0
 

Author Comment

by:eugene007
ID: 20019684
So I need to create a shapebuffer object and parse it as a reference to createAndShowGUI method?
0
 
LVL 13

Expert Comment

by:Bart Cremers
ID: 20020561
Yep, in case of a non-local setup, you'll need this. And probably some other areas where you need something similar.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:eugene007
ID: 20021598
But ShapeBuffer is an interface.
0
 

Author Comment

by:eugene007
ID: 20021759
what I did for the main method for the whiteboard file is this:

    public static void main(String[] args) throws Exception {
      String boardURL;
      ShapeBuffer temp = new LocalBoard();

      final ShapeBuffer b = temp;
        final Whiteboard w = new Whiteboard();

      //Schedule a job for the event-dispatching thread:
      //creating and showing this application's GUI.
      javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                w.createAndShowGUI(b);
            }
          });
    }

and now the whiteboard appears. however the text option does not work.
0
 
LVL 13

Expert Comment

by:Bart Cremers
ID: 20022089
The Text option is the same, look where it throws the nullpointer exception and find out what could be the cause (a null reference). Make sure you initialize the reference and that problem should be solved to.
0
 

Author Comment

by:eugene007
ID: 20023306
I did this. I came up with a new class for the client side.

import java.awt.*;

public class CS4330xx extends AbstractText
{
    public CS4330xx(int x, int y)
    {
        super(x,y,"hello",Color.BLACK,1);
    }
   
    public boolean pointInShape(int x, int y, Graphics g, int margin)
    {
        return true;
    }
      
    public void draw(Graphics g)
    {
      
    }
}

In a file called TextTool.java I made this changes

public void dragStart(int x, int y, Graphics g)
{
        AbstractText text = new CS4330xx(x,y);
        ..............................
}

but the text option does not work.
0
 
LVL 13

Expert Comment

by:Bart Cremers
ID: 20024516
You'll need to check the comments in the code. They'll show you the right way.
0
 

Author Comment

by:eugene007
ID: 20024571
now it seems to be working :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The main intent of this article is to make you aware of ‘Exchange fail to mount’ error, its effects, causes, and solution.
Steps to fix “Unable to mount database. (hr=0x80004005, ec=1108)”.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question