简体   繁体   English

单击 JFrame 上的 JButton 后如何使 JPanel 可见

[英]How To Make a JPanel visible after clicking a JButton on a JFrame

Here we go...My java application's login form has a option called forgot password..when I click that a panel should appear same time login JFrame goes back and keep as a shade window.that new panel come forward.我们开始吧...我的 Java 应用程序的登录表单有一个名为忘记密码的选项..当我单击一个面板时,应该同时出现一个面板,同时登录 JFrame 返回并保留为一个阴影窗口。那个新面板出现了。

this.dispose(); this.dispose();

this will close the default window is there any method to do that..keep default window open and goes back like a shade, a panel come forword这将关闭默认窗口是否有任何方法可以做到这一点..保持默认窗口打开并像阴影一样返回,面板出现

Dont use .dispose() you only need to hide it.Use不要使用 .dispose() 你只需要隐藏它。使用

.setVisible(false);

If you want to make it faded out you have to animate it.Use jDialog instead.And play a bit with opacity.Bud in that case dont put set visible to False.Or you wont see it at all.如果你想让它淡出,你必须动画它。使用 jDialog 代替。并使用不透明度玩一点。Bud 在这种情况下不要把 set visible 设置为 False。否则你根本看不到它。

On new component which you want to have over it在您想要拥有的新组件上

.setAlwaysOnTop(true); // this makes sure that you will see it on top of your main window

after you are done put it away with dispose if you dont need it afterwards.完成后,如果您以后不需要它,请将其丢弃。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM