Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Need help making a section of code in one class into a class of it's own

 
Ranch Hand
Posts: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been playing with a JCalendar JDateChooser and I wrote code that validates the submitted dates and times.
There are three date and time choosers and three repeated validations. I want to make a ValidDate class that I can
just call in the main program but I am having trouble. I thought I could just take the code from just below the submit button
put it in a method but I can't figure out how to get the chosen date into the ValidDate class.

I can get the date within the main program with:


but when I try to put that in a seperate ValidDate class it doesn't of course know what  schedDate_1 is.
I don't know what the variable in the JDateChooser is, be it a Date, a String, etc. I don't know how to find out.

Essentially, I am confused as to how I reference a third party (JDateChooser) class inside my OmniTrackScheduler class from a ValidDate class.

Here is the whole code:

 
Rancher
Posts: 259
13
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you pass the schedDate_1 object into your class via a constructor? that way it will know about it.
 
Ray Gilbert
Ranch Hand
Posts: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

S Fox wrote:can you pass the schedDate_1 object into your class via a constructor? that way it will know about it.



Not really sure how to go about it yet. I will review constructors in my book.
 
S Fox
Rancher
Posts: 259
13
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
basically you would do this...


 
Ray Gilbert
Ranch Hand
Posts: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

S Fox wrote:basically you would do this...


I think I just need to start back over at the beginning of my books again.

I don't know where to put this that makes it work I tried it in the OmniTrackScheduler
class and it creates many errors. I tried it in the ValidDate class with the same result.
Maybe part of it goes in one and part of it goes in another but essentially, I think I am
just trying to work too far outside my capabilities. I will start back with printing Hello World. lol
}

 
Ray Gilbert
Ranch Hand
Posts: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With a little more reading and experimenting, I came up with this:



in a SchedulerTest class and this:

in the ValidDate class

 
Friends help you move. Good friends help you move bodies. This tiny ad will help:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic