gpt4 book ai didi

java - 是否有可能将 JPanel 对象存储在 arraylist 中

转载 作者:行者123 更新时间:2023-12-01 23:53:03 26 4
gpt4 key购买 nike

嗨,我从团队领导那里得到了一项任务,即存储用户在文本字段中输入的员工详细信息,无论该面板中的内容如何,​​之后在另一个框架中,管理员必须通过调用数组列表来检查每个员工的详细信息,该列表应在卡片布局中显示面板,这是我的员工注册编码。任何人都可以帮助我

Registration()
{
frm=new JFrame("Welcome to the login page");
left=new JPanel(new GridLayout(0,1));
left.setBackground(Color.LIGHT_GRAY);
right=new JPanel(new GridLayout(0,1));
right.setBackground(Color.LIGHT_GRAY);
sp=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,left,right);
lb9=new JLabel("Member");
lb9.setFont(new Font("Serif",Font.PLAIN, 18));
lb9.setForeground (Color.blue);
lb10=new JLabel("Create an Account");
lb10.setFont(new Font("Serif", Font.PLAIN, 16));
lb10.setForeground (Color.blue);
lb1=new JLabel("Username");
tf1=new JTextField(10);
lb2=new JLabel("Password");
tf6=new JTextField(10);
lb3=new JLabel("First Name");
tf2=new JTextField(10);
lb4=new JLabel("Last Name");
tf3=new JTextField (10);
lb5=new JLabel("Password");
psd2=new JPasswordField (10);
lb6=new JLabel("Confirm password");
psd3=new JPasswordField (10);
lb7=new JLabel("MailID:");
tf4=new JTextField (10);
lb8=new JLabel("Contact No");
tf5=new JTextField (10);
b1=new JButton("Enter");
b2=new JButton("Register");

}
public void launchFrame()
{


frm.setSize(450, 350);
frm.add(sp);
//sp.setLeftComponent(left);
//sp.setRightComponent(right);
left.add(lb9);
left.add(lb1);
left.add(tf1);
left.add(lb2);
left.add(tf6);
left.add(b1);


right.add(lb10);
right.add(lb3);
right.add(tf2);
right.add(lb4);
right.add(tf3);
right.add(lb5);
right.add(psd2);
psd2.setEchoChar('*');
right.add(lb6);
right.add(psd3);
psd3.setEchoChar('*');
right.add(lb7);
right.add(tf4);
right.add(lb8);
right.add(tf5);
right.add(b2);

frm.setVisible(true);
}

最佳答案

像这样创建List对象

List<JPanel> panelList = new ArrayList<JPanel>();

// add your JPanel object like this way
panelList.add(yourPanel);

// retrieve your JPanel object from list
JPanel panel = panelList.get(index);

关于java - 是否有可能将 JPanel 对象存储在 arraylist 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16075287/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com