• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Swing Calender, ComboBox and timer questions

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
im trying to code a program at the minute which when you set specific times to switch something on in this case a boiler (theretically)

So i need to have a switch on time and switch off time therefore i have used JComboBoxes then used a string array to hold the value for hours and minutes and then converted them into an interger for to use for if statements.

Now im quite stumped on what to do next i know i have to compare the times together with a realtime clock therefore i guess using the swing calender function???

So far i have come up with this code but even the simple if statement fails me it always reads ON even trying different cominations of >= <= == etc.... im a bit stuck how to compare the times. I would also like it to keep checking to see whether the boiler should still be active therefore i guess putting the whole thing into an infinate for loop?

Any tips or ideas would be greatful i have embedded my code for you to all look at also i am not the best programmer i will admit that and i have limited knowledge but any help would be helpful.

 
Ranch Hand
Posts: 38
MySQL Database PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use GregorianCalendar() to get the current time and compare with the selected time...

Here is the sample code. to get time..


Since,String arrays contains the integer values you can use the below code to initialize the combo box..



hope this helps u...
 
sean beacham
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Abhilash Etikala wrote:Use GregorianCalendar() to get the current time and compare with the selected time...

Here is the sample code. to get time..


Since,String arrays contains the integer values you can use the below code to initialize the combo box..



hope this helps u...



i dont know what this code does!

i know the first 3 lines get the current hour and minute thats fine.

ive started to write some code so far so good.... a few more tips and i think i should get thre by tomorrow

 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use parentheses for logical grouping of conditional expressions.
 
reply
    Bookmark Topic Watch Topic
  • New Topic