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

Multiple Arrays Situation  RSS feed

 
Davide Delvecchio
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to code a little program in which you can select a day of the year via three combobox (days, months, years). Then, we can select a journey (from 1 to 10) again in a combobox. Once we have done that, we can insert values in three JTextFields and put them in three arrays with a "Confirm" JButton. I attached a picture of the current state of the program.

The goal of the program is to "remember" each inserted value by the user, according to the journey selected AND the day selected. Right now, I achieved to make the program "remember" the values accordingly to the journey, but not the date. Of course, the goal is also to be able to see old inserted values and modify them. Goal achieved right now accordingly to the journey selected, but not the date, again.

How could I do? I am not requesting huge lines of codes, just ideas.

If needed, there is part of the code. I copied only the necessary:






Capture.JPG
[Thumbnail for Capture.JPG]
The program
 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The posted code does not not compile without errors. You need to fix the errors in the code so it can be compiled and executed for testing.

Also there are too few comments in the code describing what it is trying to do and how it is going to do it.
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Davide Delvecchio wrote:How could I do? I am not requesting huge lines of codes, just ideas.

My first one: forget about the GUI. This is an information/storage problem, NOT a display one; and you're likely to distract yourself (a LOT) by worrying about buttons and JTextFields.

Once you have a solution that makes sense, then plug it into your GUI.

My second: Create a Journey class, and think about what IT needs to contain. For example: could each of those of those date-based entries be regarded as a "Leg" of the journey?

What, not how - it's a tough lesson to learn when you're starting out, but it'll reap you rich rewards.

Winston
 
Campbell Ritchie
Marshal
Posts: 55741
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I would suggest that you need a Journey class. That should be designed and coded separately from the GUI. Put the GUI aside and create a Journey application completely separately. The text fields do not form part of the Journey app; they simply allow you to enter and read information. I see Winston has beaten me to it with that advice.
Why have you got those arrays for dates?
 
Davide Delvecchio
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:

What, not how - it's a tough lesson to learn when you're starting out, but it'll reap you rich rewards.

Winston


Thanks for the quick answer and the helpful tip (and link to the article), I will try to think on that!

 
Davide Delvecchio
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Welcome to the Ranch [...] Why have you got those arrays for dates?


Thank you!
The String arrays for dates defines the text for the dates' JComboBox (see picture in the original post). As you and Winston said, the GUI is causing me some problems, but I will admit, I simply cannot find a solution to put in the system the user input for a specific day and journey.

 
Campbell Ritchie
Marshal
Posts: 55741
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The String arrays are not dates; they are writing. You should not be thinking about comboboxes at this stage, but how to record dates. If you need a class for dates; you can read about them in the Java™ Tutorials. The parsing and formatting section may help you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!