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

JText Fields - populated

I have four JText fields in my dialog.  I am not sure that the right thing is to have them has JText fields.  When the dialog is being created, those fields will get values from a different place.  The fields should not be editable

Right now I have final

final JTextField curProject = new JTextField(20);
final JTextField cur3dTrans = new JTextField(20);
final JTextField cur2dTrans = new JTextField(20);
final JTextField curEmails = new JTextField(20);

example would be something like this (not exactly right, but the value will come from a differernt place)

ediProject.getProjectName() = curProject

So I need to have a field with a value and non editable by the user
What is the best way to do this?

  • 2
1 Solution
You dont need to have them final

JTextField cur2dTrans = new JTextField("your original text");

better make them instance variables:

public calss YurMainClass {
 JTextField curProject;

public YourMainClass(){
cur2dTrans = new JTextField("your original tracl");


public void actionPerformed (ActionEvent ae){
//create your dialog
//get Project say from this dialog

curProject = getProject();



Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

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