2015-04-07 3 views
1

По какой-то причине, если вы выделяете текст текстовой области, фон становится черным и, следовательно, делает текст нечитаемым, также когда я выбираю переключатели внизу (см. Прикрепленные изображения), вся область текста затем становится черной, текст нечитабельный! Кто-нибудь знает, почему он это делает?JTextArea становится черным при взаимодействии с апплетом?

Вот код для моего текстового поля ...

 //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

ответ

3

свинг не понимает, прозрачные цвета. Вместо этого, вы должны использовать setOpaque и передать его false

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

Вы можете использовать JLabel с это текст, завернутые в HTML, а также, для example. JLabel по умолчанию является прозрачным

+1

Ahaaa! Большое спасибо! – JL9

Смежные вопросы