• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

refreshing a Textfield

We have a textfield we were talking about in a earlier question.
when the dialog first opens that field has not value assigned to it.  Let me show what the dialog looks like.

Project:  [ jtext   ]  [ change button ]

When the dialog is first opened jtext has not value.  But when the user clicks the change button that open another dialog.  It is when the dialog is opening we get the value for jtext.

 
private void showProjectSelectDialog() {
      EdiSelectProjectDialog ar = new EdiSelectProjectDialog(this, session, appReg);
	  ar.setModal(true);
	  ar.setVisible(true);
	  EdiProject newProject = ar.getSelectedProject();
	  if (newProject != null) {
		  currentProject = newProject;
		  curProject = new JTextField(20);
		  curProject.setText(currentProject.getName());
		  curProject.setEnabled(false);
		  
	  }
	  else {
		  System.out.println("No Project\n");
	  }
   }

Open in new window


The user from the new dialog can select a different project.  The dialog goes away, but I am not sure how to update the jtextfield to show the new value.  Is there a refresh? or some kind of listener?
0
jkteater
Asked:
jkteater
  • 3
  • 2
1 Solution
 
for_yanCommented:
You don't need any refresh. The moment you cal setText JTextFiled shoud show thge contents
0
 
for_yanCommented:
Make sure you pass to the neew JDialog handle to your original class correctly, so thaat you can acces the JTextField
You can make a method in the original class for setText on this JText field and call it from your dialog as soon as user made a selection
0
 
CEHJCommented:
Make lines 3 and 4of your code  the last lines of the method
0
 
CEHJCommented:
Oops sorry - was misreading. My previous comment just applies to line 3
0
 
CEHJCommented:
jkteater, the accepted answer implies that you don't need to change any of your code to get it to do what you want - is that the case?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now