Merge pull request #490 from Bl3nd/master

UI Font Size
This commit is contained in:
Konloch 2024-04-08 18:51:31 -07:00 committed by GitHub
commit c2f516ad52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

AI 샘플 코드 생성 중입니다

Loading...
2 changed files with 51 additions and 22 deletions

View File

@ -2,14 +2,14 @@ package the.bytecode.club.bytecodeviewer;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import java.awt.*;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import javax.swing.*;
import javax.swing.SwingUtilities;
import me.konloch.kontainer.io.DiskReader; import me.konloch.kontainer.io.DiskReader;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
@ -22,6 +22,8 @@ import the.bytecode.club.bytecodeviewer.bootloader.UpdateCheck;
import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI; import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI;
import the.bytecode.club.bytecodeviewer.gui.components.ExtendedJOptionPane; import the.bytecode.club.bytecodeviewer.gui.components.ExtendedJOptionPane;
import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog; import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog;
import the.bytecode.club.bytecodeviewer.gui.components.SearchableJTextArea;
import the.bytecode.club.bytecodeviewer.gui.components.SearchableRSyntaxTextArea;
import the.bytecode.club.bytecodeviewer.gui.resourcelist.ResourceListIconRenderer; import the.bytecode.club.bytecodeviewer.gui.resourcelist.ResourceListIconRenderer;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.TabbedPane; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.TabbedPane;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ClassViewer; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ClassViewer;
@ -751,4 +753,31 @@ public class BytecodeViewer
* because Smali and Baksmali System.exit if it failed * because Smali and Baksmali System.exit if it failed
*/ */
public static void exit(int i) { } public static void exit(int i) { }
/**
* Updates all UI components fonts.
*
* @implNote {@link SearchableRSyntaxTextArea} and {@link SearchableJTextArea}
* do not update until "Refresh" button is clicked.
*
* @param font The font to change everything to.
*/
public static void updateAllFonts(Font font) {
Enumeration<Object> enumeration = UIManager.getDefaults().keys();
while (enumeration.hasMoreElements()) {
Object key = enumeration.nextElement();
Object value = UIManager.get (key);
if (value instanceof Font)
UIManager.put (key, font);
}
}
/**
* Updates all swing components.
*/
public static void updateUI() {
for (Window w : Window.getWindows()) {
SwingUtilities.updateComponentTreeUI(w);
}
}
} }

View File

@ -1,27 +1,15 @@
package the.bytecode.club.bytecodeviewer.gui; package the.bytecode.club.bytecodeviewer.gui;
import java.awt.Component; import java.awt.*;
import java.awt.Dimension;
import java.awt.KeyboardFocusManager;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.swing.BoxLayout; import javax.swing.*;
import javax.swing.ButtonGroup; import javax.swing.event.ChangeEvent;
import javax.swing.JCheckBoxMenuItem; import javax.swing.event.ChangeListener;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JSeparator;
import javax.swing.JSpinner;
import javax.swing.JSplitPane;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingUtilities;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.Constants;
@ -466,6 +454,18 @@ public class MainViewerGUI extends JFrame
fontSpinner.setPreferredSize(new Dimension(60, 24)); fontSpinner.setPreferredSize(new Dimension(60, 24));
fontSpinner.setMinimumSize(new Dimension(60, 24)); fontSpinner.setMinimumSize(new Dimension(60, 24));
fontSpinner.setModel(new SpinnerNumberModel(12, 1, null, 1)); fontSpinner.setModel(new SpinnerNumberModel(12, 1, null, 1));
fontSpinner.addChangeListener(e -> {
JSpinner spinner = (JSpinner) e.getSource();
Font font = UIManager.getFont("defaultFont");
if (font == null) {
font = UIManager.getFont("Label.font");
}
font = font.deriveFont((float) (int) spinner.getValue());
BytecodeViewer.updateAllFonts(font);
BytecodeViewer.updateUI();
});
fontSize.add(fontSpinner); fontSize.add(fontSpinner);
apkConversionSecondaryMenu.add(decodeAPKResources); apkConversionSecondaryMenu.add(decodeAPKResources);