import java.awt.FileDialog; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class FileDialogDemo extends JFrame implements ActionListener { JLabel label; FileDialogDemo(){ super("File Dialog Demo"); setSize(300, 100); setDefaultCloseOperation(EXIT_ON_CLOSE); setLocationRelativeTo(null); setResizable(false); JPanel pane = new JPanel(new FlowLayout(FlowLayout.LEFT)); JButton button = new JButton("Open"); button.addActionListener(this); label = new JLabel(); pane.add(button); pane.add(label); add(pane); setVisible(true); } public static void main(String[] args) { new FileDialogDemo(); } @Override public void actionPerformed(ActionEvent e) { FileDialog dialog = new FileDialog(this, "Select File", FileDialog.LOAD); dialog.setFile("*.*"); dialog.setVisible(true); label.setText(dialog.getDirectory() + dialog.getFile()); } }
Pages
Friday, November 02, 2012
Menggunakan Class java.awt.FileDialog pada Java
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment