User Tools

Site Tools


writing_classes_practice

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
writing_classes_practice [2022/10/01 13:58] frchriswriting_classes_practice [2022/10/01 14:45] (current) – [Writing Classes Practice] frchris
Line 1: Line 1:
 ====== Writing Classes Practice ====== ====== Writing Classes Practice ======
  
-These are designed to be done with an actual computer.  You would need to write the class from scratch and use the Tester class to see how your work is progressing.  Usually when you write a class for a Quiz, Test, or Exam, the task will be simpler (since you have no computer).  You learn a lot by finding and fixing mistakes yourself on a computer, which is why this is great practice.+These are designed to be done with an actual computer.  You would need to write the class from scratch and use the Tester class to see how your work is progressing.  Usually when you write a class for a Quiz, Test, or Exam, the task will be simpler (since you have no computer).  You learn a lot by finding and fixing mistakes yourself on a computer, which is why this is such great practice.
  
 ===== Clock ===== ===== Clock =====
Line 22: Line 22:
 import javax.swing.Timer; import javax.swing.Timer;
  
-public class ClockTester extends JPanel implements KeyListener, ActionListener+public class ClockTester extends JPanel implements  ActionListener
 { {
  public static int WIDTH=800;  public static int WIDTH=800;
Line 53: Line 53:
  window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  window.getContentPane().add(app);  window.getContentPane().add(app);
- window.addKeyListener(app); 
- //window.pack(); 
  window.setVisible(true);  window.setVisible(true);
  
Line 75: Line 73:
  
  }  }
- // update is a workaround to cure Windows screen flicker problem +  
- public void update(Graphics g){ +
- paint(g); +
-+
- +
- // These 3 methods need to be declares to implement the KeyListener Interface +
- @Override +
- public void keyTyped(KeyEvent e) {} +
- +
- @Override +
- public void keyPressed(KeyEvent e) {} +
- +
- @Override +
- public void keyReleased(KeyEvent e) {} +
- @Override+
  public void actionPerformed(ActionEvent e) {  public void actionPerformed(ActionEvent e) {
  
writing_classes_practice.1664647117.txt.gz · Last modified: 2022/10/01 13:58 by frchris

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki