In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the relevant knowledge of how to realize the initialization of Netbeans JTree, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this article on how to initialize Netbeans JTree. Let's take a look.
In Netbeans JTree, the originally generated JTree is a fake tree. You can write the initialization function of JTree, and then call it after the window is initialized:
Public void treeInitialize () {DefaultMutableTreeNode root=new DefaultMutableTreeNode ("root"); try {m_DBMetaData = m_connection.getMetaData (); m_tabReset = m_DBMetaData.getTables (null, "%", "%", new String [] {"TABLES"}) While (m_tabReset.next ()) {DefaultMutableTreeNode t_newNode = new DefaultMutableTreeNode (m_tabReset.getString ("TABLE_NAME")); root.add (t_newNode);} TreeModel treeModel = new DefaultTreeModel (root); jDBTree.setModel (treeModel) } catch (SQLException e) {JOptionPane.showMessageDialog (this, "database access error"); System.exit (1);}}
This program fetches the table name from the database as the leaf node of JTree.
The response of the JTree leaf node double-click event and the acquisition of its Text:
Add MouseClicked event
Private void jDBTreeMouseClicked (java.awt.event.MouseEvent evt) {/ / TODO will add your processing code here: DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) jDBTree.getLastSelectedPathComponent (); / / get the mouse click point if (selectedNode = = null) {return / / if it is not a node on the tree} if (selectedNode.isLeaf () & & evt.getClickCount () = = 2) {/ / make sure it is a leaf node and a double / / click event. ViewTable (selectedNode.toString ()); / / the parameter is the Text of the node. }} this is the end of the article on "how to initialize Netbeans JTree". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to realize the initialization of Netbeans JTree". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.