eugene007
asked on
Java networked whiteboard
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.NullPointerExcep tion
at Drawing.getShapes(Drawing. java:21)
at Drawing.paintComponent(Dra wing.java: 62)
at javax.swing.JComponent.pai nt(JCompon ent.java:1 006)
at javax.swing.JComponent.pai ntChildren (JComponen t.java:843 )
at javax.swing.JComponent.pai nt(JCompon ent.java:1 015)
at javax.swing.JComponent.pai ntChildren (JComponen t.java:843 )
at javax.swing.JComponent.pai nt(JCompon ent.java:1 015)
at javax.swing.JLayeredPane.p aint(JLaye redPane.ja va:559)
at javax.swing.JComponent.pai ntChildren (JComponen t.java:843 )
at javax.swing.JComponent.pai nt(JCompon ent.java:1 015)
at javax.swing.JComponent.pai ntWithOffs creenBuffe r(JCompone nt.java:49 72)
at javax.swing.JComponent.pai ntDoubleBu ffered(JCo mponent.ja va:4925)
at javax.swing.JComponent._pa intImmedia tely(JComp onent.java :4868)
at javax.swing.JComponent.pai ntImmediat ely(JCompo nent.java: 4675)
at javax.swing.RepaintManager .paintDirt yRegions(R epaintMana ger.java:4 51)
at javax.swing.SystemEventQue ueUtilitie s$Componen tWorkReque st.run(Sys tem
EventQueueUtilities.java:1 14)
at java.awt.event.InvocationE vent.dispa tch(Invoca tionEvent. java:209)
at java.awt.EventQueue.dispat chEvent(Ev entQueue.j ava:461)
at java.awt.EventDispatchThre ad.pumpOne EventForHi erarchy(Ev entDispatc hTh
read.java:242)
at java.awt.EventDispatchThre ad.pumpEve ntsForHier archy(Even tDispatchT hre
ad.java:163)
at java.awt.EventDispatchThre ad.pumpEve nts(EventD ispatchThr ead.java:1 57)
at java.awt.EventDispatchThre ad.pumpEve nts(EventD ispatchThr ead.java:1 49)
at java.awt.EventDispatchThre ad.run(Eve ntDispatch Thread.jav a:110)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerExcep tion
at Drawing.getShapes(Drawing. java:21)
at Drawing.paintComponent(Dra wing.java: 62)
at javax.swing.JComponent.pai nt(JCompon ent.java:1 006)
at javax.swing.JComponent.pai ntChildren (JComponen t.java:843 )
at javax.swing.JComponent.pai nt(JCompon ent.java:1 015)
at javax.swing.JComponent.pai ntChildren (JComponen t.java:843 )
at javax.swing.JComponent.pai nt(JCompon ent.java:1 015)
at javax.swing.JLayeredPane.p aint(JLaye redPane.ja va:559)
at javax.swing.JComponent.pai ntChildren (JComponen t.java:843 )
at javax.swing.JComponent.pai nt(JCompon ent.java:1 015)
at javax.swing.JComponent.pai ntWithOffs creenBuffe r(JCompone nt.java:49 72)
at javax.swing.JComponent.pai ntDoubleBu ffered(JCo mponent.ja va:4925)
at javax.swing.JComponent._pa intImmedia tely(JComp onent.java :4868)
at javax.swing.JComponent.pai ntImmediat ely(JCompo nent.java: 4675)
at javax.swing.RepaintManager .paintDirt yRegions(R epaintMana ger.java:4 51)
at javax.swing.SystemEventQue ueUtilitie s$Componen tWorkReque st.run(Sys tem
EventQueueUtilities.java:1 14)
at java.awt.event.InvocationE vent.dispa tch(Invoca tionEvent. java:209)
at java.awt.EventQueue.dispat chEvent(Ev entQueue.j ava:461)
at java.awt.EventDispatchThre ad.pumpOne EventForHi erarchy(Ev entDispatc hTh
read.java:242)
at java.awt.EventDispatchThre ad.pumpEve ntsForHier archy(Even tDispatchT hre
ad.java:163)
at java.awt.EventDispatchThre ad.pumpEve nts(EventD ispatchThr ead.java:1 57)
at java.awt.EventDispatchThre ad.pumpEve nts(EventD ispatchThr ead.java:1 49)
at java.awt.EventDispatchThre ad.run(Eve ntDispatch Thread.jav a:110)
The server on the other hand keeps showing this message:
Starting remote canvas on rmi://home-527d:10880/Boar d
How do I solve this problem?
Your help is kindly appreciated.
Regards
Eugene
The errors I obtain while running the client side is:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerExcep
at Drawing.getShapes(Drawing.
at Drawing.paintComponent(Dra
at javax.swing.JComponent.pai
at javax.swing.JComponent.pai
at javax.swing.JComponent.pai
at javax.swing.JComponent.pai
at javax.swing.JComponent.pai
at javax.swing.JLayeredPane.p
at javax.swing.JComponent.pai
at javax.swing.JComponent.pai
at javax.swing.JComponent.pai
at javax.swing.JComponent.pai
at javax.swing.JComponent._pa
at javax.swing.JComponent.pai
at javax.swing.RepaintManager
at javax.swing.SystemEventQue
EventQueueUtilities.java:1
at java.awt.event.InvocationE
at java.awt.EventQueue.dispat
at java.awt.EventDispatchThre
read.java:242)
at java.awt.EventDispatchThre
ad.java:163)
at java.awt.EventDispatchThre
at java.awt.EventDispatchThre
at java.awt.EventDispatchThre
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerExcep
at Drawing.getShapes(Drawing.
at Drawing.paintComponent(Dra
at javax.swing.JComponent.pai
at javax.swing.JComponent.pai
at javax.swing.JComponent.pai
at javax.swing.JComponent.pai
at javax.swing.JComponent.pai
at javax.swing.JLayeredPane.p
at javax.swing.JComponent.pai
at javax.swing.JComponent.pai
at javax.swing.JComponent.pai
at javax.swing.JComponent.pai
at javax.swing.JComponent._pa
at javax.swing.JComponent.pai
at javax.swing.RepaintManager
at javax.swing.SystemEventQue
EventQueueUtilities.java:1
at java.awt.event.InvocationE
at java.awt.EventQueue.dispat
at java.awt.EventDispatchThre
read.java:242)
at java.awt.EventDispatchThre
ad.java:163)
at java.awt.EventDispatchThre
at java.awt.EventDispatchThre
at java.awt.EventDispatchThre
The server on the other hand keeps showing this message:
Starting remote canvas on rmi://home-527d:10880/Boar
How do I solve this problem?
Your help is kindly appreciated.
Regards
Eugene
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yep, in case of a non-local setup, you'll need this. And probably some other areas where you need something similar.
ASKER
But ShapeBuffer is an interface.
ASKER
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 .invokeLat er(new Runnable() {
public void run() {
w.createAndShowGUI(b);
}
});
}
and now the whiteboard appears. however the text option does not work.
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
public void run() {
w.createAndShowGUI(b);
}
});
}
and now the whiteboard appears. however the text option does not work.
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.
ASKER
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.BL ACK,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.
import java.awt.*;
public class CS4330xx extends AbstractText
{
public CS4330xx(int x, int y)
{
super(x,y,"hello",Color.BL
}
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.
You'll need to check the comments in the code. They'll show you the right way.
ASKER
now it seems to be working :)
ASKER