Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. package tester;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import java.io.File;
  6.  
  7. import javax.swing.JButton;
  8. import javax.swing.JFileChooser;
  9. import javax.swing.JFrame;
  10. import javax.swing.JOptionPane;
  11.  
  12. public class ffff extends JFrame implements ActionListener
  13. {
  14. JButton bDodaj;
  15. public ffff()
  16. {
  17. setSize(333,432);
  18. setTitle("tester");
  19. setLayout(null);
  20.  
  21. bDodaj = new JButton("test");
  22. bDodaj.setBounds(70, 110, 130, 35);
  23. add(bDodaj);
  24. bDodaj.addActionListener(this);
  25.  
  26.  
  27. }
  28.  
  29. @Override
  30. public void actionPerformed(ActionEvent e)
  31. {
  32. Object zrodlo = e.getSource();
  33. if(zrodlo == bDodaj)
  34. {
  35. JFileChooser fc = new JFileChooser();
  36. if(fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
  37. {
  38. File plik = fc.getSelectedFile();
  39. JOptionPane.showMessageDialog(null, "Wybrany plik to " + plik.getAbsolutePath());
  40. }
  41. }
  42.  
  43. }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement