Skip to content

Commit

Permalink
add font size config for high resolution screens
Browse files Browse the repository at this point in the history
  • Loading branch information
moovida committed Oct 29, 2024
1 parent 2c8cb15 commit 7e5b659
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions gui/src/main/java/org/hortonmachine/gui/utils/GuiUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.awt.ComponentOrientation;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Image;
Expand All @@ -42,13 +43,13 @@
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.function.Consumer;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
Expand All @@ -68,7 +69,6 @@
import javax.swing.WindowConstants;
import javax.swing.filechooser.FileFilter;
import javax.swing.table.DefaultTableModel;
import javax.swing.text.DefaultEditorKit;

import org.apache.commons.io.FilenameUtils;
import org.hortonmachine.dbs.log.Logger;
Expand Down Expand Up @@ -259,6 +259,13 @@ public static String showComboDialog( Component parentComponent, String title, S
}

public static void setDefaultLookAndFeel() {
// change fonts only if -Dhm.fontsize=18 is passed
String fontSize = System.getProperty("hm.fontsize");
if (fontSize != null) {
int fs = Integer.parseInt(fontSize);
setUIFont(new javax.swing.plaf.FontUIResource("Dialog", Font.PLAIN, fs));
}

OSType osType = OsCheck.getOperatingSystemType();
// if(osType == OSType.MacOS) {
// // set keybindings
Expand Down Expand Up @@ -307,11 +314,24 @@ public static void setDefaultLookAndFeel() {
// }
break;
}



} catch (Exception ex) {
ex.printStackTrace();
}
}

public static void setUIFont(javax.swing.plaf.FontUIResource f) {
Enumeration<Object> keys = UIManager.getDefaults().keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
Object value = UIManager.get(key);
if (value instanceof javax.swing.plaf.FontUIResource) {
UIManager.put(key, f);
}
}
}

/**
* Set the default frame icon, also considering the macos case.
Expand Down

0 comments on commit 7e5b659

Please sign in to comment.