Advertisement
Guest User

Untitled

a guest
Feb 1st, 2014
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.27 KB | None | 0 0
  1. package test;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Dimension;
  5. import java.awt.Font;
  6. import java.awt.Rectangle;
  7. import java.awt.event.ActionEvent;
  8. import java.awt.event.ActionListener;
  9.  
  10. import javax.swing.JButton;
  11. import javax.swing.JCheckBox;
  12. import javax.swing.JDialog;
  13. import javax.swing.JFrame;
  14. import javax.swing.JLabel;
  15.  
  16. public class Programy extends JDialog implements ActionListener {
  17.    
  18.     private static JFrame rodzic;
  19.     private JButton bWstecz, bWyjście;
  20.        
  21.     public Programy(JFrame f) {
  22.         rodzic = f;
  23.         setSize(800,800);
  24.         setTitle("Test");
  25.         setLayout(null);
  26.         setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  27.        
  28.         bWstecz = new JButton("Wstecz");
  29.         bWstecz.setBounds(550, 700, 100, 20);
  30.         add(bWstecz);
  31.         bWstecz.addActionListener(this);
  32.                
  33.            
  34.         bWyjście = new JButton("Wyjście");
  35.         bWyjście.setBounds(650, 700, 100, 20);
  36.         add(bWyjście);
  37.         bWyjście.addActionListener(this);
  38.        
  39.     }
  40.  
  41.     public void closeDialog() {
  42.         rodzic.setVisible(true);
  43.         setVisible(false);
  44.     }
  45.  
  46.     @Override
  47.     public void actionPerformed(ActionEvent e)
  48.     {
  49.         Object z = e.getSource();
  50.         if (z==bWstecz)
  51.             closeDialog();
  52.         else if (z == bWyjście) dispose();
  53.     }
  54.    
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement