pessoal,
como faço um JFileChooser?
JMenuItem.add( {new ActionListener()
public void actionPerformed(ActionEvent event)
{
JFileChooser escolha = new JFileChooser(“Escolher arquivos”);
//Como jogar isso na tela, JPanel ou Container?
}
} );
pessoal,
como faço um JFileChooser?
JMenuItem.add( {new ActionListener()
public void actionPerformed(ActionEvent event)
{
JFileChooser escolha = new JFileChooser(“Escolher arquivos”);
//Como jogar isso na tela, JPanel ou Container?
}
} );
Suponha o seguinte programinha…
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Teste extends JFrame {
public static void main(String[] args) {
JFrame f = new Teste();
f.setVisible(true);
}
public Teste() {
setSize(200, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel p = new JPanel();
p.setLayout(new FlowLayout(FlowLayout.RIGHT));
JButton b = new JButton("Abrir");
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser dlgOpen = new JFileChooser();
int result = dlgOpen.showOpenDialog(this);
// veja na API os valores possiveis para result
// (não lembro)
} } );
p.add(b);
getContentPane().add(p, BorderLayout.SOUTH);
}
}
Espero que ajude.