如何将值从一个帧传递到另一个帧

编程入门 行业动态 更新时间:2024-10-28 13:29:06
本文介绍了如何将值从一个帧传递到另一个帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在这里有一个登录表单,包括用户名密码 我有另一个表格可以记录客户数据,填写的文本框很少。 喜欢客户名称; 客户电子邮件和客户联系。 基本上当用户接到客户的电话时会发生这种情况。 用户输入他或她的用户名和密码,登录系统。 和用户必须填写文本框,提交后,数据保存在mysql数据库中。 所以mysql有一个名为customer的数据库。 it有五个cloumns cus id,cusName,cusAdress,cusContact,contactUser 所以我创建了一个名为MysqlConnect的类,它拥有所有的setter和getter。 所以我创建了一个名为setName和getName的getter和setter

Here i have a login form includes username and password and i have another form which can records customer data and there are few text boxes to fill. like customer name; customer email and customer contact. the basically what happens is when user get a call from a customer. user put his or her user name and password, login to the system. and user has to fill textboxes and after submit it, data saves in a mysql database. so mysql has a database called customer. it has five cloumns cus id,cusName,cusAdress,cusContact,contactUser So i have created a class called MysqlConnect which holds all setters and getters. so i have created a getter and setter called setName and getName

public class MysqlConnect { String Name; public void setName(String newName){ Name = newName; } public String getName(){ return Name; } }

然后我在登录表单中设置一个值

then i set a value in the login form

nameSet = uName.getText();//gets the username from a textbox MysqlConnect cont = new MysqlConnect(); cont.setName(nameSet);

之后,我已经在其他表格中实施了一个getter来调用客户数据。

after that i have implement a getter in the other form call customer data.

MysqlConnect cont = new MysqlConnect(); String namet = cont.getName(); JOptionPane.showMessageDialog(null, "Data Saved Successfully."+nameUser+"");

但它显示为空值。 我尝试过: 我描述的getter和setter?

But it shows a null value. What I have tried: Getters and Setters as i Described?

推荐答案

是的,因为你创建了一个新的 MysqlConnect 实例时间,所以它不会包含任何数据。您应该在应用程序的开头创建一个类的实例。这样它将始终包含最新的值。 Yes, because you create a new instance of MysqlConnect each time, so it will not contain any data. You should have one instance of the class created at the start of your application. That way it will always contain the most up to date values.

更多推荐

如何将值从一个帧传递到另一个帧

本文发布于:2023-11-25 14:29:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1630125.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!