Hi
I have a Laptop- MacBook Air.. And I have a TV connected to it via USB C ->
HDMI . I have tried everything in the code snippets I could find in google.
public static void disponscreen() {
System.out.println("Hello from the Disp on screen Function!");
Integer j=0;
GraphicsEnvironment ge = GraphicsEnvironment.
getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
System.out.println("No of monitord"+ge.getDefaultScreenDevice());
System.out.println("No of monitord"+gs.length);
GraphicsDevice gd = gs[0];
GraphicsConfiguration[] gc = gd.getConfigurations();
JFrame f = new JFrame("simple gui");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel textLabel = new JLabel("I'm a label in the window");
textLabel.setPreferredSize(new Dimension(300, 100));
f.getContentPane().add(textLabel, BorderLayout.CENTER);
//Display the window. frame.setLocationRelativeTo(null);
frame.pack(); frame.setVisible(true); } public static void
main(String[] args) { createWindow(); } }
f.setVisible(true);
}
public static void main(String[] args) {
System.out.println("Hello from the Java Main Function!");
disponscreen();
}
gs.length is 1 regardless of connecting or not connecting a TV
gs.length is 1 regardless of connecting or not connecting a TV
I expect to have gs.length = 2. Ie two devices connected.
Anyone can help??
Regards
Murali