I am trying to create a gui using swing. I have a main frame and I want it to only show the x button at the top right corner. I would also like to make this button impossible to press if certain conditions are met. I did some search on google and on java’s website but I couldn’t find any functions related to these two tasks. Any small pieces of code or links to tutorials or apis are welcome.
I want the button to be there. I don’t want the window to close (which I can do with the setDefaultCloseOperation) and also I’m trying to find a way to be able to make the button look greyed out and not allow it to execute the animation of getting pressed in when I click on it. I want it to be there but grey and totally non responsive.
maybe
myFrame.setResizable(false);and all of Events for this Button you can hande this wayEDIT:
window’s decorations coming from Native OS, and then you have this four options as follows
full decorated (JFrame) minimize/maximize/close Button
only close Button JDialog and JFrame#setResiziable(false)
undecorated, then there missed minimize/maximize/close Button(a) and toolBar (that came from Native OS) too
undecorated Top-level Container with JPanel (with GradientPaint simulated real ToolBar) contains JButton with Char X (could be enabled once time or another time disabled as you want)