You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to connect a TV to the Laptop. I want to display one JFrame on Laptop and another on my TV. But my code only recognises the Laptop monitor. It does not seem to recognise the TV as a second monitor.
I am experiment with this code:
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
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am trying to connect a TV to the Laptop. I want to display one JFrame on Laptop and another on my TV. But my code only recognises the Laptop monitor. It does not seem to recognise the TV as a second monitor.
I am experiment with this code:
Beta Was this translation helpful? Give feedback.
All reactions