简体   繁体   English

如何在JComboBox中准确显示字符串?

[英]How to accurately display string in JComboBox?

I have an array of strings that represent options in a drop-down menu. 我有一个字符串数组,表示下拉菜单中的选项。

        String[] s_reflection_map = {
                "x=W–1–x mod W                               ",
                "x/W even x=x mod W; odd x=W–1–x mod W, no PI",
                "same, but with Pixel Interpolation          ",
                "x=x mod W/2, y=y mod H/2                    ",
                "x>W–1,x=x mod W else x=W–1–x mod W          ",
                "x<W,x=x mod W//2 else x=W–1–x mod W         ",
                "x/W even,x=x mod W/2;odd x=W–1–x mod W/2    ",
                "x/W even,x=x mod W/2;odd x=(W–1)/2–x mod W/2",
                "simple                                      "
        };

        JComboBox<String> jcb_reflection_map = new JComboBox<>(s_reflection_map);

Minus sign, the character "-" cannot be displayed correctly. 减号,字符“ - ”无法正确显示。

JComboBox在配置JFrame窗口中显示

Can anyone remind me of why minus is illegal character? 任何人都可以提醒我为什么减去非法人物?

The subtraction symbols are encoded as literal Unicode EN DASH' (U+2013) characters, the preferred glyph in a mathematical context. 减法符号被编码为文字Unicode EN DASH' (U+2013)字符,这是数学上下文中的首选字形。 In Java source, substitute the corresponding escape, for example, 在Java源代码中,替换相应的转义,例如,

"x=W\u20131\u2013x mod W                               ",

这种格式效果很好。

"x = W \u2013 x mod W"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM