gpt4 book ai didi

java - 与小程序交互时 JTextArea 变黑?

转载 作者:行者123 更新时间:2023-11-29 05:08:45 27 4
gpt4 key购买 nike

出于某种原因,如果您突出显示文本区域文本,背景会变成黑色,从而使文本不可读,同样当我选择底部的单选按钮(见附图)时,整个文本区域会再次变黑使文本不可读!有人知道为什么要这样做吗?

这是我的文本区域的代码...

        //Text area that displays the games instructions
textAreaInstructions = new JTextArea(
"To play choose your difficulty and then click start. \n\n" +
"The aim of the game is to select the 'golden' rectangle, you will be presented with 4 \n" +
"rectangles and you must choose one that has height and width proportions that represent \n" +
"the golden ratio: 1.618. If you're not too sure what a golden rectangle looks like it's \n" +
"best you start on beginner until you get the hang of it! \n\n" +
"For every correctly identified golden rectangle you score 1 piece of 'Gold', however if you \n" +
"incorrectly identify a golden rectangle, 1 piece of 'Gold' will be taken away from your \n" +
"score. Remember, you only have 30 seconds, so collect as much 'Gold' as you can, good luck! \n");
c.add (textAreaInstructions);
textAreaInstructions.setBounds(130, 110, 600, 200);
textAreaInstructions.setEditable(false);
textAreaInstructions.setBackground( new Color(0, 0, 0, 0) ); //Transparrent background to text area

selected text clicked radio buttons

最佳答案

Swing 不理解透明颜色。相反,您必须使用 setOpaque 并将其传递给 false

textAreaInstructions.setEditable(false);
//textAreaInstructions.setBackground( new Color(0, 0, 0, 0) );
textAreaInstructions.setOpaque(false);

对于 example,您也可以使用 JLabel 并将其文本包装在 HTML 中. JLabel 默认透明

关于java - 与小程序交互时 JTextArea 变黑?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29483151/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com