How to create a flexible object?

How can I create an object by getting the required parameters from JTextFields?

  • I have 3 JTextFields. Description, deposit and rate. I want the values entered into these fields to be used to create an object from another class which requires these 3 fields (Descrpiton, deposit and rate) and add this field to my current array list. I do not know the correct syntax to make this happen. Appreciate any help. Thanks

  • Answer:

    You need to convert the things from JTextField to appropriate type and call appropriate constructor of that class I assume Description is sttring deposit integer rate integer Assuming T1, T2, T3 are JTextFields new yourclass(T1.getText(), Integer.parseInt(T2.getText()), Integer.parseInt(T3.getText()) )

Maho at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.