ZeroOne3010 / yetanotherhueapi

A Java library for controlling Philips Hue lights. Available from the Maven Central.
MIT License
68 stars 21 forks source link

Changing color of a light or room #7

Closed DanielBlik closed 5 years ago

DanielBlik commented 5 years ago

is there a way to change the color since i have been struggling with this for several hours still a beginner programmer so sorry if this is a stupid quetstion image

ZeroOne3010 commented 5 years ago

Please notice how your IDE is underlining some items in red. It is trying to help you. This means that you have a syntax error there. Consider the three lines of code you have, i.e. excluding the method definition and the curly brackets. On the first line you have a typo in the word builder ("buidler") and you haven't capitalized the the class name Color. On the second line it highlights the builder() method which leads me to think you have imported the wrong State. Finally, on the third line the method color(...) is highlighted because a Light does not have such a method. The correct way to do it would be this: room.setState(State.builder().color(java.awt.Color.PINK).on()); assuming the correct State has been imported from the same package as Hue.

DanielBlik commented 5 years ago

ah sorry for the small mistakes like "buidler " stupid of me. But what do you mean by importing the right state have been googling that but cant seem to find anything related to "importing a state"

ZeroOne3010 commented 5 years ago

I mean that you should import the State class from this library and not some other State, so you should have this line: import io.github.zeroone3010.yahueapi.State;. Or, if you already have imported io.github.zeroone3010.yahueapi.*, then that should be enough. Just make sure you haven't imported any other class by the name of State, that's what I mean. So if you have anything like "import javax.swing.plaf.nimbus.State;" or "import sun.java2d.StateTrackable.State;", you should get rid of those.

DanielBlik commented 5 years ago

GOT IT !!!!

thanks a lot turns out while making a type error it gave an error and suggesting a state import which interfered thank you so much your awesome :)