• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

The client is not displaying the whole thing

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I have a server named Teacher() and a client named Student() and I am drawing shapes with butons in the Teacher() app and Student() can see them in her own app. Right now, the Student() can see the first drawn shape but she can't see the following. I think the 'choice' never changes but I couldn't solve it.

Here is the Teacher()'s code for sending shapes:



Here is the Student()'s code for receiving shapes:



Here is the PaintPanel() which is where I defined the choices(buttons):

 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Francesca duBois wrote:Here is the PaintPanel() which is where I defined the choices(buttons):



The following code is difficult to understand. It's clear that g2d is a Graphics object which is being drawn on, but the code doesn't show where it came from. It should really come from the jpCenter component, but presumably it doesn't since you aren't seeing that component updated.
 
Francesca duBois
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:

Francesca duBois wrote:Here is the PaintPanel() which is where I defined the choices(buttons):



The following code is difficult to understand. It's clear that g2d is a Graphics object which is being drawn on, but the code doesn't show where it came from. It should really come from the jpCenter component, but presumably it doesn't since you aren't seeing that component updated.



Oh sorry about that I created an independent class PaintPanel() and that code is inside of it:

 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's kind of distracting to have to look at all of that unused code. There's a whole lot of code devoted to ShapeParams, and it looks like it was meant to do something in the past. So it would improve things if you took that out.

But after that, there's a class named Teacher and you're using several of its static variables while trying to get data to appear. Or is that "Teacher" supposed to be a variable? If so, it would help if you followed the Java standards and called it "teacher" instead. Anyway, it would help to know if the "Teacher" there is the same "Teacher" which you used elsewhere. Have you debugged the code to find out if the values you are getting from it are what you expected them to be?
 
Francesca duBois
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:It's kind of distracting to have to look at all of that unused code. There's a whole lot of code devoted to ShapeParams, and it looks like it was meant to do something in the past. So it would improve things if you took that out.

But after that, there's a class named Teacher and you're using several of its static variables while trying to get data to appear. Or is that "Teacher" supposed to be a variable? If so, it would help if you followed the Java standards and called it "teacher" instead. Anyway, it would help to know if the "Teacher" there is the same "Teacher" which you used elsewhere. Have you debugged the code to find out if the values you are getting from it are what you expected them to be?



They are the same "Teacher" and yes it is the class one. I have debugged it and tested it in the console, and it shows that the shapes are being sent and received but the Student() app can not draw the shapes that comes after the first.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Should I assume that "jpCenter" refers to a "PaintPanel" object which is displayed on the screen? And that there aren't any other "PaintPanel" objects?

And you said you debugged that code. Does that mean that you observed the paintComponent method being called and that (for example) Teacher.choice had the value you expected it to have? If not, what did you do instead?
 
Francesca duBois
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Should I assume that "jpCenter" refers to a "PaintPanel" object which is displayed on the screen? And that there aren't any other "PaintPanel" objects?

And you said you debugged that code. Does that mean that you observed the paintComponent method being called and that (for example) Teacher.choice had the value you expected it to have? If not, what did you do instead?



Yes it is the PaintPanel, and when I debugged it, it was sending the value I want. Also I printed the incoming data with println.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And the rectangles and ovals and lines that were drawn on that Graphics object, were they inside the area of the component which was visible on the screen?
 
Francesca duBois
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:And the rectangles and ovals and lines that were drawn on that Graphics object, were they inside the area of the component which was visible on the screen?



Yes as I mentioned, the Teacher() can draw shapes bu the Student() can only see the first drawn shape on her own app.
 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Student() can only see the first drawn shape


Does the Student receive more shapes after the first one?  What does it do with the second shape it receives?  Is it drawn on the visible GUI like the first one was?

Note: the list of if statements in the paintComponent method appear to be mutually exclusive, ie only one will be true and the others will be false. In that case, the structure of statements should be either a switch  statement with a default or a list of if/else if/else statements with an error message in the trailing else so you know when none of the if statements were true.
 
Francesca duBois
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Norm Radder wrote:

Student() can only see the first drawn shape


Does the Student receive more shapes after the first one?  What does it do with the second shape it receives?  Is it drawn on the visible GUI like the first one was?

Note: the list of if statements in the paintComponent method appear to be mutually exclusive, ie only one will be true and the others will be false. In that case, the structure of statements should be either a switch  statement with a default or a list of if/else if/else statements with an error message in the trailing else so you know when none of the if statements were true.



No after the first one, the Student() does not receive any more shapes The 'choice' is what buttons are e.g. rectangle, circle, line. When printed out on the console, I saw that the choice never changes and I think it draws the second shape on the first shape Teacher() had sent so that's why it doesn't display any more shapes. It just shows the first shape Teacher() had sent. I dpn't know how to fix it tho.
 
Norm Radder
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

No after the first one, the Student() does not receive any more


That implies there is something wrong with the sending and receiving of the shapes between the Teacher and Student.  What happens on the Teacher when the second shape is supposed to be sent?  Are there any errors?  What happens on the Student when the Teacher is sending the second shape?
 
Francesca duBois
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Norm Radder wrote:

No after the first one, the Student() does not receive any more


That implies there is something wrong with the sending and receiving of the shapes between the Teacher and Student.  What happens on the Teacher when the second shape is supposed to be sent?  Are there any errors?  What happens on the Student when the Teacher is sending the second shape?



Teacher stays the same, there is nothing wrong with it, the Student visually stays as it is with the first shape. And when I printed out the choice sent before and after the second shape, I saw that it never changes.
 
Bartender
Posts: 5465
212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Say the teacher presses the circle button for the second time, and he sends this ShapeParameters message, what does that message contain? Especially, how many objects do the rectangles, circles and lines collection contain? Have you checked that?
 
Norm Radder
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Teacher stays the same, there is nothing wrong with it, the Student visually stays


I was asking about what happens inside the program, not what shows in the GUI.  
When the Teacher creates and sends the second image, what statements are executed on the Teacher to send the shape?
On the Student what statements are executed after the Teacher has sent the second shape?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic