简体   繁体   中英

Writing a string to a jTextField problems

I am pretty new to Java but have some basic programming experience with C, C++ I have just started creating GUIs and decided to create a Blackjack game.

I have created an array of Strings for the cards being dealt, however when I try to write the string (eg Ace, King, Eight, etc) using the setText method it doesn't work. It seems setText will only write text inside " " to the jTextField. I cannot for the life of me find an appropriate method to write my array of strings to the jTextFields.

Can anyone advise me of an appropriate method to use? Thanks in advance!

Here's how to assign your array String in jtextfield

sample:

String[] names = {"name1","name2","name3","nam4"};

yourTextField.SetText(names[0]); // result "name1"

yourTextField.SetText(names[0] + " , " + names[1]); // result "name1 , name2"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM