Refresh Jframe

Asked

Viewed 1,097 times

1

I made software to monitor servers

I have a Jframe with several buttons in which these set a color (green if server is online and red otherwise). I do 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 updating 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 the repaint or revalidate if necessary to use them?

1 answer

1

When ping updates Jframe. If you are online paint green and do:

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

If you are offline:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.