????1 ??y?
??????????java??ó???JavaApp???????????????????????м????????????????(JDBC ????MYSQL?????)?????????????????????.????????????????????????????.java swing?????JTabbedPane???????????????????????com.mkmis.controls??????????????TabbedPane?????????????????????????.??y?????????:

????2 ??????????
??????IDE????????Login??JFrame???壬????[???]?????????????????е???????????????????Vistual Studio??????????????????Ч?????????Vistual Studio.??????????????????Σ????????????????ο??.?????????????????????.
??????????????????а????????Ч??????????:

????3 ???????????
????Java Swing??????????????????????NET???????.??????????????java swing?????setTitle().??????????????setLocationRelativeTo(getOwner()). ???????????getText()?????????′??????:
????1     public Login() {
????2         initComponents();
????3         setTitle("???");
????4         setDefaultCloseOperation(EXIT_ON_CLOSE);
????5         setVisible(true);
????6         setResizable(false);
????7         setLocationRelativeTo(getOwner()); //???????
????8
????9     }
????1  private void btnLoginActionPerformed(java.awt.event.ActionEvent evt) {
????2     // TODO add your handling code here:
????3     if(this.txtUserName.getText()!="" && this.txtPWD.getText().toString()!="")
????4     {
????5         Connection conn = DBConnection.getConnection();
????6         PreparedStatement ps = null;
????7         ResultSet rs = null;
????8         try {
????9             ps = conn.prepareStatement(
????"select * from users where UserName = ? and password = ?");
????10             ps.setString(1??this.txtUserName.getText());//
????11             ps.setString(2?? this.txtPWD.getText());
????12             rs = ps.executeQuery();
????13             while (rs.next()) {
????14                 User user = new User();
????15                 user.setId(rs.getInt("id"));
????16                 user.setUsername(rs.getString("UserName"));
????17                 user.setPassword(rs.getString("password"));
????18
????19                 System.out.println(user.toString());
????20                 //??????
????21                 FrameMain frm=new FrameMain(user.getUsername());
????22                 frm.setVisible(true);
????23                 this.dispose();//?????????
????24
????25             }
????26         } catch (SQLException e) {
????27             e.printStackTrace();
????28         } finally {
????29             DBConnection.closeResultSet(rs);
????30             DBConnection.closeStatement(ps);
????31             DBConnection.closeConnection(conn);
????32         }
????33
????34      }
????35  }
??????????????????????setVisiable(true);?????????????dispose();??????????????????????????????enter???????????????????????£???????????????????????????????keypressed??????????????????????????????????(???δ?????!)?????′??????:
????1    private void txtPWDKeyPressed(java.awt.event.KeyEvent evt) {
????2         // TODO add your handling code here:
????3         if(evt.getKeyCode()==KeyEvent.VK_ENTER)
????4         {
????5             //?????????
????6             btnLoginActionPerformed(null);
????7
????8         }
????9     }
????4 ??????
???????????????????????????????????????????(???????????????????)?????????????????:
??????????????JFreeChart?????????????????????????????????????????????????н??.?????????????????????????this.setExtendedState(this.getExtendedState()|JFrame.MAXMIZED_BOTH).???????????????????????С?仯?????????????????????????????????.
????1     public FrameMain(){
????2         initComponents();
????3          setLocationRelativeTo(getOwner()); //???????
????4          this.setExtendedState(this.getExtendedState()|JFrame.MAXIMIZED_BOTH );
????//?? window
????5          LoadTree();
????6
????7     }
????8     public FrameMain(String uname){
????9         initComponents();
????10          setLocationRelativeTo(getOwner()); //???????
????11          this.setExtendedState(this.getExtendedState()|JFrame.MAXIMIZED_BOTH );
????12          LoadTree();
????13          this.lblUser.setText("??? "+uname+ " ???!");
????14
????15     }
???????????????????????LoadTree??????????????????????????:
????1     private void LoadTree()
????2     {
????3         //????????????????
????4         jTabbedPane1.setCloseButtonEnabled(true);
????5
????6         DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("?????");
????7         node1.add(new DefaultMutableTreeNode("?????"));
????8         node1.add(new DefaultMutableTreeNode("?????"));
????9         node1.add(new DefaultMutableTreeNode("????"));
????10
????11         DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("?????");
????12         node2.add(new DefaultMutableTreeNode("jack"));
????13         node2.add(new DefaultMutableTreeNode("Lily"));
????14         node2.add(new DefaultMutableTreeNode("Smith"));
????15
????16         DefaultMutableTreeNode top = new DefaultMutableTreeNode("??????");
????17
????18
????19         top.add(new DefaultMutableTreeNode("?????"));
????20         top.add(node1);
????21         top.add(node2);
????22
????23         //JTree tree=new JTree(top);
????24         DefaultTreeModel model = new DefaultTreeModel (top);
????25         this.jTree1.setModel(model);
????26        //jTree1.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION)
????27        //set jframe icon
????28        try
????29
????30        {
????31        Image icon= ImageIO.read(this.getClass().getResource("/images/Icon.png"));
????32        tabIcon = createImageIcon("/images/Icon.png"?? "tab icon");
????33
????34        this.setIconImage(icon);
????35        }
????36        catch(IOException ex)
????37        {
????38
????39            System.out.println(ex);
????40
????41        }
????42
????43     }
??????Tree????仯????У????class.forName()?? cls.newInstance()?????????????壬????????:
????1     private void jTree1ValueChanged(javax.swing.event.TreeSelectionEvent evt) {
????2         // TODO add your handling code here:
????3
????4        DefaultMutableTreeNode node = (DefaultMutableTreeNode)
????jTree1.getLastSelectedPathComponent();
????5
????6         if (node == null){
????7             //Nothing is selected.
????8              return;
????9         }
????10
????11         Object nodeInfo = node.getUserObject();
????12         String item = (String) nodeInfo;
????13
????14         if (node.isLeaf()) {
????15             String item1 = (String) nodeInfo;
????16             // this.setTitle(item1);
????17             //File f = new File("client.jar");
????18             //URLClassLoader cl = new URLClassLoader(new URL[]{f.toURI().toURL()?? null});
????19             //Class<?> clazz = cl.loadClass("epicurus.Client");
????20             //Method main = clazz.getMethod("main"?? String[].class);
????21             //main.invoke(null?? new Object[]{new String[]{}});
????22             try {
????23                 Class cls = Class.forName("com.mkmis.forms.JIFrame1");
????24                 javax.swing.JInternalFrame frm =
????(javax.swing.JInternalFrame) cls.newInstance();
????25                  frm.setVisible(true);
????26
????27                 //jTabbedPane1.addTab(" "+item1+"  "??null??frm);
????28                 jTabbedPane1.addTab(" "+item1+"  "??this.tabIcon??frm);
????29
????30              }
????31              catch (Throwable e) {
????32                 System.err.println(e);
????33              }
????34         } else {
????35             System.out.println("not leaf");
????36         }
????37     }
??????javaswing?е?·?????net????????漲???????????ImageIcon?????:
????1     /** Returns an ImageIcon?? or null if the path was invalid. */
????2     protected ImageIcon createImageIcon(String path??String description) {
????3         java.net.URL imgURL = getClass().getResource(path);
????4         if (imgURL != null) {
????5             return new ImageIcon(imgURL?? description);
????6         } else {
????7             System.err.println("Couldn't find file: " + path);
????8             return null;
????9         }
????10     }