Solved

JText fields and Strings

Posted on 2011-09-30
7
272 Views
Last Modified: 2012-05-12
I have a JText field created

final JTextField curProject = new JTextField(20);

I am trying to assign a String value to that field?

curProject = currentProject.getName();

Type mismatch: cannot convert from String to JTextField
0
Comment
Question by:jkteater
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 

Author Comment

by:jkteater
ID: 36892162
should there be a listener?
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
ID: 36892167
Should be
curProject.setText(currentProject.getName());

Open in new window

0
 
LVL 47

Expert Comment

by:for_yan
ID: 36892175
CurProject.setText(crrentProject.getName())
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 47

Expert Comment

by:for_yan
ID: 36892180
Istener does not matter for assigning string to setText method
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36892190
You cannot asign string to curProject bbecauise curProject is a JTextFiled and not a String, but you shoid use a method setText(String) which takes String as an argument
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36892209
And you certainly can varioius listenes assigned to JTextField - like ActionnLustener whochj would listen for carriage return or KeyListener which would fire with any key typed, but this has no connecion to your type mmismatch situatin
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 36892481
:)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
V.simple question about Android packages and libraries 1 36
jmss example java 2 31
Is there a simpler dropbox system? 10 44
passing enum to a method 4 34
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn different types of Android Layout and some basics of an Android App.
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:
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…

735 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