22 23 24 25 26 27 28
INSERT I IN NT TO `subcategory` (`scat (1,1,'Samsung'), (2,2,'A4Tech'), (3,1,'Philips'), (4,2,'Sonic'), (5,3,'Perfect');
host it on google or amazon cloud as i did this ... It rajuahmed: depends on you… ust carry on. ... Robinkhan: Thank you Sir ...
Noow w creeaattee a j avvaa p ro j eecctt a tt neettbbeea n aanndd crreeaattee tthhe ffool l o w wiingg cl a sssseess: Daattaabbaassee..jjaavvaa //for making the connection 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
package e util; import java.sql.Connection; import java.sql.DriverManager; public c cl la ass Database { p pu ub bl lic st ta at ti ic Connection g try { Class.forName("com Connection con = D ("jdbc:mys "root","yo r re et tu urn con; } catch h(Exception ex) { System.out.println r re et tu urn nu ul ll l; } } p pu ub blic s st ta at tic vo oi id d close( try { con.close(); } catch h(Exception ex) { } } }
Diissppllaay Caatteeggo ry ..jjaavvaa //to display the JTree //Basically this is a JFrame 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
packag ge e display; import t java.sql.*; import t java.util.ArrayList; import t javax.swing.tree.Default import t javax.swing.tree.Default import t util.Database; public c c cl lass DisplayCategory e ex x Connection con = n nu ul ll l; Statement stm = nu ul ll l; pu ub bl li ic DisplayCategory() { initComponents(); pop_tree();//call to po } //System generated code
CATEGORIES
► Android (19) ▼ Core Java (37) ► Core Java Basic by Example (4) ▼ Swing (27) » Android like Toast using Java Swing » Backup & Restore MySQL Database Using Java-Complet e Solution » copylibs doesn't support the "excludeFro mCopy" attribute » Custom JButton with Gradient Color » Custom JDialog with Expandable Details Pane » Display Image on JFrame from MySQL
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
@SuppressWarnings("unchecke // @SuppressWarnings("CallToTh pu ub bl li ic fin na al l void pop_tree( try { tr ry y { con = Database. stm = con.creat } c ca at tch (Exception ex.printStackTr } ArrayList list = n ne e list.add("Category
» Dynamic JTable: Display Sum of Selected Row » Dynamically add row to JTable » Event handle using implements » Event handle using inner class » How to add JPopupMenu to JFrame and image as background of JFrame » JMenuBar Background Image Example » JSplitPane with ClosableTab Application » JTextPane Line Number » JToolBar Background Image Example » P ooppul aattee JJTTrreeee ffrroom m M ySSQ QLL Daatta b a ssee » Print JTextArea using PrinterJob in Java » Resize image and upload
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
String sql = "SELEC ResultSet rs = stm. wh hi il le e (rs.next()) { Object value[] list.add(value) } Object hierarchy[] DefaultMutableTreeN DefaultTreeModel tr cat_tree.setModel(t } catc ch h (Exception e) { } } @SuppressWarnings("CallToTh pu ub bl li ic DefaultMutableTreeNo DefaultMutableTreeNode try { in nt t ctrow = 0; in nt t i = 0; tr ry y { try { con = Datab stm = con.c } catc ch h (Except ex.printSta } String sql = "S ResultSet rs = while (rs.next( ctrow = rs. } String L1Nam[] String L1Id[] = ResultSet rs1 = while (rs1.next L1Nam[i] = L1Id[i] = r i++; } DefaultMutableT for (i in nt t childI child = ne ew w node.add(ch String sql2 ResultSet r wh hi il le e (rs3. grandch child.a } } } c ca at tch (Exception ex.printStackTr }
to MySQL db using Java Swing » Shaking JFrame With Blinking Effect If Login Unsuccessful » Simple Slideshow using Card Layout » Simple Splash Screen with Progress Bar in Java Swing » Some Important Tips About Several Components in Swing » Status Bar Example for JFrame » Use of Bangla Localization in Java Swing » Using JDateChoose r From Your NetBeans Palette » Working with JList » Write The Contents of a JFrame to a Text File and Display Recorded Data to a JTable » copylibs doesn't
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
} catc ch h (Exception e) { } return (node); } pu ub bl li ic sta at ti ic c void d main(Str java.awt.EventQueue.inv pu ub bl li ic voi id d run() { new DisplayCate } }); } // Variables declaration pr ri iv va ate javax.swing.JTree c pr ri iv va ate javax.swing.JPanel pr ri iv va ate javax.swing.JScroll // End of variables declara }
T hi s i s tthhee o uuttpputt::
JTree Displaying tree from MySQL db
support the "excludeFromC opy" attribute » Create Jar File Programmatica lly » How to add Notification to System Tray in java » Play Sound on Button Click in Java » Some Tips on Working with Date in Java » Sorting dynamic array
► Free Projects (2) ► Hibernate (5) ► Jasper report (7) ► JSF 2.0 (13) ► JSP & Servlet (9) ► JSTL 1.1 (4) ► NetBeans (2) ► PrimeFaces (8) ► Programming Tutorial(video) (10) ► Software (3) ► Spring (1) ► Struts2 (1) ► Tomcat (2)
TAG CLOUD
Re l ate d P o sttss
SplitPane with
Simple CRUD Using
ClosableTab Application
JSF2+Hibernate Integration and MySQL
META
Upload and display
Jsp, Servlet, JSTL and
image from MySQL db
MySQL Simple CRUD
using PrimeFaces
Application
Register Log in Entries RSS Comments RSS WordPress.org
ARCHIVES CALENDAR
September 2015 M M TT W W TT FF SS SS
1 2 3 4 5 6 Sample Login app in
Login and Registration
7 8 9 10 11 12 13
android using Servlet
Example in JSP with
14151617181920
and JSON Parsing
Session
T T w w eeeett Tw we
0
0
S Shhaarree
21222324252627 4
LLiikkee
4
S Shhaarree
282930 « Jun
ARCHIVES
adm iin n Hello! I am Md. Abdul
Select Month
Bari; founder and admin of javaknowledge; currently providing training as a J2EE faculty in The Computers Ltd. Dhaka, Bangladesh under
CONNECT ON FACEBOOK
an IT Scholarship project provided by IDB-BISEW. I
Javaknowledge 3,053 likes
am a self learner and passionate about training and writing. I am always trying my best to share my knowledge through
LLiikkee PPaaggee
Be the first of your friends to like this
my blog. More Posts - Website Follow Me:
Tweets
w FFoollllo olllloow ow
13 Aug
javaknowledge
tagged with JTree, mysql, Populate JTree Swing
@java_knowledge
JAVA Training With Live Project fb.me/3AONeTA
10,381` Total Views
11 Aug
javaknowledge
LEAVE A R EPLY Your email address will not be published. Required fields are marked *
Tweet to ava_knowled e
SITE RANK
Name *
Email *
Website BLOG STATISTICS
− 1 = eight
Comment
User Online: 3 Today Visitor: 1,137 Yesterday Visitor: 823 Total Visit: 2,241,304 Total Posts: 108 Total Comments:
Post Comment
6 C O MM EN T S Pradeep
March 6, 2013 1:51 pm
Thank you very much sir..!! I appreciate your work and i have been looking for this everywhere, and I’m novel for java. Your tutorial is much helped me. Could you please explain me how to add another level for this tree… Eg – Category List -Monitor –Samsung —Korean Samsung —Chinese Samsung –Philips -Mouse –A4Tech –Sonic -Keyboard –Perfect I’ve stuck on my project and need to solve this problem ASAP. I would really appreciate your help. Thank You -Pradeep PS (Please don’t mind my English , coz i’m not native English speaker):) Reply gp
January 31, 2014 6:28 am
Pradeep, i have the same question, do you have a solution ?
Reply
530 Total Users: 16,395 Last Post Date: June 7, 2015
Pradeep
March 6, 2013 1:54 pm
Appreciate if you can explain how database should be altered and codings, bcoz i’m really novel to java. Thanks in advance Reply Arnab Saha
August 9, 2013 1:40 pm
Nice job
Reply a_omess
June 17, 2014 9:39 am
Thank you, this really helped my work.
Reply madhusara
December 20, 2014 1:48 am
thanx sir for all example
Reply
Journey to the way of Java...
zeeDynamic Theme