3

以前の質問Java Project - how to freeze Frameに関連して、メイン画面の色を暗くして (すべてをグレーまたは白黒にして)、プレーヤー ダイアログ ボックスを強調表示することはできますか? どうやってやるの?

4

1 に答える 1

2

完全な例と説明については、 Glass Paneの例を参照してください。

一般に、ガラス ペインは透明な背景を使用できます。

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

次に、ダイアログを表示する場合の基本的なコードは次のようになります。

glassPane.setVisible( true );
JDialog dialog = new JDialog(...);
// add components to dialog
dialog.setVisible( true );
glassPane.setVisible( false );
于 2011-01-29T05:29:04.220 に答える