Results 1 to 5 of 5
Thread: Save a JPanel in NetBeans 7.0.1
- 08-15-2011, 04:15 PM #1
Member
- Join Date
- Aug 2011
- Location
- Bogotá
- Posts
- 28
- Rep Power
- 0
Save a JPanel in NetBeans 7.0.1
Hi, How can I to save a JPanel I using? I want to save this Jpanel and can load it in the future. This JPanel contains a matrix of JButtons and other one of JLabels, the JButtons changes its own text and the text of the JLabels too. Then, I want reload the Jpanel for I can work on it. I've read about "Serialization" in java but I don't understand yet.
Last edited by mad72584; 08-15-2011 at 04:18 PM.
- 08-15-2011, 06:04 PM #2
hello, you don't need to serialize the whole jpanel but you can read each jlabel text with the method getText() and than save it as String. For this you can use a PrintWriter : PrintWriter*«*File*«*Java Tutorial. When the jpanel is build, you can read the labels from your file with example a FileReader*«*File*«*Java Tutorial and set the labels with the method setText()
- 08-15-2011, 06:31 PM #3
Member
- Join Date
- Aug 2011
- Location
- Bogotá
- Posts
- 28
- Rep Power
- 0
Thanks! It looks easy, I'll read it and test it and I'll coment you. Meanwhile, I wait for more options. Thanks j2me64.
- 08-15-2011, 06:36 PM #4
Another possibility is the XMLEncoder and XMLDecoder classes.
- 08-17-2011, 02:16 PM #5
Member
- Join Date
- Aug 2011
- Location
- Bogotá
- Posts
- 28
- Rep Power
- 0
Similar Threads
-
Trouble adding JPanel to JFrame with NetBeans IDE
By ozzyman in forum New To JavaReplies: 1Last Post: 05-23-2011, 11:35 PM -
jpanel not showing up under inspector in netbeans
By pink123 in forum AWT / SwingReplies: 3Last Post: 03-31-2011, 04:39 AM -
Need to Save a data to file from JPanel and read the data back to Jpanel
By yashrajsen in forum AWT / SwingReplies: 1Last Post: 11-09-2010, 10:28 AM -
How can I add image to a JPanel using netbeans
By shahid0627 in forum AWT / SwingReplies: 5Last Post: 09-01-2009, 08:56 AM -
How to draw in a JPanel using Netbeans 6.1 GUI maker
By Gatts79 in forum New To JavaReplies: 4Last Post: 08-28-2009, 07:50 PM
Bookmarks