2012-07-22 40 views
0

我想讓我的TextArea黑色而不是白色。我希望使整個屏幕的Window整個屏幕將是TextArea黑色並將有白色字母。如何使Java中的TextArea變爲黑色?

我該如何做到這一點?

+0

Swing? AWT?還有別的嗎? – 2012-07-22 17:21:48

回答

1

Swing組件

JTextArea txt = new JTextArea(); 
//Set background black 
txt.setBackground(Color.BLACK); 
//Set Foreground(text) white 
txt.setForeground(Color.WHITE); 

規則同樣適用於AWT組件

TextArea txt = new TextArea(); 
//Set background black 
txt.setBackground(Color.BLACK); 
//Set Foreground(text) white 
txt.setForeground(Color.WHITE); 

setForegroundsetBackground方法屬於JComponent/Component類因此accessibl e傳遞給每個組件,因爲所有Swing/AWT組件在層次結構的某個位置將擴展這些類。

3

試試這個..

JTextArea txt = new JTextArea(); 
txt.setBackground(Color.BLACK); 
txt.setForeground(Color.WHITE); 
+0

謝謝......我包括它...... – 2012-07-22 17:25:17

+0

非常感謝,它幫助! – 2012-07-23 10:20:26

相關問題