Advertisement
Guest User

class GUI

a guest
Feb 23rd, 2020
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. package proiect_individual_0;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import java.util.ArrayList;
  6.  
  7. public class GUI{
  8.  
  9. TextField t1, t2;
  10. Frame f = new Frame("Rute");
  11. Button a1, a2, a3, a4, a5, a6, a7;
  12.  
  13. //Constructorul care se apeleaza in main si in care sunt incluse elementele principale
  14. GUI(){
  15. initiateAll();
  16. f.setSize(700, 400);
  17. f.setLayout(null);
  18. f.setVisible(true);
  19. }
  20.  
  21. //initierea fiecarui buton aparte
  22. void initiateA1(){
  23. a1 = new Button ("Task (a)");
  24. //marimile butonului
  25. a1.setBounds(100, 100, 225, 70);
  26. //actiunea butonului
  27. a1.addActionListener ( new ActionListener(){
  28. public void actionPerformed(ActionEvent e){
  29. dialogA();
  30. }
  31. });
  32. }
  33. void initiateA2(){
  34. a2 = new Button ("Task (b)");
  35. //marimile butonului
  36. a2.setBounds(375, 100, 200, 70);
  37. //actiunea butonului
  38. a2.addActionListener ( new ActionListener(){
  39. public void actionPerformed(ActionEvent e){
  40. dialogA();
  41. }
  42. });
  43. }
  44. void initiateA3(){
  45. a3 = new Button ("Task (c)");
  46. //marimile butonului
  47. a3.setBounds(100, 220, 100, 70);
  48. //actiunea butonului
  49. a3.addActionListener(new ActionListener(){
  50. public void actionPerformed(ActionEvent e){
  51. dialogA();
  52. }
  53. });
  54. }
  55. void initiateA4(){
  56. a4 = new Button ("Task (d)");
  57. //marimile butonului
  58. a4.setBounds(200, 220, 100, 70);
  59. //actiunea butonului
  60. a4.addActionListener(new ActionListener(){
  61. public void actionPerformed(ActionEvent e){
  62. dialogA();
  63. }
  64. });
  65. }
  66. void initiateA5(){
  67. a5 = new Button ("Task (e)");
  68. //marimile butonului
  69. a5.setBounds(300, 220, 100, 70);
  70. //actiunea butonului
  71. a5.addActionListener(new ActionListener(){
  72. public void actionPerformed(ActionEvent e){
  73. dialogA();
  74. }
  75. });
  76. }
  77. void initiateA6(){
  78. a6 = new Button ("Task (f)");
  79. //marimile butonului
  80. a6.setBounds(400, 220, 100, 70);
  81. //actiunea butonului
  82. a6.addActionListener(new ActionListener(){
  83. public void actionPerformed(ActionEvent e){
  84. dialogA();
  85. }
  86. });
  87. }
  88. void initiateA7(){
  89. a7 = new Button ("Task (g)");
  90. //marimile butonului
  91. a7.setBounds(500, 220, 100, 70);
  92. //actiunea butonului
  93. a7.addActionListener(new ActionListener(){
  94. public void actionPerformed(ActionEvent e){
  95. dialogA();
  96. }
  97. });
  98. }
  99.  
  100. //unirea initierilor intr-o functie si adaugarea lor in fereastra principala
  101. void initiateAll(){
  102. initiateA1();
  103. initiateA2();
  104. initiateA3();
  105. initiateA4();
  106. initiateA5();
  107. initiateA6();
  108. initiateA7();
  109. f.add(a1);
  110. f.add(a2);
  111. f.add(a3);
  112. f.add(a4);
  113. f.add(a5);
  114. f.add(a6);
  115. f.add(a7);
  116. }
  117.  
  118. void dialogA(){
  119. Dialog d;
  120. Frame f = new Frame();
  121. d = new Dialog(f , "Introducerea a date noi", true);
  122. d.setLayout(null);
  123. TextField tf0, tf1, tf2, tf3, tf4, tf5, tf6, tf7, tf8, tf9, tf10;
  124. tf0 = new TextField(); tf0.setBounds(125, 100, 150, 20);
  125. tf1 = new TextField(); tf1.setBounds(125, 140, 150, 20);
  126. tf2 = new TextField(); tf2.setBounds(125, 160, 150, 20);
  127. tf3 = new TextField(); tf3.setBounds(125, 180, 150, 20);
  128. tf4 = new TextField(); tf4.setBounds(125, 200, 150, 20);
  129. tf5 = new TextField(); tf5.setBounds(125, 200, 150, 20);
  130. tf6 = new TextField(); tf6.setBounds(125, 200, 150, 20);
  131.  
  132.  
  133.  
  134.  
  135. /*b0.addActionListener(new ActionListener()
  136. {
  137. public void actionPerformed( ActionEvent e )
  138. {
  139. d.setVisible(false);
  140. }
  141. }); */
  142.  
  143. d.add(tf0);
  144. String text = tf0.getText().toString();
  145. d.setSize(300, 500);
  146. d.setVisible(true);
  147. }
  148.  
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement