This question already has answers here:
Java Swing adding Action Listener for EXIT_ON_CLOSE
(4 answers)
JFrame Exit on close Java
(8 answers)
Closed 6 years ago.
Is there a way to know if JFrame was closed by pressing X, I mean the default exit button?
f.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
Related
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.
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");
This question already has answers here:
How to capture a JFrame's close button click event?
(6 answers)
Closed 8 years ago.
How do you add a ActionListener to the close button (not a JButton the button on the top-right)?
See Closing an Application for a discussion on this topic and a couple of solutions.
Basically you need to do two things:
Use the setDefaultCloseOperation(...) of the frame.
Add a WindowListener to the frame
This question already has answers here:
Swing: remove focus border from dialogues' buttons
(3 answers)
Closed 9 years ago.
I have a JButton in Java(Swing):
After the click I get this line around the button:
How do I remove these lines?
button.setFocusPainted(false); is the right solution!
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to change JFrame Icon
I want to put Logo or some icon on the corner of window in my Java desktop application.
How to do that?
Use setIconImage(ImageIcon) for this.