The easiest way to do this would be to override paintComponent( Graphics g ) on the JPanel (or other container) you are adding the buttons to, and draw the line using the g.drawLine( x1, y1, x2, y2 ) method. You should calculate the value of x1 and y1 from the location of one button, and x2 and y2 from the location of the other button.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.