📄 view.java
字号:
}catch(Exception err){System.out.println("error!");}
}
}
class DealButton4Action implements ActionListener{
public void actionPerformed(ActionEvent e){
FtpServer.createServer();
}
}
class DealButton5Action implements ActionListener{
public void actionPerformed(ActionEvent event){
String dir = record_b.get(record_b.size()-2);
System.out.println(dir);
record_f.addElement(record_b.get(record_b.size()-1));
record_b.remove(record_b.size()-1);
jTextField1.setText(dir);
view.this.aboutTextFieldEvent();
}
}
class DealButton6Action implements ActionListener{
public void actionPerformed(ActionEvent event){
String dir = record_f.lastElement();
System.out.println(dir);
record_b.addElement(dir);
record_f.remove(record_f.size()-1);
jTextField1.setText(dir);
view.this.aboutTextFieldEvent();
}
}
class DealButton7Action implements ActionListener{
public void actionPerformed(ActionEvent e){
connector.disconnect();
((CardLayout)jPanel1.getLayout()).first(jPanel1);
jTextField1.setText(record_b.get(record_b.size()-2));
record_b.addElement(jTextField1.getText());
}
}
//****************************************************************
class DealNetTableAction implements MouseListener{
public void mouseClicked(MouseEvent e){
if (e.getButton() == MouseEvent.BUTTON3)
{
String downloadfile = (String)jTable2.getValueAt(jTable2.getSelectedRow(),0);
view.this.download = downloadfile;
jPopupMenu2.show(e.getComponent(),e.getX(),e.getY());
}
if (e.getClickCount() == 2)
{
try{
String getName = (String)jTable2.getValueAt(jTable2.getSelectedRow(),0);
System.out.println(getName);
String host = jTextField1.getText();
connector.cwd(getName);
connector.getList();
netfile = connector.fileName;
jTable2.setModel(new NetTableModel(netfile));
}catch(Exception t){}
}
}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
}
class DealTableAction implements TableModelListener,MouseListener{ //,ListSelectionListener,TableColumnModelListener
public void tableChanged(TableModelEvent e){
System.out.println("the table is changed!");
}
public void openFile(){
try{
File getFile = (myFile)jTable1.getValueAt(jTable1.getSelectedRow(),0);
jTextField1.setText(getFile.getAbsolutePath());
record_b.addElement(jTextField1.getText());
if (getFile.isFile())
Desktop.getDesktop().open(getFile);
if (getFile.isDirectory())
{
jTable1.setModel(new myTableModel(getFile.getAbsolutePath()));
Vector<File> storePath = new Vector<File>();
File listFile = getFile;
storePath.addElement(listFile);
while (listFile.getParent() != null)
{
listFile = listFile.getParentFile();
storePath.addElement(listFile);
}
Object[] treePath = new Object[storePath.size()+1];
for (int i=storePath.size()-1;i>=0;i--)
{
treePath[storePath.size()-i] = storePath.get(i);
}
File[] root = File.listRoots();
Vector<File> rootvector = new Vector<File>();
for (int i=0;i<root.length;i++)
rootvector.addElement(root[i]);
treePath[0] = rootvector;
TreePath inst = new TreePath(treePath);
jTree1.expandPath(inst);
}
}catch(IOException exc){System.out.println("error");}
}
public void preView(){
try{
File getFile = (myFile)jTable1.getValueAt(jTable1.getSelectedRow(),0);
if (getFile.getName().endsWith(".jpg")||getFile.getName().endsWith(".JPG"))
{
ImageIcon pictrue = new ImageIcon(getFile.getAbsolutePath());
Image rppic = pictrue.getImage();
jLabel2.setHorizontalAlignment(JLabel.CENTER);
jLabel2.setIcon(new ImageIcon(rppic.getScaledInstance(200,200,Image.SCALE_DEFAULT)));
((CardLayout)jPanel2.getLayout()).first(jPanel2);
}
if (getFile.getName().endsWith(".txt")||getFile.getName().endsWith(".java")||getFile.getName().endsWith(".asm"))
{
BufferedReader input = new BufferedReader(new InputStreamReader(new FileInputStream(getFile)));
String passage = new String();
String getString = new String();
while ((getString = input.readLine()) != null)
{
passage += getString;
passage += (char)10;
}
view.this.jTextArea1.setText(passage);
((CardLayout)jPanel2.getLayout()).last(jPanel2);
}
}
catch(FileNotFoundException e){}
catch(IOException e){}
}
public void mouseClicked(MouseEvent e){
if (e.getClickCount() == 2)
{
this.openFile();
}
if (e.getClickCount() == 1)
{
this.preView();
}
}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
}
class DealNetTreeAction implements MouseListener{
public void mouseClicked(MouseEvent e){
TreePath tp = ((JTree)e.getSource()).getSelectionPath();
if (tp != null)
{
String host = (String)tp.getLastPathComponent();
jTextField1.setText(host);
record_b.addElement(jTextField1.getText());
String userName = JOptionPane.showInputDialog(jPanel1,"Please write down your user name:");
String passWord = JOptionPane.showInputDialog(jPanel1,"Please write down the password:");
connector = new FtpClient();
connector.connect(host,21,userName,passWord);
connector.getList();
netfile = connector.fileName;
for (int i=0;i<netfile.size();i++)
System.out.println(netfile.get(i));
jTable2.setModel(new NetTableModel(netfile));
((CardLayout)jPanel1.getLayout()).last(jPanel1);
}
}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
}
class DealTreeAction implements TreeSelectionListener,TreeExpansionListener,TreeModelListener,MouseListener{
public void mouseClicked(MouseEvent e){
if (e.getButton() == MouseEvent.BUTTON3)
{
jPopupMenu1.show(e.getComponent(),e.getX(),e.getY());
TreePath getName = jTree1.getSelectionPath();
if (getName != null)
view.this.theSharefile = ((File)getName.getLastPathComponent()).getAbsolutePath();
}
else
{
TreePath tp = ((JTree)e.getSource()).getSelectionPath();
if (tp!=null)
{
if (tp.getLastPathComponent().getClass().toString().equals("class java.io.File")||
tp.getLastPathComponent().getClass().toString().equals("class explorer.myFile"))
{
File tempNode = (File)tp.getLastPathComponent();
view.this.jTextField1.setText(tempNode.getAbsolutePath());
record_b.addElement(jTextField1.getText());
if (tempNode.isDirectory())
{
view.this.path = tempNode.getAbsolutePath();
view.this.jTable1.setModel(new myTableModel(view.this.path));
((CardLayout)jPanel1.getLayout()).first(jPanel1);
}
if (tempNode.isFile())
{
try{
if (tempNode.getName().endsWith(".jpg")||tempNode.getName().endsWith(".JPG"))
{
ImageIcon pictrue = new ImageIcon(tempNode.getAbsolutePath());
Image rppic = pictrue.getImage();
jLabel2.setHorizontalAlignment(JLabel.CENTER);
jLabel2.setIcon(new ImageIcon(rppic.getScaledInstance(200,200,Image.SCALE_DEFAULT)));
((CardLayout)jPanel2.getLayout()).first(jPanel2);
}
if (tempNode.getName().endsWith(".txt")||tempNode.getName().endsWith(".java")||tempNode.getName().endsWith(".asm"))
{
BufferedReader input = new BufferedReader(new InputStreamReader(new FileInputStream(tempNode)));
String passage = new String();
String getString = new String();
while ((getString = input.readLine()) != null)
{
passage += getString;
passage += (char)10;
}
view.this.jTextArea1.setText(passage);
((CardLayout)jPanel2.getLayout()).last(jPanel2);
}
}
catch(FileNotFoundException err){}
catch(IOException err){}
}
}
else
{
jTextField1.setText("Jason's Computer");
record_b.addElement(jTextField1.getText());
Vector<File> getRoot = (Vector<File>)tp.getLastPathComponent();
view.this.jTable1.setModel(new myTableModel(getRoot));
}
}
}
}
public void valueChanged(TreeSelectionEvent e){}
public void treeExpanded(TreeExpansionEvent e){}
public void treeCollapsed(TreeExpansionEvent e){}
public void treeNodesChanged(TreeModelEvent e){}
public void treeNodesInserted(TreeModelEvent e){}
public void treeNodesRemoved(TreeModelEvent e){}
public void treeStructureChanged(TreeModelEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
}
//**************************************************************************
// 变量声明 - 不进行修改//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenu jMenu4;
private javax.swing.JMenu jMenu5;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem10;
private javax.swing.JMenuItem jMenuItem11;
private javax.swing.JMenuItem jMenuItem12;
private javax.swing.JMenuItem jMenuItem13;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JMenuItem jMenuItem6;
private javax.swing.JMenuItem jMenuItem7;
private javax.swing.JMenuItem jMenuItem8;
private javax.swing.JMenuItem jMenuItem9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPopupMenu jPopupMenu1;
private javax.swing.JPopupMenu jPopupMenu2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JSplitPane jSplitPane1;
private javax.swing.JTable jTable1;
private javax.swing.JTable jTable2;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField jTextField1;
private javax.swing.JToolBar jToolBar1;
private javax.swing.JTree jTree1;
private javax.swing.JTree jTree2;
// 变量声明结束//GEN-END:variables
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -