John McTavish
John McTavish

Reputation: 33

How can I make the TextArea in Java black?

I want to make my TextArea black instead of white. I wish to make the Window fullscreen where the whole screen would be the TextArea that's black and would have white letters.

How can I achieve this?

Upvotes: 0

Views: 981

Answers (2)

Nitin Chhajer
Nitin Chhajer

Reputation: 2339

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

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.

Upvotes: 1

Kumar Vivek Mitra
Kumar Vivek Mitra

Reputation: 33534

Try this..

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

Upvotes: 3

Related Questions