1 import java.awt.Button; 2 import java.awt.Component; 3 import java.awt.List; 4 import java.awt.event.ActionEvent; 5 import java.awt.event.ActionListener; 6 import java.awt.event.MouseEvent; 7 import java.io.File; 8 import java.util.Arrays; 9 10 import javax.management.modelmbean.ModelMBean; 11 import javax.swing.JButton; 12 import javax.swing.JComponent; 13 import javax.swing.JFrame; 14 import javax.swing.JInternalFrame; 15 import javax.swing.JLabel; 16 import javax.swing.JPanel; 17 import javax.swing.JSplitPane; 18 import javax.swing.JTable; 19 import javax.swing.JTextField; 20 import javax.swing.JTree; 21 import javax.swing.tree.DefaultMutableTreeNode; 22 import javax.swing.tree.DefaultTreeModel; 23 import javax.swing.tree.TreeNode; 24 25 import org.omg.CORBA.PUBLIC_MEMBER; 26 27 public class arraylist{ 28 public static void main(String args[]) { 29 30 CFrame a = new CFrame(800, 600); 31 32 33 34 } 35 } 36 37 38 39 40 41 class CFrame extends JFrame implements ActionListener { 42 /** 43 * 44 */ 45 private static final long serialVersionUID = 1L; 46 47 //public canshu 48 private JLabel jinduJLabel; 49 private JLabel ipJLabel ; 50 private JButton downloadJButton; 51 private JButton stopJButton; 52 private JButton link; 53 private JTextField ipJTextField; 54 private JTextField portJTextField; 55 private JPanel FileTree; 56 57 public CFrame(int w,int s) { 58 // TODO Auto-generated constructor stub 59 setVisible(true); 60 setLocation(200, 100); 61 setSize(w, s); 62 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 63 64 JSplitPane fistJSplitPane = new JSplitPane(0); 65 JSplitPane secoJSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); 66 fistJSplitPane.setRightComponent(secoJSplitPane); 67 add(fistJSplitPane); 68 69 JPanel Buttons = new JPanel(); 70 71 //IP 72 ipJLabel = new JLabel("IP"); 73 Buttons.add(ipJLabel); 74 75 //iptext 76 ipJTextField = new JTextField(18); 77 Buttons.add(ipJTextField); 78 //port 79 JLabel portJLabel = new JLabel("PORT"); 80 Buttons.add(portJLabel); 81 //port Text 82 portJTextField = new JTextField(4); 83 Buttons.add(portJTextField); 84 //link 85 link= new JButton("LINK"); 86 link.addActionListener(this); 87 Buttons.add(link); 88 89 //download 90 downloadJButton = new JButton("DOWNLOAD"); 91 downloadJButton.addActionListener(this); 92 Buttons.add(downloadJButton); 93 //STOP 94 stopJButton = new JButton("STOP"); 95 stopJButton.addActionListener(this); 96 Buttons.add(stopJButton); 97 //jindu 98 jinduJLabel=new JLabel(); 99 Buttons.add(jinduJLabel); 100 fistJSplitPane.setLeftComponent(Buttons); 101 102 //file tree 103 FileTree = new JPanel(); 104 //FileTree.add(stopJButton); 105 secoJSplitPane.setLeftComponent(FileTree); 106 107 //download file tabel 108 JPanel tableJPanel = new JPanel(); 109 //tabel 110 JTable table = new JTable(); 111 tableJPanel.add(table); 112 secoJSplitPane.setRightComponent(tableJPanel); 113 114 115 116 117 118 } 119 120 private TreeNode makeEditableTree() { 121 // TODO Auto-generated method stub 122 DefaultMutableTreeNode root = new DefaultMutableTreeNode("object"); 123 return root; 124 } 125 126 @Override 127 public void actionPerformed(ActionEvent e) { 128 129 130 if (e.getSource()==link) { 131 TreeNode treeNode = makeEditableTree(); 132 JTree tree = new JTree(new DefaultTreeModel(treeNode)) ; 133 tree.setEditable(true); 134 FileTree.add(tree); 135 //product tree 136 137 138 jinduJLabel.setText("link"); 139 140 } else if(e.getSource()==downloadJButton){ 141 jinduJLabel.setText("download"); 142 143 } 144 else if (e.getSource()==stopJButton) { 145 jinduJLabel.setText("stop"); 146 147 } 148 else {} 149 150 } 151 }
时间: 2024-10-25 02:22:57