• Post Reply Bookmark Topic Watch Topic
  • New Topic

JLabels not displaying

 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got some JLabels that I add to a JPanel within a JApplet, first when the JApplet loads the JLables do not display. If I resize a little the JLabels display, if I continue making the JApplet larger then the JLabel moves to the left and you can see part of the JLabel earlier underneath the latest display of it. Looks as though the JLabel keeps reprinting but overwriting the older copies of itself. How can I refresh the page, clear the page each time? Thanks.

AF
 
Campbell Ritchie
Marshal
Posts: 52516
118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know, without seeing some more details, eg code.
Since JLabel is a Swing component, I shall move this thread to our GUIs forum.
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How many times do you need to be asked for a SSCCE?

You get what you give. If you make an effort to ask a proper question with all the information needed to solve the problem, then we will make and effort. We are not here to spend time guessing what you might be doing.

 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob, since the problem(s) seem to be inconsistent (I would think that the 3 classes involved would be needed since it appears it may not only be 1 issue with the code). If I posted something simplified to what I'm using I'm sure there would be a complaint regarding the generalized code posted. I have gotten feedback whether I've posted the code or not that has helped and the people really show they know what they are doing - rather than constant complaint and later no response anyways. These issues, as the layout questions I've had, ALL relate to the same bit of code so (as I said before) posting a simplified version of the code is pointless when I don't know where the problem(s) lie. In the case where I'm not sure the cause of the problems, I really can't see anything to do but post the code in it's entirity. Appreciate any helpful insight to the problem(s) in the code. Thanks again.

The code was posted already at :
http://www.coderanch.com/t/536771/GUI/java/Layout-Manager
 
Paul Clapham
Sheriff
Posts: 21867
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For my part (and sorry if this sounds like more complaining) it's a pain having to configure an applet to test. So here's a question: if you run the same code but modified to be an application, does the same thing happen?
 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
:-) No problems Paul. Good idea, I'll try giving that a shot. If it helps any I'm running it from Eclipse as an applet. Do you think Eclipse may throw an extra wrench in? Thanks for the response as well.
 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's an interesting thing I've noticed. The JPanel that has 3 parts to it doesn't display the BorderLayout.CENTER JPanel when first drawn out. If I drag the JApplet larger to the right or left all it does is keep the embedded JPanels centered. Now if I drag the JApplet to make it bigger vertically the center JPanels display so all 3 sections show BUT the old way it displayed (2 sections without the center section) still remains on top of the correct display. So the BorderLayout JPanel's are hiding things initially when loaded and when they are stretched down they show everything but they also leave things displayed on top. Hope that makes sense.
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> (as I said before) posting a simplified version of the code is pointless when I don't know where the problem(s) lie.

That is the whole point of creating a SSCCE. You create a SSCCE and chances are the simple code will work. Then you add another component and see if it still works. Each time you add component it starts to look more and more like your real application. And so on.

You don't have to use 3 classes. If you truly understand what you are trying to do, you can do it in a single class.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!