英文:
Android Studio and Swing based apps text/ui is broken
问题
以下是您提供的内容的翻译:
这是我第一次下载 Android Studio,这是我在主菜单中获得的内容:
基于 Swing 的应用程序的文本也存在相同的问题:
Swing 应用程序的代码:
public class Base {
private static JFrame JF;
private static Map<String,JButton> Buttons = new HashMap<String,JButton>();
public static void init(int x, int y) {
JF = new JFrame();
JF.setSize(x, y);
JF.setLayout(null);
JF.setVisible(true);
}
public static void CreateButton(String Bname,String BText,int posx, int posy, int sizex, int sizey) {
final JButton Button = new JButton(BText);
Button.setBounds(posx, posy, sizex, sizey);
JF.add(Button);
Buttons.put(Bname, Button);
}
public static void SetButtonEvent(EventActionType EType,String ButtonName) {
if(EType == EventActionType.CLICKCOUNTER) {
final JButton Button = Buttons.get(ButtonName);
final JLabel Label = new JLabel("0");
JF.add(Label);
Label.setBounds(Button.getBounds().x,Button.getBounds().y + 50, 100, 100);
Button.addActionListener(new ActionListener() {
int Counter = 0;
public void actionPerformed(ActionEvent e) {
Counter++;
Label.setText(String.valueOf(Counter));
}
});
}
}
}
主类:
public class Main extends Base {
public static void main(String args[]) {
init(400,500);
CreateButton("Button_1","ClickMe",130,100,100, 40);
SetButtonEvent(EventActionType.CLICKCOUNTER,"Button_1");
}
}
GPU:Nvidia 1650
CPU:Intel core i5 9600
英文:
This is my first time downloading Android Studio and this what I get in the main menu:
Swing based apps have the same problem with the text:
The code for the swing app:
public class Base {
private static JFrame JF;
private static Map<String,JButton> Buttons = new HashMap<String,JButton>();
public static void init(int x, int y) {
JF = new JFrame();
JF.setSize(x, y);
JF.setLayout(null);
JF.setVisible(true);
}
public static void CreateButton(String Bname,String BText,int posx, int posy, int sizex, int sizey) {
final JButton Button = new JButton(BText);
Button.setBounds(posx, posy, sizex, sizey);
JF.add(Button);
Buttons.put(Bname, Button);
}
public static void SetButtonEvent(EventActionType EType,String ButtonName) {
if(EType == EventActionType.CLICKCOUNTER) {
final JButton Button = Buttons.get(ButtonName);
final JLabel Label = new JLabel("0");
JF.add(Label);
Label.setBounds(Button.getBounds().x,Button.getBounds().y + 50, 100, 100);
Button.addActionListener(new ActionListener() {
int Counter = 0;
public void actionPerformed(ActionEvent e) {
Counter++;
Label.setText(String.valueOf(Counter));
}
});
}
}
}
The main Class:
public class Main extends Base {
public static void main(String args[]) {
init(400,500);
CreateButton("Button_1","ClickMe",130,100,100, 40);
SetButtonEvent(EventActionType.CLICKCOUNTER,"Button_1");
}
}
GPU: Nvidia 1650
CPU: Intel core i5 9600
答案1
得分: 0
-- Android Studio 解决方案 --
为什么会出现这个问题?
我认为这是因为您正在使用的字体不受支持。要将其更改为受支持的字体,请按照以下步骤操作:
- 创建一个新的文本文件。
- 打开它并粘贴以下代码:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]
"Segoe UI (TrueType)"=""
"Segoe UI Bold (TrueType)"=""
"Segoe UI Bold Italic (TrueType)"=""
"Segoe UI Italic (TrueType)"=""
"Segoe UI Light (TrueType)"=""
"Segoe UI Semibold (TrueType)"=""
"Segoe UI Symbol (TrueType)"=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes]
"Segoe UI"="Verdana"
- 转到文件,点击 "另存为"。
- 将其命名为 "font.reg",然后点击下拉菜单并选择 "所有文件",最后点击保存。
- 在运行文件之前,请检查代码,因为如果代码出错,可能会损坏您的计算机。
- 运行该文件并重新启动您的计算机。
这是对我有效的方法,希望对您也有用。
祝您有美好的一天/夜晚!
再见
英文:
-- android studio solution --
why is this problem occurring?
i think it is because the font your using is not supported, to change it to a supported one, follow these steps:
- Create a new text file
- open it and paste in this code
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]
"Segoe UI (TrueType)"=""
"Segoe UI Bold (TrueType)"=""
"Segoe UI Bold Italic (TrueType)"=""
"Segoe UI Italic (TrueType)"=""
"Segoe UI Light (TrueType)"=""
"Segoe UI Semibold (TrueType)"=""
"Segoe UI Symbol (TrueType)"=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes]
"Segoe UI"="Verdana"
- go to file, and click "save as"
- name it "font.reg" and click on the drop down and select "all files" and then click save
- before you run the file check the code because this can potentially ruin your computer if you miss up the code
- run the file and restart you computer
now this is the method that worked for me hopefully it will work for you.
Have a good day/night
Bye
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论