Updating a jpanel

so, there is a case in which the main character do something (in panel 2) and then the label in JPanel1 the label should be updated.

I think that it should be similar to your logic but maybe is more that in my architecture something is wrong and every change should be done from "Main Class".

Paul, the above problem was stopping me make the changes in my ..do you update a jpanel? i have a jpanel that contains a scrollpane with a jtable in it. initially, the panel displays the current data of the jtable. I wanted to update the JPanel by means of re-initializing the JPanel by other class extended by JPanel.

I can now call the method from a non-static context. i have a jpanel that contains a scrollpane with a jtable in it. I am having a problem updating the contents of a JPanel inside a JFrame. In other words I want the destroy the panel I have up when I click a button ...A lot of the answers I've found refer to setting markers by arrays, however that won't work in this case as the objects I'm tracking could be anywhere. All worked out in the end so I suppose it wasn't a jpanel updating continuously question.I have a JPanel in my application that has to be replaced entirely. Here is my code: Application // application import *; import javax.swing.*; public class Application Driver { // The application window static Main Frame window; public static void main(String[] args) { // Create the app window try catch (Exception e) window = new Main Frame(); // Get the window toolkit Toolkit the Kit = Toolkit(); // Get screen size Dimension wnd Size ..thanks, have re-written my code. I would guess that every time the panel redraws, you will be adding another mouselistener to it.It wouldnt initiall let me call update Panel without qualifying with class name. Rather, why not add the Mouse Listener in the class's constructor? I am making a program that holds values for items that you sell and other info.I have a panel on my frame by clicking on a button I want to delete the old panel and make the other panel and add that panel to my frame.(also I use netbeans) would you please help me that how can i do that?