I wrote a program in eclipse using JFrame to display a GUI that will be run on a separate PC. In order to fit the screen I used Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
and setSize((int)screenSize.getWidth(), (int)screenSize.getHeight());
, but for some reason it is too big when I run the JAR file on the other PC. What would be the best way to make it fit whatever screen the JAR file is being run on?
Edit: I have added a sample code of my issue, and have commented out the 4 "options" that I have tried without success.
package testDisplay;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JLabel
import javax.swing.JPanel;
public class Main {
public static void main(String []args) {
Display display = new Display();
}
}
@SuppressWarnings("serial")
public class Display extends JFrame {
/**
* Constructor for Display
*/
public Display() {
// Create Window
setTitle("Production Perfomance");
setUndecorated(true);
setVisible(true);
setLocation(new Point(0,0));
setLayout(null);
getContentPane().setBackground(Color.BLACK);
// Option 1:
//GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
//setSize((int)gd.getDisplayMode().getWidth(), (int)gd.getDisplayMode().getHeight());
// Option 2:
//Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
//setSize((int)screenSize.getWidth(), (int)screenSize.getHeight());
// Option 3:
//setSize(MAXIMIZED_HORIZ, MAXIMIZED_VERT);
// Option 4:
//setExtendedState(MAXIMIZED_BOTH);
// Add Panel with Label
JLabel title = new JLabel("<- - - - - - - - - - - - - - - ->");
title.setFont(new Font("Arial Black", Font.BOLD, 140));
title.setForeground(new Color(53, 203, 253));
JPanel bTitle = new JPanel();
bTitle.setBackground(new Color(39, 67, 157));
title.setBounds(0, 90, getWidth(), 150);
bTitle.setBounds(0, 400, getWidth(), 300);
add(bTitle);
bTitle.add(title);
}
}