Solved

JText Fields - populated

Posted on 2011-09-23
2
204 Views
Last Modified: 2012-05-12
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?

0
Comment
Question by:jkteater
  • 2
2 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 36589536
You dont need to have them final

JTextField cur2dTrans = new JTextField("your original text");
cur2dTrans.setEditable(false);


0
 
LVL 47

Accepted Solution

by:
for_yan earned 50 total points
ID: 36589579
better make them instance variables:

public calss YurMainClass {
 JTextField curProject;

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





}


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

curProject = getProject();

cur2dTrans.setEditable(false);




}


}
 
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This video teaches viewers about errors in exception handling.

808 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