Skip to content
Sign upLog in
← Back to Community

How to change screen background in java

Profile icon
plscodeinjava

Title says it all, please help!!!!

Answered by Highwayman [earned 5 cycles]
View Answer
Voters
Profile icon
ShaziaKamboh
Profile icon
plscodeinjava
Comments
hotnewtop
Profile icon
Highwayman

The screen as in the terminal or the screen as in the actual like window screen for a Swing app or something

Profile icon
plscodeinjava

@Highwayman

As in the terminal, its NOT a swing app

Profile icon
Highwayman

Ah. There is no portable way(AFAIK) to change the terminal bgcolor, but you can use ansi escape codes on repl.it. Just look up "ANSI Escape code for XXX background" where XXX is the color. If you can’t find it I’ll just give it to you hope that helps


@amaddentcsec

Profile icon
plscodeinjava

@Highwayman

Some sites are blocked because of school, just give them to me thanks so much!!!!

Profile icon
Highwayman

Ok, it’s

integer code = /* sone number from 40 to 47 */; System.out.println("\033[" + code + "m");

@amaddentcsec

Profile icon
plscodeinjava

@Highwayman

Thats really not what i'm looking for though...

image

Profile icon
Highwayman

Ohh so.... hm. Ok so what if you did like you make a set_background() function that just sets the background and then outputs spaces for the entire screen and then just... uh... f. I’m sorry. That’s basically the only thing I know about for changing console colors is codes so...

@amaddentcsec