Hakunin

JAVA_GUI_TEST

Dec 6th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.ActionEvent;
  3. import java.awt.event.ActionListener;
  4.  
  5.  
  6. public class Slusac implements ActionListener{
  7.     Frame f;
  8.  
  9.     public Slusac(Frame f){
  10.         this.f=f;
  11.     }
  12.  
  13.     @Override
  14.     public void actionPerformed(ActionEvent e) {
  15.         if(e.getActionCommand().equals("a")){
  16.             GUI.Dijalog a = new GUI.Dijalog(f);
  17.         }
  18.     }
  19. }
  20.  
  21. /////////////////////////////
  22.  
  23. import java.awt.*;
  24.  
  25. public class GUI extends Frame{
  26.  
  27.     GUI(){
  28.         super("stagod");
  29.         Slusac s1 = new Slusac(this);
  30.         setVisible(true);
  31.         Button a = new Button("a");
  32.         Button b = new Button("b");
  33.         setSize(500,400);
  34.         add(a);
  35.         add(b);
  36.         setLayout(new FlowLayout());
  37.  
  38.         a.addActionListener(s1);
  39.         b.addActionListener(s1);
  40.     }
  41.  
  42.     static class Dijalog extends Dialog{
  43.         Dijalog(Frame roditelj){
  44.             super(roditelj,"titl",true);
  45.             setSize(150,200);
  46.             setVisible(true);
  47.         }
  48.     }
  49.  
  50. }
  51.  
  52. //////////////////////////
  53.  
  54. public class aplikacija {
  55.     public static void main(String[] args) {
  56.         GUI g = new GUI();
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment