Home > Back-end >  Hope in JTree add a scroll bar and displayed, best can modify the source code and then send in the r
Hope in JTree add a scroll bar and displayed, best can modify the source code and then send in the r

Time:09-22

The import javax.mail. Swing. *;
The import javax.mail. Swing. Tree. DefaultMutableTreeNode;

import java.sql.*;
Public class information_student extends JFrame {
Public static void main (String [] args) {
JFrame frame=new JFrame (" personal information ");
JTree tree;
JPanel con;
The Font Font=new Font (" black ", the Font. PLAIN, 20).
frame.setVisible(true);
Frame. SetExtendedState (MAXIMIZED_BOTH);
Frame. SetResizable (false);
Frame. SetLayout (null);
DefaultMutableTreeNode root=new DefaultMutableTreeNode (" student information ");
DefaultMutableTreeNode information_person=new DefaultMutableTreeNode (" personal information ");
DefaultMutableTreeNode information_course=new DefaultMutableTreeNode (" registration information ");
DefaultMutableTreeNode information_safe=new DefaultMutableTreeNode (" accounts ");
DefaultMutableTreeNode basic=new DefaultMutableTreeNode (" basic information ");
DefaultMutableTreeNode education=new DefaultMutableTreeNode (" teaching information ");
DefaultMutableTreeNode select=new DefaultMutableTreeNode (" choosing courses ");
DefaultMutableTreeNode selected=new DefaultMutableTreeNode (" selected courses ");
DefaultMutableTreeNode alter=new DefaultMutableTreeNode (" modify course ");
Root. The add (information_person);
Root. The add (information_course);
Root. The add (information_safe);
Information_person. Add (basic);
Information_person. Add (education);
Information_course. Add (select);
Information_course. Add (selected);
Information_course. Add (alter);
The tree=new JTree (root);
Tree. The setFont (new Font (" black ", the Font. PLAIN, 18));
Tree. SetBorder (BorderFactory. CreateEmptyBorder (10, 5, 10, 10));
Con=new JPanel ();
The JScrollPane scroll=new JScrollPane ();
Scroll. SetViewportView (tree);
Frame. The add (scroll);
Scroll. SetBounds (0150250980);
}
}
  • Related