Results 1 to 3 of 3
  1. #1
    Fireking is offline Member
    Join Date
    Jul 2008
    Rep Power

    Default [SOLVED] Textfield

    Hi, just a quick question on something that is buggin me (and i have searched google and the forums but cant find anything).
    I am creating a calculator in netbeans, i have used the GUI part to create the design and i am currently writing the code for the buttons. My issue is that i cant remember nor find the code to add characters to a textfield without deleting what is already in there.
    If someone can give me the code or direct me to a place where i could find it i would be most appreciative :)


  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power


    One way would be to get what's there now, concat the new values to it and put it back. Read the API doc for the correct methods.

  3. #3
    Fireking is offline Member
    Join Date
    Jul 2008
    Rep Power


    thx after a good 10 mins that seems to work :)
    Didn't know you could do that :)

    the code i have for each button is as follows
    Java Code:
    private void btnOneActionPerformed(java.awt.event.ActionEvent evt) {                                       
    // if/else statement to allow me to join the numbers without adding them 'concatenate'
    if (screenNo == 0)
        screenNo = 1;
    } else
        concatNo = txtScreen.getText().concat("1");
        screenNo = Float.parseFloat(concatNo);

Similar Threads

  1. set focus to the textfield
    By paty in forum New To Java
    Replies: 2
    Last Post: 07-09-2010, 08:28 AM
  2. textfield and database
    By t3mh4 in forum JDBC
    Replies: 2
    Last Post: 05-14-2008, 08:12 AM
  3. JSP - getting value from a textfield
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-01-2007, 08:58 PM

Posting Permissions

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