• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java help GUi's

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Bartender
Posts: 732
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Every snowflake is perfect and unique. And every snowflake contains a very tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic