Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help with placing another JPanel inside a JScrollPane

 
Nirmit Dalal
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator





















I HAVE TWO JPANELS named "UI" and "OUTPUTPAGE1" and one JScrollPane in which UI Jpanel is already present ....i want to replace UI Jpanel by OUTPUTPAGE1 JPanel by a mouseclick event
HELP!!
 
Rob Camick
Ranch Hand
Posts: 2539
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Way too much code to post. In the future post a proper SSCCE when yo uask a question.

i want to replace UI Jpanel by OUTPUTPAGE1


 
Nirmit Dalal
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:Way too much code to post. In the future post a proper SSCCE when yo uask a question.

i want to replace UI Jpanel by OUTPUTPAGE1







hey Rob ,
i know i have posted way too much code .... in learning phase ....
i have already tried this
....but not success



anywhere else i could be going wrong....maybe adding of mouselistener or anywhere else??
 
Rob Camick
Ranch Hand
Posts: 2539
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in learning phase ....


And that is way I suggested you need to start with an SSCCE.

Create a simple program that does what you need. Prove to yourself that it indeed is only a single line of code that is required to replace a component in a scrollpane.

Then once you get it working in a simple program you look to what is different in your real program. Like I said we don't have time to read through all that code.

maybe adding of mouselistener


Thats easy to check. Just add a println(..) statement in the listener to see if the code is executed.

or anywhere else??


A common problem is having two variable reference different scrollpanes. So maybe you have a class variable and an instance variable of the same name. Get rid of the instance variable.
 
Nirmit Dalal
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried your trick of writing the minimal possible code which does what i want it to ....and it has worked ....would be posting a solution asap of my original problem so that i can contribute to this forum cheers
 
Nirmit Dalal
Greenhorn
Posts: 22
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the FINAL SOLUTION THANK YOU ROB



 
Rob Camick
Ranch Hand
Posts: 2539
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no need to revalidate() the viewport.
 
Nirmit Dalal
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:There is no need to revalidate() the viewport.




Ya you are right !!! good catch :P
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic