이 기사에서는 Javafx에서 [My Computer Explorer]의 간단한 구현에 대해 설명합니다. 참조를 위해 공유하십시오. 세부 사항은 다음과 같습니다.
1. Java 코드 :
패키지 ttt; import java.io.file; import javafx.application.application; import javafx.beans.value.changelistener; import javafx.beans.value.obser vablevalue; import javafx.collections.fxcollections; import javafx.collections.observablevelist; import javafx.scene.scene; import javafx.scene.control.tablecolumn; import javafx.scene.control.tableview; import javafx.scene.control.treeitem; import javafx.scene.layout.borderpane; import javafx.scene.layout .hbox; import javafx.scene.layout.priority; import javafx.stage.stage; import javafx.scene.control.treeview; import javafx.scene.control.cell.proper tyvaluefactory; public class views application {public static votchablelist < fileteal> data = fxcollections.observablearraylist (); Resource Management "); treeitem <file> rootitem = new TreeItem <> (새 파일 (System.getenv ("computername "))); for (파일 파일 : file.listroots ()) {filetreeitem rootsite = new Filetreeitem (file) rootitem.getchildren (). Tablecolumn <filedetail, string> new Tablecolumn <> ( "파일"); SecondColumn = "Type"); (최종 수정); SetCellValueFactory (New PropertyValueFactory, String> ( "LastModified"); Sethrow (Tree, Priority.Always) 매 ; setall (TableList)});
2. Java 코드 :
packing Java.io.file; import Java.util.date {private string filename; String 유형; Private SimpledateFormat FMT (파일) {isfile.isfile. filename = getname (); "yyyy-mm-dd hh : mm"; .length = length (); this.type = "폴더"; etfilename () {return filename} public void setfilename (filename = filename) {return lastmodified; {반환 유형} public void settype (String type).
3. Java 코드 :
packing ttt; import java.io.file; import javafx.collections.fxcollection; import javafx.collections.bservablelist; public class filetreeitem은 treeitem <file> {private bolean isleaf isfir volean isfir isfir Private Boolean isfirsttimeLeaf = true (file) {public vistmentablelist <treeitem >> getchil dren (isfirsttimechildren) {super.getchildren setAll (the returnchildren (this)} return super. isfile (); isleaf repinse isleaf; [] files = f.listfiles (); if (files! = null) {persitive <treeitem <file >> childrens.observablearraylist (file childfile : files) {c hidden.add (childfile. ));
4. 실행 효과의 스크린 샷 :
이 기사가 모든 사람의 Java 프로그래밍에 도움이되기를 바랍니다.