Solved

JText fields and Strings

Posted on 2011-09-30
7
262 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
  • 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

707 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

16 Experts available now in Live!

Get 1:1 Help Now