Hi , I am trying to create an image-viewing application , wherein the user chooses an image file using a file chooser .

I have created a Jpanel ,inside a jframe with a menu bar, which gives the user a variety of options to select from , using combo boxes and check boxes .The user then has to click on a button in the jpanel.

I want to replace this Jpanel then with a JScrollPane containing the image(modified using the options selected) . How do I achieve this? Is it possible for the action listener of the button (which is inside the jpanel) to remove the jpanel and add the scrollpane instead to the content pane of the jframe?

you can create a method in your JFrame that changes the content of the JFrame. Something like:

void changePanels(JPanel component_to_add, JPanel component_to_remove){

and then call it from your button action handler.

// parentFrame is your JFrame 
parentFrame.changePanel(this, myScrollpane);
This question has already been answered. Start a new discussion instead.