Refresh Jframe [closed]

1

I made software to monitor servers

I have Jframe with several buttons where these are one color (green if server is online and red otherwise). I run this test using ping .

When I click the button to open this frame, all buttons are painted once, I would like to do this to stay updated in real time

My code starts like this:

 private void BtTecnicoActionPerformed(java.awt.event.ActionEvent evt){                                          
    JFramePrincipal d = new JFramePrincipal();
    d.setVisible(true);


    PingThread servidor = new PingThread ("ip",d.BTbotao);
    servidor.start();
}

Where would I use repaint or revalidate if I needed to use them?

    
asked by anonymous 29.05.2015 / 15:43

1 answer

1

When you ping, update the JFrame. If you are online for green paint and do:

botao.setBackground(Color.GREEN);
frame.revalidate();
frame.repaint();

If you are offline:

botao.setBackground(Color.RED);
frame.revalidate();
frame.repaint();
    
08.06.2015 / 00:48