[英]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. setForeground
和setBackground
方法属于JComponent
/ Component
类,因此每个组件均可访问,因为所有Swing / AWT组件(在层次结构中的某个位置)都将扩展这些类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.