Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JTextfield setText not updating, possible thread issue

843804Mar 2 2005 — edited Mar 3 2005
I have a button on a JPanel (Calculate), that calculates some values based on user input and enters the results into a JTable (Both the button and the JTable are on the same JPanel). Additionally, it computes a second set of values, now these values are to be placed in JTextFields contained within another JPanel. The values are computed fine, and I can print them out to the command line, thou it doesn't want to update my JTextFields.

The code for the calculate button is as follows:
		button_calcSheetTotalsCalculate.addActionListener(

                new ActionListener() {

	                public void actionPerformed (ActionEvent actionEvent) {

		                Thread t = new Thread() {

			                Object[] totalsData = null;
			                CalcSheetSummaryGUI_IF calcSheetSummary = new CalcSheetSummaryGUI();

		                    public void run() {

                        	    if (SwingUtilities.isEventDispatchThread()) {
                                            // update the data in the TableModel and on the other panel
		                            tableModel_calcSheetTotals.updateRowTotalsData(totalsData);
                                            // the data is updated with a simple panel_name.updateUI(); method
		                            calcSheetSummary.updateSummaryPanel();

	                            } else {
                                    //compute the new data values
		                            CalcSheetCalculations_IF calcSheetCalculations = new CalcSheetCalculations();
	                                totalsData = calcSheetCalculations.performCalculations();
		                            calcSheetSummary.performSummaryCalculation();

		                            SwingUtilities.invokeLater(this);
	                            }
		                    }
		                };
							t.start();
	                }
       });
Thanks guys/gals.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 31 2005
Added on Mar 2 2005
5 comments
643 views