Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tester;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.io.File;
- import javax.swing.JButton;
- import javax.swing.JFileChooser;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- public class ffff extends JFrame implements ActionListener
- {
- JButton bDodaj;
- public ffff()
- {
- setSize(333,432);
- setTitle("tester");
- setLayout(null);
- bDodaj = new JButton("test");
- bDodaj.setBounds(70, 110, 130, 35);
- add(bDodaj);
- bDodaj.addActionListener(this);
- }
- @Override
- public void actionPerformed(ActionEvent e)
- {
- Object zrodlo = e.getSource();
- if(zrodlo == bDodaj)
- {
- JFileChooser fc = new JFileChooser();
- if(fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
- {
- File plik = fc.getSelectedFile();
- JOptionPane.showMessageDialog(null, "Wybrany plik to " + plik.getAbsolutePath());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement