Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java help GUi's  RSS feed

 
ovais hussain
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I wanted to know how would I display the namefield, address field, currentbalancefield and the credit limit field,
because when pressing the JButton nothing seems to come up.

How am I supposed to know if something happen when pressing the button ?

Thanks

 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well your action listener is just initializing the Account class. After that it's done, there is nothing else.

You may add in dialog popup saying the account is created or something

 
Fred Kleinschmidt
Bartender
Posts: 560
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your button action listener creates a new instance of Account, discarding any previous instance that may have existed. Then it does nothing with it. What is it that you expect or want to happen?
 
ovais hussain
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fred Kleinschmidt wrote:Your button action listener creates a new instance of Account, discarding any previous instance that may have existed. Then it does nothing with it. What is it that you expect or want to happen?


Basically i'm doing an assignment which wants the following:

Please recall Exercise 1 from Exercise Sheet 6 issued in week 9.
Write a graphical user interface (GUI) form using JFrame as demonstrated in the lecture. In your
form the user should be able to enter a name, address, the current balance and the credit limit data.
When the user presses a “Submit” button, your program should read the data in the text fields and create an Account
object using an appropriate constructor.
Hint: You will need a JFrame, 4 JTextFieldsand 1 JButton component for this purpose.

I done most of it except how would I display the namefield, addressfield, currentbalancefield, creditlimitfield when pressing the JButton?
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First please amend line 54 in your original post by breaking this line into multiple lines for easier reading.

As for your question, you already got the text field's content currentbalancefield.getText() so you can add labels to a JDialog and display that or get those attributes from the newly instantiated Account and add them to a JDialog.


 
ovais hussain
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:First please amend line 54 in your original post by breaking this line into multiple lines for easier reading.

As for your question, you already got the text field's content currentbalancefield.getText() so you can add labels to a JDialog and display that or get those attributes from the newly instantiated Account and add them to a JDialog.





So using your following code I came up with the following:



It worked as expected, I appreciate the help

thanks

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!