A way to put one monitor to sleep on a dual monitor system

Deathbot35

Honorable
Aug 24, 2012
1
0
10,510
I've been looking for a way to put my Primary Monitor <21" Acer LCD Monitor> to sleep while watching movies or what have you on my secondary monitor <27" Samsung LED Smart TV>. I have scoured around and can find nothing that will allow me to put my main to sleep without actually hitting the power button.

Any help would be greatly appreciated.
 

supaflav

Honorable
Dec 18, 2012
1
0
10,510
This post is a bit old but I ran into a similar issue. I can turn on my PC/media player/lights remotely but my 27" computer display throws a distracting glow across the room. In order to maximize my laziness I created a simple Java app to blacken the display
(which I can launch remotely using other tools).

Below is the java code that I have tested on Windows 7.
It takes a single argument 0 to max display-1.
For example: java -jar Dimmer.jar 1 will blacken my second monitor, no arguments will assume display 0

[cpp]
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JWindow;
import javax.swing.UIManager;

public class Dimmer extends JWindow
{
private static final long serialVersionUID = 3493635987367217622L;

private final int _screen;

public Dimmer ()
{
this(0);
}

public Dimmer (int screen)
{
super();
_screen = screen;

{
final JButton button = new JButton("click to exit");
button.setForeground(Color.gray);
button.setOpaque(false);
button.setContentAreaFilled(false);
button.setBorder(BorderFactory.createEmptyBorder());
button.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent arg0)
{
System.exit(0);
}
});
add(button, BorderLayout.CENTER);
}
setAlwaysOnTop(true);
}

public void begin()
{
GraphicsDevice gda[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
GraphicsDevice gd = gda[_screen];
getContentPane().setBackground(Color.black);

for (GraphicsDevice gdTmp : gda)
{
System.out.print( (gd == gdTmp) ? "->" : " ");
System.out.println(
"Screen(" + gdTmp.getDefaultConfiguration().getDevice().getIDstring() +")"
+" "+ gdTmp.getDefaultConfiguration().getBounds() );
}

Rectangle bounds = gd.getDefaultConfiguration().getBounds();
setLocation(bounds.getLocation());
setSize(bounds.getSize());

validate();
setVisible(true);
}

/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
Dimmer dimmer = new Dimmer(args.length == 1 ? Integer.valueOf(args[0]) : 0);
dimmer.begin();
}

}
[/cpp]