Cov txheej txheem:

Kuv yuav siv cov ntawv xaiv li cas?
Kuv yuav siv cov ntawv xaiv li cas?

Video: Kuv yuav siv cov ntawv xaiv li cas?

Video: Kuv yuav siv cov ntawv xaiv li cas?
Video: Yuam Kev Ua Koj Sev - Pajai Yang/Paj Ntsais Yaj (Official Music Video) 2024, Kaum ib hlis
Anonim

Nyem qhov Qhib a Cov ntaub ntawv khawm. Mus ncig ntawm lub xaiv cov ntaub ntawv , xaiv a ntaub ntawv , thiab nyem qhov dialog's Open khawm. Siv lub Save a Cov ntaub ntawv khawm kom coj tau ib lub dialog tseg. Sim ua siv tag nrho cov tswj ntawm lub xaiv cov ntaub ntawv.

Ib yam li ntawd, kuv yuav import JFileChooser li cas?

Qhia qhib cov ntaub ntawv yooj yim siv JFileChooser

  1. Ntxiv cov lus yuav tsum tau ntshuam: import javax.swing. JFileChooser;
  2. Tsim ib qho piv txwv tshiab ntawm JFileChooser chav kawm: JFileChooser fileChooser = tshiab JFileChooser();
  3. Teem cov directory tam sim no:
  4. Qhia lub dialog:
  5. Xyuas seb tus neeg siv xaiv cov ntaub ntawv lossis tsis:
  6. Xaiv cov ntaub ntawv xaiv:
  7. Thiab tag nrho cov code snippet yog raws li nram no:

Ib yam li ntawd, koj sau li cas rau cov ntaub ntawv hauv Java? FileWriter: FileWriter yog qhov yooj yim tshaj plaws txoj hauv kev los sau cov ntaub ntawv hauv Java . Nws muab overloaded sau txoj kev mus sau int, byte array, thiab String rau lub Cov ntaub ntawv . Koj tuaj yeem ua tau sau ib feem ntawm txoj hlua lossis byte array siv FileWriter. FileWriter sau ncaj qha rau hauv Cov ntaub ntawv thiab yuav tsum tau siv tsuas yog thaum tus lej sau tsawg dua.

Tom qab ntawd, ib tus tuaj yeem nug, JFileChooser yog dab tsi hauv Java?

JFileChooser yog ib feem ntawm java ua Swing pob. Cov java ua Swing pob yog ib feem ntawm JavaTM Foundation Classes (JFC). Java Viav vias muab cov khoom xws li cov nyees khawm, panels, dialogs, thiab lwm yam. JFileChooser yog ib txoj hauv kev yooj yim thiab muaj txiaj ntsig los qhia tus neeg siv xaiv cov ntaub ntawv lossis cov npe.

JOptionPane yog dab tsi hauv Java?

Java JOptionPane . Cov JOptionPane chav kawm yog siv los muab cov txheej txheem dialog box xws li cov lus dialog box, paub meej tias dialog box thiab input dialog box. Cov thawv sib tham no yog siv los tso saib cov ntaub ntawv lossis tau txais cov tswv yim los ntawm tus neeg siv. Cov JOptionPane chav kawm inherits JComponent chav kawm.

Pom zoo: