22.07.2013 Views

PDF de la clase 34

PDF de la clase 34

PDF de la clase 34

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Clock, main()<br />

public c<strong>la</strong>ss Clock<br />

extends JFrame implements Runnable {<br />

private Thread clockThread = null;<br />

private Time time;<br />

private long accumTime = 0L;<br />

private long startTime = -1L;<br />

public static void main( String[] args ) {<br />

Clock clock = new Clock();<br />

clock.show();<br />

}<br />

Clock, constructor<br />

public Clock() {<br />

super( "Reloj" ); setDefaultCloseOperation(<br />

EXIT_ON_CLOSE ); JPanel buttons = new<br />

JPanel();<br />

JButton bStart = new JButton( "iniciar" );<br />

bStart.addActionListener( new ActionListener()<br />

{ public void actionPerformed(ActionEvent e)<br />

{ start(); }<br />

} );<br />

// crea los botones bStop y bReset <strong>de</strong> <strong>la</strong> misma forma<br />

35<br />

36<br />

18

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!