سلام عليكم
هذا برنامج يعطيك اسماء الملفات
الموجودة داخل
path معين
انا استفيد منه لأن لدي مكتبة كبيرة من الأفلام
فأريد أن أعمل لستة لكل أسماء الافلام مثلا
عموما هذا الكود :
import java.io.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
public class folders{
public static void main(String[] args) throws IOException {
String dd = JOptionPane.showInputDialog("PLZZ ENTER PATH");
File f = new File(dd);
String[] m = f.list();
String s="";
Stack stk = new Stack();
for(int i= m.length-1 ; i >= 0; i--)
{
stk.add( m );
}
JFrame frm = new JFrame();
frm.setTitle("THE MOST NICE MEMO NONO");
frm.setSize(600,300);
JTextArea txt =new JTextArea();
txt.setText("*****************************************\n"+
"* THIS SOFTWARE DEVELOPED *\n"+
"* BY MEMONONO@YAHOO.COM *\n"+
"*****************************************\n");
txt.append( print(stk,f) );
txt.setAutoscrolls(true);
///*********************************************
frm.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
JScrollPane scrollPane = new JScrollPane(txt);
//**********************************************
frm.getContentPane().add(scrollPane);
txt.setEditable(false);
JMenuItem menuItem1 = new JMenuItem("MEMONONO@YAHOO.COM");
JMenuItem menuItem2 = new JMenuItem("WAEL KABLI");
//Create the popup menu.
final JPopupMenu popup = new JPopupMenu();
popup.add(menuItem1);
popup.add(menuItem2);
//Add listener to components that can bring up popup menus.
txt.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
popup.show(e.getComponent(),
e.getX(), e.getY());
}
});
frm.show();
//txt.updateUI();
}
public static String print(Stack stk , File f){
String x="";
if( stk.isEmpty()){
return x;
}
else{
String temp = (String) stk.pop();
File ft = null;
if(!temp.trim().equals("") )
ft = new File(f.getPath()+"\\"+temp);
if(ft!=null && ft.isDirectory()){
String[] m = ft.list();
//Stack tempStack = new Stack();
x = x + "\n************\n"+temp;
for(int i= m.length-1 ; i >= 0; i--)
x += "\n"+ m;
return x + "\n************\n" + print(stk,f);
}
else
return x +temp+ "\n"+ print(stk,f);
}
}
}وايضا اقدم ملفاً exe مرفقا