wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Swing Calender, ComboBox and timer questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing Calender, ComboBox and timer questions" Watch "Swing Calender, ComboBox and timer questions" New topic
Author

Swing Calender, ComboBox and timer questions

sean beacham
Greenhorn

Joined: Apr 12, 2011
Posts: 20
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.

Abhilash Etikala
Ranch Hand

Joined: Nov 08, 2009
Posts: 38

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

Joined: Apr 12, 2011
Posts: 20
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

Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Use parentheses for logical grouping of conditional expressions.


luck, db
There are no new questions, but there may be new answers.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Swing Calender, ComboBox and timer questions
 
Similar Threads
Passing values back from inner classes
Jcombobox
getting the time in milliseconds
help on dynamic select box
If statement problem