简体   繁体   English

如何使Java中的TextArea黑色?

[英]How can I make the TextArea in Java black?

I want to make my TextArea black instead of white . 我想将TextArea设为黑色,而不是白色 I wish to make the Window fullscreen where the whole screen would be the TextArea that's black and would have white letters. 我希望将Window全屏显示,其中整个屏幕将是黑色TextArea并带有白色字母。

How can I achieve this? 我该如何实现?

Try this.. 尝试这个..

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

For swing components 对于秋千组件

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

Same goes for the awt components awt组件也是如此

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

The setForeground and setBackground methods belong to the JComponent / Component class and hence accessible to every component, as all the Swing/AWT component, at some place up the hierarchy, will extend these classes. setForegroundsetBackground方法属于JComponent / Component类,因此每个组件均可访问,因为所有Swing / AWT组件(在层次结构中的某个位置)都将扩展这些类。

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

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