简体   繁体   English

从一个Jframe到NetBeans中的JPanel

[英]Going from one Jframe to a JPanel in NetBeans

I have created a login form where users will enter their credentials and navigate to other frame. 我创建了一个登录表单,用户将在其中输入其凭据并导航到其他框架。 This frame to frame transition is working fine. 这种逐帧过渡效果很好。 But I also added a admin login from a invisible label in the bottom. 但是我还从底部的不可见标签添加了管理员登录名。

When the admin clicks the invisible label on the user login frame (NewJFrame), a custom login panel (Admin) should be opened. 当管理员单击用户登录框架(NewJFrame)上的不可见标签时,应打开一个自定义登录面板(Admin)。

But when I click the label, JPanel is not showing. 但是,当我单击标签时, JPanel没有显示。

private void jLabel6MouseClicked(java.awt.event.MouseEvent evt) 
{
    Admin o = new Admin();           // Admin is a login panel
    NewJFrame o1= new NewJFrame();   
    o1.add(o);                     // Throwing an Exception here

    // TODO add your handling code here:
}    

you are adding it on mouse click ? 您是通过鼠标单击添加它的? i think you should add it at start and on mouse click , just make it visible by yourPanel.setVisible(true); 我认为您应该在开始并单击鼠标时将其添加,只需使其通过yourPanel.setVisible(true)可见即可;

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

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