Java 非ASCII字符*有时*不作为JButton文本使用

Java 非ASCII字符*有时*不作为JButton文本使用,java,eclipse,user-interface,jbutton,Java,Eclipse,User Interface,Jbutton,我正在尝试用一些非ASCII字符作为标题的按钮来制作gui。(∧, ∨ 及↔ 特别是)我使用“\u2227”这样的字符串来完成此任务,因为我尝试使用”∧" 我做了一个小测试GUI(将所有代码写在一个.txt文件中,然后在终端上编译)很遗憾,我的gui太复杂了,无法全部手动编写,因此我改用Eclipse的WindowBuilder。当我尝试在Eclipse中创建相同的按钮时,该按钮会显示以下符号(□ ) 相反,如果我在eclipse之外运行eclipse生成的代码,那么这个问题就会一直存在,所以代

我正在尝试用一些非ASCII字符作为标题的按钮来制作gui。(∧, ∨ 及↔ 特别是)我使用“\u2227”这样的字符串来完成此任务,因为我尝试使用”∧" 我做了一个小测试GUI(将所有代码写在一个.txt文件中,然后在终端上编译)很遗憾,我的gui太复杂了,无法全部手动编写,因此我改用Eclipse的WindowBuilder。当我尝试在Eclipse中创建相同的按钮时,该按钮会显示以下符号(□ ) 相反,如果我在eclipse之外运行eclipse生成的代码,那么这个问题就会一直存在,所以代码肯定有问题,而不仅仅是eclipse错误。我一辈子都搞不清楚这里发生了什么

有人知道我怎么解决这个问题吗

测试代码(已工作):

Eclipse生成的代码(按钮有错误的符号)我从1000多行代码中删掉了这个代码,只显示相关的代码,但即使只运行这部分代码,问题仍然存在

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.GridBagLayout;
import javax.swing.JButton;
import java.awt.GridBagConstraints;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTabbedPane;
import java.awt.Insets;
import java.awt.CardLayout;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.datatransfer.*;
import java.awt.Toolkit;
import java.awt.Font;

public class Test {
private JFrame frame;

/**
 * Launch the application.
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                Test window = new Test();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

/**
 * Create the application.
 */
public Test() {
    initialize();
}

/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame();
    frame.setBounds(100, 100, 350, 361);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(new CardLayout(0, 0));

    JTabbedPane tabbedPane_1 = new JTabbedPane(JTabbedPane.TOP);
    frame.getContentPane().add(tabbedPane_1, "name_7199196968440");

    JPanel logicPanel = new JPanel();
    tabbedPane_1.addTab("Logic", null, logicPanel, null);
    GridBagLayout gbl_logicPanel = new GridBagLayout();
    gbl_logicPanel.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    gbl_logicPanel.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    gbl_logicPanel.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    gbl_logicPanel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    logicPanel.setLayout(gbl_logicPanel);

    JButton button_1 = new JButton("\u2227");
    button_1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
        }
    });
    button_1.setFont(new Font("Arial", Font.PLAIN, 16));
    GridBagConstraints gbc_button_1 = new GridBagConstraints();
    gbc_button_1.insets = new Insets(0, 0, 5, 5);
    gbc_button_1.gridx = 5;
    gbc_button_1.gridy = 2;
    logicPanel.add(button_1, gbc_button_1);
    }
}

eclipse代码在这里工作得很好。@JBNizet它对我不起作用,我试过从eclipse和多台计算机上的终端运行它,你真的运行了它并得到了一个∨ 在按钮上?尝试更改字体。这可能是由于此原因。在Mac中,我无法再现错误。或者更改项目编码…eclipse代码在这里工作正常。@JBNizet它对我不起作用,我尝试从eclipse和多台计算机上的终端运行它。您真的运行了它并获得了一个∨ 在按钮上?尝试更改字体。这可能是因为。在Mac中,我无法再现错误。或者更改项目编码。。。
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.GridBagLayout;
import javax.swing.JButton;
import java.awt.GridBagConstraints;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTabbedPane;
import java.awt.Insets;
import java.awt.CardLayout;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.datatransfer.*;
import java.awt.Toolkit;
import java.awt.Font;

public class Test {
private JFrame frame;

/**
 * Launch the application.
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                Test window = new Test();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

/**
 * Create the application.
 */
public Test() {
    initialize();
}

/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame();
    frame.setBounds(100, 100, 350, 361);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(new CardLayout(0, 0));

    JTabbedPane tabbedPane_1 = new JTabbedPane(JTabbedPane.TOP);
    frame.getContentPane().add(tabbedPane_1, "name_7199196968440");

    JPanel logicPanel = new JPanel();
    tabbedPane_1.addTab("Logic", null, logicPanel, null);
    GridBagLayout gbl_logicPanel = new GridBagLayout();
    gbl_logicPanel.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    gbl_logicPanel.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    gbl_logicPanel.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    gbl_logicPanel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    logicPanel.setLayout(gbl_logicPanel);

    JButton button_1 = new JButton("\u2227");
    button_1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
        }
    });
    button_1.setFont(new Font("Arial", Font.PLAIN, 16));
    GridBagConstraints gbc_button_1 = new GridBagConstraints();
    gbc_button_1.insets = new Insets(0, 0, 5, 5);
    gbc_button_1.gridx = 5;
    gbc_button_1.gridy = 2;
    logicPanel.add(button_1, gbc_button_1);
    }
}