Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all,
Vanilla are planning an update to the site on April 24th (next Wednesday). It is a major PHP8 update which is expected to boost performance across the site. The site will be down from 7pm and it is expected to take about an hour to complete. We appreciate your patience during the update.
Thanks all.

Netbeans and java

Options
  • 24-09-2014 9:02pm
    #1
    Closed Accounts Posts: 431 ✭✭


    Can anyone help me out I'm looking to build a simple application that has a jtextfield so the user enters a number and the value is saved as a variable. How would I archive this?


Comments

  • Registered Users Posts: 291 ✭✭Seridisand


    Can anyone help me out I'm looking to build a simple application that has a jtextfield so the user enters a number and the value is saved as a variable. How would I archive this?

    Can you clarify "archive"?

    Do you mean you want store the value so that it can be retrieved? You would need to either use a back end storage like a database or write the variable value to a file and then read the file from the application.


  • Closed Accounts Posts: 431 ✭✭whats newxt


    Seridisand wrote: »
    Can you clarify "archive"?

    Do you mean you want store the value so that it can be retrieved? You would need to either use a back end storage like a database or write the variable value to a file and then read the file from the application.

    Sorry I'm on the phone I mean achieve. Basically I want to take whatevers in the jtextfield and save it as a variable and then print it out on screen.


  • Registered Users Posts: 291 ✭✭Seridisand


    If you want to accept it as a string you could do it like this
    String yourString = yourJTextField.getText();
    
    Or like this as an integer value
    int myInt = Integer.parseInt(yourJTextField.getText());
    

    You'll need to create some sort of Action Event - button event ideally to trigger the variable value being set to the value of the JTextField.

    http://docs.oracle.com/javase/tutorial/uiswing/events/intro.html


  • Closed Accounts Posts: 431 ✭✭whats newxt


    Seridisand wrote: »
    If you want to accept it as a string you could do it like this
    String yourString = yourJTextField.getText();
    
    Or like this as an integer value
    int myInt = Integer.parseInt(yourJTextField.getText());
    

    You'll need to create some sort of Action Event - button event ideally to trigger the variable value being set to the value of the JTextField.

    http://docs.oracle.com/javase/tutorial/uiswing/events/intro.html

    Thanks very much that works perfect i have another question whats the best event to use on the main window to trigger the event code? i want everything to update without pressing a button


  • Registered Users Posts: 291 ✭✭Seridisand


    Have a look at the link in my last post, you could add a component/frame/focus event listener to update the main frame, but I'd recommend using a component like a button event to trigger the update


  • Advertisement
Advertisement