Fix scaling for linux devices

This commit is contained in:
Manuel Thalmann 2022-11-15 16:30:05 +01:00
parent ff0c3f0b98
commit 25068543ad

View file

@ -29,6 +29,7 @@ import java.util.Set;
* @version 2.04 2021/9/11 Test as plugin
*/
public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
private final Dimension UHDTHRESHOLD = new Dimension(2000, 1500);
private final String STANDARDENCODING = "UTF-8";
private JMenuItem connect, exit, open, test, retest, textView, graphicView, clear;
@ -154,8 +155,18 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
ex.printStackTrace();
}
setFontSize(11);
setSize(new Dimension(400, 400));
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
double scale = (
screenSize.getWidth() > UHDTHRESHOLD.getWidth() &&
screenSize.getHeight() > UHDTHRESHOLD.getHeight()) ? 2 : 1;
scale = Math.max(scale, Toolkit.getDefaultToolkit().getScreenResolution() / 96.0);
setFontSize((int) (11 * scale));
setSize(
new Dimension((int)(400 * scale), (int)(400 * scale)));
setTitle("ExBox");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
initComponents();