Advertisement
Guest User

3

a guest
Sep 17th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. import java.awt.event.*;
  2. import java.awt.*;
  3.  
  4. class ElsoProgram extends Frame {
  5. ElsoProgram() {
  6. setTitle("Első program");
  7.  
  8. Label ne = new Label("Ez egy felirat!");
  9. add(ne);
  10.  
  11. setSize(400, 300);
  12. setVisible(true);
  13. }
  14.  
  15. public static void main(String args[]) {
  16. new ElsoProgram();
  17. }
  18.  
  19. }
  20.  
  21.  
  22. import java.awt.*;
  23. import java.awt.event.*;
  24. import static java.lang.Math.*;
  25. import java.io.*;
  26.  
  27. public class MasdoikProgram extends Frame implements ActionListener
  28. {
  29. Button gomb1, gomb2;
  30. TextField ne;
  31.  
  32. public MasdoikProgram() //konstruktor
  33. {
  34. setLayout(new FlowLayout());
  35.  
  36. ne = new TextField("MasdoikProgram");
  37. gomb1 = new Button("MasodikProgramA");
  38. gomb2 = new Button("MasodikProgramB");
  39.  
  40. addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent we){System.exit(0);}} );
  41.  
  42. gomb1.addActionListener(this);
  43. gomb2.addActionListener(this);
  44. add(ne);
  45. add(gomb1);
  46. add(gomb2);
  47. setTitle("MasodikProgram");
  48. setSize(300, 350);
  49. setVisible(true);
  50. }
  51.  
  52. @Override
  53. public void actionPerformed(ActionEvent e)
  54. {
  55. String str = e.getActionCommand(); // str a megnyomott gomb neve
  56.  
  57. if (str=="MasodikProgramA") {
  58. ne.setText("Succes é!");
  59. //setTitle("" + sqrt(Double.parseDouble(ne.getText())));
  60. //ide johet barmi
  61. } //egyik vege
  62.  
  63. if (str=="MasodikProgramB") {
  64. ne.setText("Siker é!");
  65. } //masik vege
  66.  
  67. }
  68.  
  69. public static void main(String args[]) {new MasdoikProgram();}
  70.  
  71. } //MasdoikProgram vege
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82. import java.awt.*;
  83. import java.awt.event.*;
  84.  
  85. public class HarmadikProgram extends Frame implements ActionListener
  86. {
  87. Button ne, ne2, ne3;
  88.  
  89. public HarmadikProgram() {
  90.  
  91. setLayout(new FlowLayout());
  92.  
  93. ne = new Button("Egy");
  94. ne2 = new Button("Kettő");
  95. ne3 = new Button("Harom");
  96.  
  97. addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent we){System.exit(0);}} );
  98.  
  99. ne.addActionListener(this);
  100. ne2.addActionListener(this);
  101. ne3.addActionListener(this);
  102.  
  103. add(ne);
  104. add(ne2);
  105. add(ne3);
  106. setTitle("HarmadikProgram");
  107. setSize(300, 350);
  108. setVisible(true);
  109. }
  110.  
  111. @Override
  112. public void actionPerformed(ActionEvent e) {
  113. String str = e.getActionCommand();
  114.  
  115. if(str=="Egy"){
  116. setTitle("Egy");
  117. }
  118. if(str=="Kettő") {
  119. setTitle("Kettő");
  120. };
  121. if(str=="Harom") {
  122. setTitle("Harom");
  123. }
  124. }
  125.  
  126. public static void main(String args[])
  127. {
  128. new HarmadikProgram();
  129. }
  130.  
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement