Reading from text fields

After some exercising with logging now it stop write into dcc.properties file and delete all values from it.
When I put in new values into dcc.properties directly and when I start app it prints this values well, but when I change them, file still have old values.
Everything was working like watch, what may happened.
I even come back with Subversion, but I didn't find any critical changes into the code, reload JDeveloper - nothing!
gbcbrAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
gui.ser was there when i last looked;)

Logging is not really connected with the problem most probably. You just need to ensure the the file saving method is called - why not add some logging to see what's happening?
gbcbrAuthor Commented:
dcc.properties
#Sat Mar 26 18:31:41 EET 2011
eurusd_support=1.39
eurusd_resist=1.42
eurjpy_resist=1
eurchf_support=1
eurgbp_support=1
usdchf_resist=1
chfjpy_resist=1
eurjpy_support=1
gbpusd_resist=1
gbpjpy_resist=1
eurchf_resist=1
gbpchf_support=1
eurgbp_resist=1
gbpjpy_support=1
gbpchf_resist=1
usdjpy_support=1
gbpusd_support=1
chfjpy_support=1
usdchf_support=1
usdjpy_resist=1

Open in new window

Exit
void fileExit_ActionPerformed() {
        mFxcmGateway.logout();
        windowClosing();
        System.exit(0);
    }

    public void windowClosing() {
        OutputStream out = null;

        try {
            Properties prop = new Properties();
            out = new FileOutputStream("dcc.properties");

            System.out.println(" FileOutputStream = " + out);

            prop.setProperty("eurusd_support", eurusd_support);
            prop.setProperty("eurusd_resist", eurusd_resist);
            prop.setProperty("eurchf_support", eurchf_support);
            prop.setProperty("eurchf_resist", eurchf_resist);
            prop.setProperty("eurgbp_support", eurgbp_support);
            prop.setProperty("eurgbp_resist", eurgbp_resist);
            prop.setProperty("usdchf_support", usdchf_support);
            prop.setProperty("usdchf_resist", usdchf_resist);
            prop.setProperty("gbpusd_support", gbpusd_support);
            prop.setProperty("gbpusd_resist", gbpusd_resist);
            prop.setProperty("gbpchf_support", gbpchf_support);
            prop.setProperty("gbpchf_resist", gbpchf_resist);
            prop.setProperty("eurjpy_support", eurjpy_support);
            prop.setProperty("eurjpy_resist", eurjpy_resist);
            prop.setProperty("usdjpy_support", usdjpy_support);
            prop.setProperty("usdjpy_resist", usdjpy_resist);
            prop.setProperty("gbpjpy_support", gbpjpy_support);
            prop.setProperty("gbpjpy_resist", gbpjpy_resist);
            prop.setProperty("chfjpy_support", chfjpy_support);
            prop.setProperty("chfjpy_resist", chfjpy_resist);


            System.out.println(" eurusd_resist = " + eurusd_resist);
            System.out.println(" eurusd_support = " + eurusd_support);
            
            prop.store(out, null);
        } catch (IOException ex) {
            Logger.getLogger(DCC.class.getName()).log(Level.SEVERE,
                                                                          null,
                                                                          ex);

        } finally {
            try {
                if (out != null)
                    out.close();
            } catch (Exception ex) {
                Logger.getLogger(DCC.class.getName()).log(Level.SEVERE, null,
                                                          ex);
            }
        }
    }

Open in new window

Calling getText
public String getTextresistEURUSD() {
        eurusd_resist = resistance_EURUSD.getText();
                System.out.println("    DCC  resistance_EURUSD = " + eurusd_resist);
        return eurusd_resist;
    }

    public String getTextsupportEURUSD() {
        eurusd_support = support_EURUSD.getText();
        //        System.out.println("    DCC  support = " + support);
        return eurusd_support;
    }

    public String getTextresistEURCHF() {
        eurchf_resist = resistance_EURCHF.getText();
        //        System.out.println("    DCC  resist = " + resist);
        return eurchf_resist;
    }

    public String getTextsupportEURCHF() {
        eurchf_support = support_EURCHF.getText();
        //        System.out.println("    DCC  support = " + support);
        return eurchf_support;
    }

Open in new window

Output
FileOutputStream = java.io.FileOutputStream@700de5f5
 eurusd_resist = 1.42
 eurusd_support = 1.39
Process exited.

Open in new window

I change values but they not getted-recorded
But loading from dcc.properties it's OK
Yesterday everything work perfect. Why it stop reading?
resistance_EURUSD.setPreferredSize(new Dimension(80, 30));
        resistance_EURUSD.setBackground(new Color(181, 255, 181));
        resistance_EURUSD.setHorizontalAlignment(JTextField.CENTER);
//        resistance_EURUSD.setText("1.4280"); // Resistanse level
        resistance_EURUSD.setText(applicationProps.getProperty("eurusd_resist")); // Resistanse level
        resistance_EURUSD.setFont(new Font("Lucida Grande", 0, 12));
        resistance_EURUSD.requestFocusInWindow();
        resistance_EURUSD.setName("resistance_EURUSD");

Open in new window

