LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Java - repaint on tabbedpane (http://www.linuxquestions.org/questions/programming-9/java-repaint-on-tabbedpane-486227/)

hunterfighter 09-23-2006 07:09 AM

Java - repaint on tabbedpane
 
Hi,
I had a problem when I using the tabbed pane in Java. I create a tabbed pane. I add a panel on it.
When I click the close button which is coded to remove the panel from the tabbed pane. It still appear the drawing on the screen. Even the component is really been removed.
So, I minimize the application and restore back it. It only will repaint or refresh the screen for me.
Any idea to overcome the problem?

mrcheeks 09-23-2006 10:13 AM

Try repainting and revalidating the JTabbedPane
Code:

// create the tabbedpane and add a panel
JPanel panel = new JPanel();
JTabbedPane jtp = new JTabbedPane();
jtp.addTab("Panel", panel);

// remove the panel
jtp.remove(panel);
jtp.repaint();
jtp.revalidate();


hunterfighter 09-23-2006 10:49 AM

Yeah the result still remain the same. Still can't make it repaint or refresh.
It only work sometimes. Depends on luck.

mrcheeks 09-23-2006 12:50 PM

try revalidate before repaint to see if it is better

hunterfighter 09-23-2006 12:55 PM

It still the same. I try with

remove(jtp);
add(jtp);

it still same.

hunterfighter 09-23-2006 10:31 PM

Will different OS different effect?

xhi 09-23-2006 11:11 PM

i have run into some weird repaint issues before as well. its probably because i do not know the *right* way to do it, and what i do is probably cheating a bit. what i would do, that would work for sure, is to toggle the visibility of the component. do a

Code:

setVisible(false);
setVisible(true);

this will guarantee a repaint.

hunterfighter 09-25-2006 06:46 AM

At last I know what the problem. You use any other library file for tabbedPane beside from Sun Java itself?
I use the 3rd party library file it got problem. after I use bak the original library file from Sun, it seems like no problem.
And I try your cheating skill. Haha it can't work for me. I better use back the original library file from Sun Java.


All times are GMT -5. The time now is 02:53 PM.