Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Change content dynamically on JPanel (Currently it opens in a new window)  RSS feed

 
Benjamin Scabbia
Ranch Hand
Posts: 34
Eclipse IDE Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi people, I'm working on a little project to apply some of the skills which I've learnt over the last few weeks. I want to create a GUI interface where I am able to click something like Help>About and then on the JPanel it would like a small about paragraph or so.

I think I'm close but unforuntately it 'writes' or changes the label by opening up a new GUI. How do I dynamically update/change the label on the current gui?

I have two classes, here is my first class:



And this is my second class:



So this is how it loads by default:

and when I click help>about this is what appears (new window opens up):

How do I fix this?

Thanks guys!
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.
You can change the current text of a JLabel by invoking
 
Benjamin Scabbia
Ranch Hand
Posts: 34
Eclipse IDE Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:Welcome to the Ranch.
You can change the current text of a JLabel by invoking


Thanks for reply and warm welcome!

Sorry I'm not 100% sure what you mean...

This is my Test class:



and in my main class I called the method

Is this what you mean?
 
Rob Camick
Ranch Hand
Posts: 2753
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it 'writes' or changes the label by opening up a new GUI.


Because that is exactly what you are telling the code to do. Your code is:



Any time you use the "new" keyword you create a new instance of the Object. You don't want to create a new instance just update the existing label.

So all you need is:


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!