📄 explorer.java
字号:
import java.awt.* ;import java.awt.event.* ;import java.io.* ;import javax.swing.* ;import javax.swing.tree.* ;/** * Swing-Applikation ähnlich dem Windows-Explorer * <BR><BR> * Die Kommunikation zwischen<BR> * Explorer-Fenster<BR> * Tree-Feld<BR> * Table-Feld<BR> * Laufwerk-Buttons<BR> * erfolgt nach dem Model-View-Controller-Pattern. * <BR><BR> */public class Explorer { ExplorerFrame xFrame = new ExplorerFrame( this ) ; String focusDir = "." ; DefaultMutableTreeNode focusNode ; TreeFeld treeFeld ; TableFeld tableFeld ; ToolLeiste toolLeiste ; public static void main( String[] args ) { try { System.setErr( new ErrPrintStream() ) ; } catch ( IOException e ) { System.err.println( e.getMessage() ); e.printStackTrace(); } ; try { /* UIManager.LookAndFeelInfo[] inf=UIManager.getInstalledLookAndFeels(); for(int i=0;i<inf.length;i++) { UIManager.LookAndFeelInfo t=inf[i]; System.out.println(t.getClassName()); }; */ UIManager.setLookAndFeel( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" ) ; } catch ( Exception e ) { System.out.println( "unbekanntes Look & Feel" ) ; } Explorer ex = new Explorer() ; } public void setTitle( String s ) { if ( xFrame == null ) { return ; } xFrame.setTitle( s ) ; } // setzt das Focusverzeichnis im Baum public void setTreeSubDir( String neuDir ) { treeFeld.setSubDir( neuDir ) ; } // setzt das Focusverzeichnis im Table public void setTableDir( String neuDir ) { if ( tableFeld == null ) { return ; } tableFeld.setDir( neuDir ) ; } // Aktualisieren Table public void updateTableDir() { tableFeld.setDir( tableFeld.getDir() ) ; } public void setFocusNode( DefaultMutableTreeNode fN ) { focusNode = fN ; } public DefaultMutableTreeNode getFocusNode() { return focusNode ; } public void setRoot( String rootName ) { treeFeld.setRoot( rootName ) ; xFrame.validate() ; }// ************************************************** class ExplorerFrame extends JFrame { public ExplorerFrame( Explorer ex ) { super( "Java - Explorer" ) ; TrennFeld trennFeld ; trennFeld = new TrennFeld( ex ) ; getContentPane().add( trennFeld ) ; // setJMenuBar(new TabelleMenuBar001(tabelle001)); addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent e ) { System.exit( 0 ) ; } } ) ; // xFrame.setSize(200,200); pack() ; setVisible( true ) ; } }// ************************************************** class TrennFeld extends JPanel { TrennFeld( Explorer ex ) { treeFeld = new TreeFeld( ex ) ; // Konstruktor mit Uebergabe einer Referenz auf die Explorer-Klasse zum Registrieren als Listener tableFeld = new TableFeld( ex ) ; // Konstruktor mit Uebergabe einer Referenz auf die Explorer-Klasse zum Registrieren als Listener toolLeiste = new ToolLeiste( ex ) ; setLayout( new BorderLayout() ) ; add( toolLeiste , BorderLayout.NORTH ) ; // TrennFeld vertikal teilen und konzinuierlich neu aufbauen JSplitPane tp1 = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT , false , treeFeld , tableFeld ) ; tp1.setContinuousLayout( true ) ; tp1.setDividerSize( 1 ) ; add( tp1 , BorderLayout.CENTER ) ; } }// **************************************************} // end class Explorer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -