Advertisement
Guest User

Untitled

a guest
May 21st, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. package n3as;
  2. import javax.swing.*;
  3. import java.awt.*;
  4. import java.awt.geom.Rectangle2D;
  5. import java.util.*;
  6. public class geo extends JFrame implements Runnable{
  7.  
  8. Forme[] f;
  9. ArrayList<Shape> t;
  10. Text c;
  11. public geo() {
  12. f=new Forme[3];
  13. Date d=new Date();
  14. int h=d.getHours();
  15. int m=d.getMinutes();
  16. int s=d.getSeconds();
  17. c= new Text(h+":"+m+":"+s);
  18. JPanel p=new JPanel(new BorderLayout());
  19. t=new ArrayList<Shape>();
  20. t.add(new Polygon());
  21. t.add(new Rectangle2D.Double());
  22. t.add(new Circle());
  23. for(int i=0;i<t.size();i++) {
  24. f[i]= new Forme(t.get(i));
  25. }
  26. }
  27.  
  28.  
  29. }
  30. ________________________________________________________________________________
  31. package n3as;
  32. import java.awt.*;
  33.  
  34. import javax.swing.*;
  35.  
  36.  
  37. public class Forme extends JPanel {
  38. Shape s;
  39. public Forme(Shape s) {
  40. this.s=s;
  41. }
  42.  
  43. public void paintComponnent(Graphics g) {
  44. super.paintComponent(g);
  45. Graphics2D g2d= (Graphics2D)g;
  46. g2d.draw(s);
  47. }
  48. public Shape getSt() {
  49. return s;
  50. }
  51. public void setSh(Shape s) {
  52. this.s=s;
  53. }
  54. }
  55. _______________________________________________________________________________________
  56. package n3as;
  57. import java.awt.*;
  58.  
  59. import javax.swing.*;
  60.  
  61.  
  62. public class Text extends JPanel {
  63. String s;
  64. public Text(String s) {
  65. this.s=s;
  66. }
  67.  
  68. public void paintComponnent(Graphics g) {
  69. super.paintComponent(g);
  70. Graphics2D g2d= (Graphics2D)g;
  71. g2d.drawString(s, 10, 10);
  72. }
  73. public String getSt() {
  74. return s;
  75. }
  76. public void setSt(String s) {
  77. this.s=s;
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement