الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

إختيار مجلد بإستخدام JFileChooser و وضع المسار في JTextField

بدأه mohlaid في 10 مارس 2013 · 7 رد · 818 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

إختيار مجلد بإستخدام  JFileChooser و وضع المسار في JTextField

 

لدي مشكلة بخصوص  اختيار مجلد بإستخدام  JFileChooser و وضع المسار في JTextField

هده محاولتي لكنها تختار المسار الأول فقط الدي يفتح عليه FileChooser

ولا يختار مثلا مسار مجلد في D أو E

 String ChTitle = "Save Downloads";
            FCh= new JFileChooser() ;  
            FCh.setCurrentDirectory( new java.io.File("."));
           FCh.setDialogTitle(ChTitle);
         FCh.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
           FCh.setAcceptAllFileFilterUsed(false);
           File f = FCh.getCurrentDirectory();
           String v= f.getPath();
           String s= FCh.getCurrentDirectory()+"";
           text2.setText(s);text1.setText(v);
            if(FCh.showDialog(MeDownloadeR.this, "Open") ==JFileChooser.APPROVE_OPTION){
          JOptionPane.showMessageDialog(null, "getcorrent Directory");   
           }else{
               JOptionPane.showMessageDialog(null, "no select Directory");
           }

Chooser.txt

تم تعديل هذه المشاركة بواسطة mohlaid في 11 مارس 2013 في 16:15

#2

هذا لانك تختار الــ relative path قم باستدعاء

 

file.getAbsolutePath();

No intellectual battle was ever won through retreat
You do not watch Gintama? Dude, you are missing a lot!


صورةmsrgb1485.gif ocajavase7programmerclr.gif

#3

لم تنفع معي  نفس المشكل

#4

قم باستخدام الداله بعد استدعاء getCurrentDirectory وليس قبلها

No intellectual battle was ever won through retreat
You do not watch Gintama? Dude, you are missing a lot!


صورةmsrgb1485.gif ocajavase7programmerclr.gif

#5

لم تنفع معي أيضا 

#6

 fChooser = new JFileChooser();

             fChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

             int ret= fChooser.showOpenDialog(null);

             if(ret==JFileChooser.CANCEL_OPTION){return;}

             else{

                 text1.setText(fChooser.getSelectedFile().toString());

تم تعديل هذه المشاركة بواسطة MohRoua في 15 مارس 2013 في 16:39

#7

JFileChooser fileChooser = new JFileChooser();

fileChooser.setDialogTitle("Specify a file to save");

int userSelection = fileChooser.showSaveDialog(this);

File fileToSave = null ;

if (userSelection == JFileChooser.APPROVE_OPTION) {

fileToSave = fileChooser.getSelectedFile();

}

#8
; ()choose=new JFileChooser

       ;(choose.setFileSelectionMode(JFileChooser.FILES_ONLY

      ;(int result = choose.showOpenDialog(this 

       ;()File file=  choose.getSelectedFile

      ;()String fileName=file.getAbsolutePath

       :(jText1.setText(fileName

تم تعديل هذه المشاركة بواسطة شاذلى احمد في 25 مارس 2013 في 08:59

1

مواضيع مشابهة