• 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

Multiple Arrays Situation

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
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
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic