Advertisement
Guest User

70 problem

a guest
Jan 20th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1.  
  2. /*
  3. * File: practice.java
  4. * Name:
  5. * Section Leader:
  6. * --------------------
  7. * This file is the starter file for the Hailstone problem.
  8. */
  9.  
  10. import acm.graphics.GCanvas;
  11. import acm.graphics.GLabel;
  12. import acm.graphics.GLine;
  13. import acm.program.*;
  14. import java.util.*;
  15. import java.awt.event.*;
  16. import javax.swing.*;
  17.  
  18. public class Practice extends GraphicsProgram implements ComponentListener {
  19. public void init() {
  20. addComponentListener(this);
  21. draw((double) getWidth()/8,(double) getHeight()/8);
  22. }
  23.  
  24. private void draw (double w,double h) {
  25. for (int i=0;i<7;i++) {
  26. GLine a = new GLine(w*(i+1),0,w*(i+1),getHeight());
  27. add(a);
  28. }
  29. for (int i=0;i<7;i++) {
  30. GLine b = new GLine(0,h*(i+1),getWidth(),h*(i+1));
  31. add(b);
  32. }
  33. }
  34.  
  35. public void componentHidden(ComponentEvent e) {}
  36. public void componentResized(ComponentEvent e) {
  37. removeAll();
  38. draw((double) getWidth()/8,(double) getHeight()/8);
  39. }
  40. public void componentShown(ComponentEvent e) {}
  41. public void componentMoved(ComponentEvent e) {}
  42.  
  43. private JTextField text;
  44. private int cursorX = 10;
  45. private int cursorY = 10;
  46. private int firstIndex=0;
  47. ArrayList <String> list = new ArrayList <String>();
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement