Is there anyway, through java, to tell whether a tv connected to your computer is turned on or off?
Or if its not build into java is there any way to even do this in windows? Because nothing change in windows or my raedeon driver when i turn my tv on/off..

Recommended Answers

All 3 Replies

You can use the GraphicsEnvironment class to get a list of all the GraphicsDevice objects that Java knows about, so your HDMI TV may appear in that, and may possibly appear/disappear when turned on/off? (I've never tried this)

Thanks for the input!
That works when i completly turn off the monitor(Tv), but still can't get it to react when i put it on standby. Which i guess makes sense, since the driver doesn't realise the screen is on standby and therefore java can't know.
I tried checking the refresh rate on the screen but it kept steady at 60 even though the screen was on standby. So it doesn't seem to be reacting to it..

Just to clarify what i tried ill include the code i used:

while(true) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice[] gs = ge.getScreenDevices();
            GraphicsDevice gd = gs[1];

            DisplayMode[] dmodes = gd.getDisplayModes();
              int bitDepth = dmodes[0].getBitDepth();
              int refreshRate = dmodes[0].getRefreshRate();

            System.out.println("Device " + 1 + ": " + gd
                        + "\n Number of colours: " + bitDepth
                        + "\n Refresh rate: " + refreshRate
                        + "\n Type: " + gd.getType() + "\n");

And nothing changes when i put the monitor associated with gs[1] on standby..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.