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:
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
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
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?
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.
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.
She still doesn't approve of my superhero lifestyle. Or this shameless plug:
a bit of art, as a gift, that will fit in a stocking