refreshing a Textfield

Posted on 2011-10-05
Last Modified: 2012-06-21
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);
	  EdiProject newProject = ar.getSelectedProject();
	  if (newProject != null) {
		  currentProject = newProject;
		  curProject = new JTextField(20);
	  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?
Question by:jkteater
    LVL 47

    Accepted Solution

    You don't need any refresh. The moment you cal setText JTextFiled shoud show thge contents
    LVL 47

    Expert Comment

    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
    LVL 86

    Expert Comment

    Make lines 3 and 4of your code  the last lines of the method
    LVL 86

    Expert Comment

    Oops sorry - was misreading. My previous comment just applies to line 3
    LVL 86

    Expert Comment

    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?

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
    Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now