Making System.out.println(); Statements red in Java [duplicate] - java

This question already has answers here:
How to print color in console using System.out.println?
(15 answers)
Closed 3 years ago.
How do I make this output "Make this a different color", but in red? In Java.
Sorry for stupid question
System.out.println("Make this a different color");

Try this
System.out.println("\033[0;31m Make this a different color");

I think you can't do it in Java if you are printing to the console.

Related

Getting the state of a window [duplicate]

This question already has answers here:
Getting active window information in Java
(3 answers)
Closed 4 years ago.
I'm trying to get the state of a window on Windows. I have to check if the window of word is active or inactive. I don't find any answer to this problem in Google.
Does anyone knows how to do this or if this is possible at all?
Window activeWindow = javax.swing.FocusManager.getCurrentManager().getActiveWindow();
The code above returns always NULL.
Thank you for your answers.
Regards
Roman
Try to use frame.hasFocus() or frame.isFocusOwner()
https://docs.oracle.com/javase/7/docs/api/javax/swing/JFrame.html

Java Swing checkboxes active [duplicate]

This question already has answers here:
How to add a radio button group in a core java program such that only one radio button is selected at one time?
(3 answers)
Closed 6 years ago.
I have a short question for you.
I have 2 checkboxes and I want to: when is the active one, the other should be off.
Tks in advance!
Please use JRadioButtons, that would fulfill your requirement.

Is there any way block Control-Alt-Delete in java? [duplicate]

This question already has answers here:
Disable the Ctrl-Alt-Delete event through Java program
(4 answers)
Closed 7 years ago.
Is there any way to block the control key in java. I have looked and looked but I have not found any way to do it thanks in advance
There is no way to block CTRL+ALT+DELETE. In any way, shape or form. It is an absolute guarantee against hacking.

Change background of a specific line of JTextArea [duplicate]

This question already has answers here:
Highlight one specific row/line in JTextArea
(3 answers)
Closed 8 years ago.
Is there any way to change the background of a specific line of JTextArea?
I found a class that does what I want. Those interested: http://www.camick.com/java/source/LinePainter.java
Thanks.

Create PopUp Window in Java [duplicate]

This question already has answers here:
Creating Java dialogs
(5 answers)
Closed 8 years ago.
How would I make a pop up box/A dialog window in Java? For instance say I want to make a window saying "Hello My name is John Smith". How would I do that? Would I have to use swing?
Yes, use Swing by simply using a Swing javax.swing.JOptionPane.
JOptionPane.showMessageDialg(null, "hello world");

Categories

Resources