Results 1 to 3 of 3
Thread: Saving objects problem
- 01-15-2011, 10:31 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 7
- Rep Power
- 0
Saving objects problem
I'm not sure if this is the correct section, but I'll go ahead and post. I have 3 button groups, consisting of 2 JRadioButtons. I have Two JTextFields. How do I get it so after the first time the person presses the set up Button (Which brings up to all the components above), it will save what I put in the text fields, and which buttons I press? I'm just trying to get one down, I'll get the rest. In one of the text fields, you have to enter a method name(this is a utility program).
I also set up a static int so it increments itself everytime you click the apply button (closes the window).
When you click the set up button and opens the set up window:
When I click the apply button:Java Code:if (setUpClick >= 1) { try { FileInputStream setUpInfo = new FileInputStream("Set Up Info.ser"); ObjectInputStream setUpObject = new ObjectInputStream(setUpInfo); String theMethodName = (String) setUpObject.readObject(); setUpObject.close(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } methodName.setText(theMethodName); }
This doesn't work. I don't know why.Java Code:public class ApplyButton implements ActionListener { public void actionPerformed(ActionEvent event) { try { FileOutputStream setUpWriting = new FileOutputStream("Set Up Info.ser"); ObjectOutputStream objectSetUp = new ObjectOutputStream(setUpWriting); objectSetUp.writeObject(theMethodName); objectSetUp.close(); } catch (IOException ex) { ex.printStackTrace(); } setUpClick++; setUpFrame.dispose(); } }
-
I'm not sure that I fully understand your question, but perhaps you don't want to dispose of your GUI window but rather call setVisible(false) on it. Then if you are to display it again, first check if it is null and if so, create the gui window, but if not, call setVisible(true) on it -- in other words do a lazy initialization of it.
- 01-15-2011, 10:49 PM #3
Member
- Join Date
- Jan 2011
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
regarding saving files or objects in database
By sandeepsai39 in forum New To JavaReplies: 10Last Post: 08-28-2010, 06:09 AM -
problem in saving file
By jogendar in forum Advanced JavaReplies: 2Last Post: 01-23-2010, 04:28 PM -
Saving Objects Permanently?
By ethann_91 in forum New To JavaReplies: 1Last Post: 01-20-2010, 08:03 AM -
help needed in saving objects
By sandeepsai17 in forum New To JavaReplies: 6Last Post: 06-30-2009, 04:02 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks