Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

[Help] How to refresh a JPanel

Hi, I have a JFrame, inside the JFrame I have 3 JPanel.

I want to change the middle JPanel with a setter, but when I do myframe.setMidPanel(new JPanel()); I still see my old panel

I tried stuff like remove/add/validate/revalidate/repaint but I probably did something wrong because it's not working

My JPanel contains a JTable

My code is something like

Code
mainFrame.setpMid(vc);
mainFrame.remove(mainFrame.getpMid());
mainFrame.add(mainFrame.getpMid());

edit: I solved my problem with this:

Code
    mf.remove(mf.getpMid());
mf.getpMid().revalidate();
        mf.getpMid().repaint();
        mf.add(mf.getpMid());
        mf.revalidate();
        mf.repaint();
You can make a thread and in this thread you make a while loop that constantly checks whether the condition you set changes and when then does, it will update the panel :)
(Oct 31, 2015 04:30 AM)mrschiz0ide Wrote:  You can make a thread and in this thread you make a while loop that constantly checks whether the condition you set changes and when then does, it will update the panel :)

oh dear god
no
no.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by ClockismApr 16, 2018 11:03 AM 3 122 Apr 16, 2018 11:03 AM
Last Post: Clockism
[.NET] by AjummaFeb 18, 2018 02:57 AM 1 120 Feb 18, 2018 02:57 AM
Last Post: Vyxn
[Shell] by CitrusllJun 7, 2017 02:55 AM 4 171 Jun 7, 2017 02:55 AM
Last Post: Citrusll