CEHJCommented:
Make sure you're reading and writing to the file think you are
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

gbcbrAuthor Commented:
What you mean? I have only one dcc.properties and whatever I write into this file directly appear on the screen.
Problem, as I see that this method  
public String getTextresistEURUSD() {
        eurusd_resist = resistance_EURUSD.getText();
                System.out.println("    DCC  resistance_EURUSD = " + eurusd_resist);
        return eurusd_resist;
    }

Open in new window

doesn't get real value from the field, so finally it gets value which was settled from dcc.p this is the reason why we have this output:
out = new FileOutputStream("dcc.properties");

            System.out.println(" FileOutputStream = " + out);

            prop.setProperty("eurusd_support", eurusd_support);
            prop.setProperty("eurusd_resist", eurusd_resist);
.....................
            System.out.println(" eurusd_resist = " + eurusd_resist);
            System.out.println(" eurusd_support = " + eurusd_support);


>>>>>>>>>>>>>>
FileOutputStream = java.io.FileOutputStream@700de5f5
 eurusd_resist = 1.42
 eurusd_support = 1.39

Open in new window

gbcbrAuthor Commented:
I even change dcc.p to dcc2.p and it's create exact copy of dcc
gbcbrAuthor Commented:
I found that something wrong with recording.
If I delete any line from dcc.p and start app this field shows empty, but when I try to close app via Exit it shows:
FileOutputStream = java.io.FileOutputStream@8a85268
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at java.util.Hashtable.put(Hashtable.java:394)
	at java.util.Properties.setProperty(Properties.java:143)
	at control.DCC.windowClosing(DCC.java:2304)
	at control.DCC.fileExit_ActionPerformed(DCC.java:2279)
	at control.DCC$2.actionPerformed(DCC.java:439)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
	at javax.swing.AbstractButton.doClick(AbstractButton.java:389)
	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:809)
	at com.apple.laf.AquaMenuItemUI.doClick(AquaMenuItemUI.java:137)
	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:850)
	at java.awt.Component.processMouseEvent(Component.java:6374)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
	at java.awt.Component.processEvent(Component.java:6139)
	at java.awt.Container.processEvent(Container.java:2085)
	at java.awt.Component.dispatchEventImpl(Component.java:4736)
	at java.awt.Container.dispatchEventImpl(Container.java:2143)
	at java.awt.Component.dispatchEvent(Component.java:4566)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4621)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4282)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212)
	at java.awt.Container.dispatchEventImpl(Container.java:2129)
	at java.awt.Window.dispatchEventImpl(Window.java:2478)
	at java.awt.Component.dispatchEvent(Component.java:4566)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:680)
	at java.awt.EventQueue.access$000(EventQueue.java:86)
	at java.awt.EventQueue$1.run(EventQueue.java:639)
	at java.awt.EventQueue$1.run(EventQueue.java:637)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
	at java.awt.EventQueue$2.run(EventQueue.java:653)
	at java.awt.EventQueue$2.run(EventQueue.java:651)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:650)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Open in new window

and I can't exit normally.
When I cancel in force it delete whole content of dcc.p and next time I can't start.
CEHJCommented:
>>If I delete any line from dcc.p and start app this field shows empty

Don't do that, it will cause the field to be null. If the field isn't found on load, you should initialize the text field to an empty string
gbcbrAuthor Commented:
And this at control.DCC.windowClosing(DCC.java:2304) is prop.setProperty("eurjpy_support", eurjpy_support);
line deleted from dcc.properties, so it doesn't create new record
gbcbrAuthor Commented:
I make like this
resistance_EURUSD.setText("1.4280"); // Resistanse level
//        resistance_EURUSD.setText(applicationProps.getProperty("eurusd_resist")); // Resistanse level

Open in new window

and comment this line it dcc.
It shows settled value and save it into dcc, but if I change value, anyway it save in dcc old value.
Something wrong with reading after typing, it's read well settled in any way value: or from dcc.p or direct setting, but all typing are ignored.
CEHJCommented:
objects will be along later: he suggested doing this the hard way
gbcbrAuthor Commented:
I'll attach now DCC.java
You have old one, please check what it maybe the difference.
But, as I told before, I check in Subversion, but I didn't find anything critical.
gbcbrAuthor Commented:
Mick BarryJava DeveloperCommented:
>             prop.setProperty("eurusd_support", eurusd_support);

should be:

             prop.setProperty("eurusd_support", getTextsupportEURUSD());

same for the others

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gbcbrAuthor Commented:
Yes, thank you, this is's work, but why it perfect works before with old construction and now stops?
Mick BarryJava DeveloperCommented:
no idea sorry, not sure what you changed before
gbcbrAuthor Commented:
@objects
http:#35197346
just for understanding root of problem, what is the possible reason this break?
Mick BarryJava DeveloperCommented:
you were previously updating the variables that you were using
gbcbrAuthor Commented:
@objects
please clarify
Mick BarryJava DeveloperCommented:
previously you must have been updating the value oif the eurusd_support variable to be what was in the text field
gbcbrAuthor Commented:
ok, anyway I think this way much straight and reliable.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.