Java Dialog setModal

In connection with my previous Java Project question - how to freeze Frame , can I darken the color of the main screen (make ALL gray or black and white) to highlight the player’s dialog box? How can i do this?

+3
source share
1 answer

See Glass Panel for an example and explanation .

In general, your glass glass can use a transparent background:

JComponent glassPane = new JPanel();
glassPane.setBackground( new Color(240, 20, 20, 100) );
frame.setGlassPane( glassPane );

Then, when you want to show the dialog, the base code will be:

glassPane.setVisible( true );
JDialog dialog = new JDialog(...);
// add components to dialog
dialog.setVisible( true );
glassPane.setVisible( false );
+2
source

Source: https://habr.com/ru/post/1788645/


All Articles