Current operating systems (e.g. Windows, macOS) let the user decide if they want dark content on light blackground (classic) or rather light content on dark blackground (dark mode). Is there something available in Java, so that my (client side) Java programs can automatically adjust their contrast polarity according to that OS user setting? I am using Swing, if that matters.
Tag: swing
JDialog not focused on OSX when Java is not on top
My JDialog is not focused when the Java program is not in the front in OSX. How do I achieve this? I have the following test program to illustrate the scenario (at the bottom), running using javac Test.java && java Test from a terminal. When the terminal output “Started first”, it will change focus to the Java program. I remove
how to use JTextField to show a negative or positive result using ActionListener on the JTextField itself
My program is supposed to ask a user to write a number in a JTextField and then show the result if the number is negative or positive in another JTextField that is disabled. All of that must be done without a button. Answer In your example you’ve forget to call the method JavaJTextFieldActionListner. I’ve remove it and move the code
No output after button click, since the variable doesn’t exist?
I wanted a frame with one TextArea and one Button. When I press the button, the TextArea should show a food menu of 5 Pizzas, well it shows nothing at all, except for the console which shows In the method windowsStart() the objects exists and are adjustable. In the actionPerformed()Method the objects are … kind of invisible, not existing? The
Highest performance for Keyboard Input
So I have a small java game engine using a single JFrame. I am currently using Key-Bindings as they were working neatly but I figured that a KeyListener might be architecturally more fitting. But since I honestly don’t really care which I’ll use I wanted to ask if there is a performance difference between these or even a better option
In Java how do you pass variables and lists between jframe components
I have created a simple program with a list object. I also have a simple UI and want to add the values from the different parts of the list to the text frames and labels but cannot find how to pass the values that are needed. The list object has been created in the main class of the UI (which
How to use a thread to run another JFrame while the main is still running
I have a jframe i want to display while my main frame is running. i want to pause my main code, until the user does the necessary actions on the other frame. I’ve read a lot of solutions but i need to see it done for my code to understand and grasp it fully. i do not want to use
How to add a JPanel graphic to a JFrame without covering the JFrame
I’m trying to add a small tornado graphic (upside down pyramid) to my Frame. I can get the tornado by adding it to the frame in the main method but when I do that all I see is the tornado graphic and not the GUI underneath it. So, I’m now trying to add the Tornado graphic to the frame when
How to scale basic drawings?
I would like to have a list of shapes, that appears in my window. Whenever I’m changing the size of the window, I would like to scale all of my drawings. I already prepared classes, that store information about random shapes in a list (rectangles, ovals, etc.). I have no problem with painting them all, but I can’t deal with
How do I stop JFrame/JPanel from auto-formatting the distances between my components?
So I’m writing a program which utilizes a GUI. The GUI is built from a JFrame and a JPanel in Java. I have a JTextArea() and a JButton() that appears beside the JTextArea on the left. I also have an image which I imported locally using the method call below (“f” is the variable name of my JFrame): I don’t