Skip to content

Tag: swing

event when press exit button: JOptionPane.showInputDialog

How can I add a function after clicking on the cancel or exit button? I tried it like this but it doesn’t work for me. It shows me an error that choice is null but it couldn’t be because it is int? is there any other possibility to solve it? Answer When you press the “exit” or “c…

JFrame keeps application running even after closing

I have a class with only static methods and one of them opens a JOptionPane error message dialogue using a JFrame object as component. This is the class + method: The ErrorPopup method is used inside a JavaFX controller and other places, called like this: Problem is that the application’s process won&#8…

Difference between getscaleinstance and scale? (swing java)

I saw a code that used getScaleInstance(x,x) to declare the scale. On the other hand, I also saw that some people used scale to declare the scale. What is the difference? For example: What is the difference between 1 and 2? Answer I have checked the docs for you and have found that: scale() – is a trans…

How to clear a JFrame?

I’m still a noob to Swing classes and I wanted to clear the screen after the user activates a button. I have used the following and it didn’t really do anything. Answer you should use it this way

How to make an app using swing that only uses 1 JFrame?

I am making an app or (something.exe). I want to make a class that will serve as my main frame. That is because I don’t want to create new frame for each class that I will make. I want my class MainMenu to have the Frame of MainFrame where I can put buttons and etc. Answer Make use of Model-view-control…