• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextfield  RSS feed

 
Louis Hadji
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone! Hope all is well!

I have a problem with a program I am trying to create.
Basically I am implementing a program for a car company and I am trying to create a loop with adding vehicles.

I have four attributes so far...these are the carMake, carModel, regNo and the carColor.

For the user to enter these details in the system I am making a JTextField come up in a JFrame. I have created an add button so basically once the user enters the first value for the 1st attribute: 'carMake' the next JTextField appears, this will request for a value for the 2nd attribute ('carModel') to be entered.

So my question is how exactly do I do this?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

Are you sure that's what you want to do? People really don't like interfaces like that. A dialog box that shows all the inputs at once is easier to do, more standard, and better from a human-interface perspective.

Moving to our Swing/AWT forum. Find it over there for continued discussion.
 
Louis Hadji
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx!

Ok I will do showing one dialog box with a load of Textfields.
But none the less curious to know how I can loop the JTextfield if I was to go about it this way.
 
Nageswar Kakolla
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

If you want to take input from user upon clicking the button "add", put code which will display Dialog with JTextField or JFrame with JTextField in
method void actionPerformed(ActionEvent evt){ } and dont forget to add listener to add button. When user enter first JTextField and clicks on "add" Button, code in actionPerformed() method will be executed which contains code to display JTextField for 2nd input variable and so on so forth.

Hope this clarifies ?

let me know if you need further info, i might give code snippet as well
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!