File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Delete part of JPanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Delete part of JPanel" Watch "Delete part of JPanel" New topic
Author

Delete part of JPanel

Pan Niko
Ranch Hand

Joined: Mar 19, 2011
Posts: 86

Hello,

How I can remove the EAST side of a JPanel that has BorderLayout? The EAST side, contains another JPanel.

Thank you
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

If the East side is a JPanel, and you want to remove it, you could just remove the JPanel from the JFrame...
Here is something I found from another site... :
"the easiest way to remove a component (panel) from a container (frame) is to keep a reference to it, and then call Container.remove(Component) ie:
i haven't tested this code but it should work.
"


“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Don't call Thread.sleep(...) on the EDT.


luck, db
There are no new questions, but there may be new answers.
Pan Niko
Ranch Hand

Joined: Mar 19, 2011
Posts: 86

Really didn''t understand the example code, sorry :S
Pan Niko
Ranch Hand

Joined: Mar 19, 2011
Posts: 86

Just want to remove the very first (default) JPanel that appeared on EAST side of the frame. Achieved to update it, but seems that update version hidden behind default JPanel, can't remove it.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

There is no
very first (default) JPanel that appeared on EAST side of the frame


If you didn't add a Component with constraint of BorderLayout.EAST, there's nothing there. And if you did,then you need to retain a reference to allow you toremove it.

Whenever adding/removing components to/from an already visible container, you need to call revalidate() and repaint().

To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Delete part of JPanel
 
Similar Threads
best layout to center component...
Doubt in GUI
Centering Text Label
Adding padding to GUI components
East JPanel and graphics