Results 1 to 5 of 5
  1. #1
    akshaygoel96 is offline Member
    Join Date
    Jan 2013
    Location
    Kent , Washington
    Posts
    7
    Rep Power
    0

    Default Help Help please...........!!

    is it possible to add both int and string value in onee text field
    Last edited by akshaygoel96; 02-20-2013 at 05:24 AM.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,449
    Blog Entries
    7
    Rep Power
    20

    Default Re: Help Help please...........!!

    Quote Originally Posted by akshaygoel96 View Post
    is it possible to add both int and string value in onee text field
    A JTextField handles, well, text, which is a single String, so the answer must be no.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: Help Help please...........!!

    But there is a workaround, Jos didn't mention. You can concatenate the string and the int into a new String and add that to the TextField.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  4. #4
    tamilarasi is offline Member
    Join Date
    Nov 2012
    Location
    India
    Posts
    70
    Rep Power
    0

    Default Re: Help Help please...........!!

    It's not possible Because the text filed accept only text.you put any value in the text fie, the text field consider as a text(String)..
    Regards
    Android developer at Trinay Technology Solutions,http://www.trinaytech.com,5705750475

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Help Help please...........!!

    You deleted your code which is important for those answering the question. I'll re-post it:

    Java Code:
    Switch.addActionListener(new ActionListener() {
    	public void actionPerformed(ActionEvent e ) {
    		String characters = (SecondTextField.getText()); // String to read the user input
    		int length = characters.length(); //change the string characters to length
    
    		//to check the characters of string..
    		for(int i = 0; i < length; i++)  {
    			char character = characters.charAt(i);
    			if(Character.isUpperCase(character)) {
    				SecondTextField.setText("" + characters.toLowerCase());
    			} else if(Character.isLowerCase(character)) {
    				//problem is here, how can i track the character which i already change above, means lowerCase
    				SecondTextField.setText("" + characters.toUpperCase());
    			}
    		}
    	}
    });

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •