(databaseForm.java)
公共类databaseForm扩展javax.swing.JFrame {
jLabelCloseMouseClicked(java.awt.event.MouseEvent *创建新的表单databaseForm */ String imgPth = null;公共databaseForm() { initComponents();}私有的无效databaseForm evt) { // TODO在这里添加处理代码: System.exit(0);){ // TODO在这里添加您的处理代码: jLabelMinMouseClicked(java.awt.event.MouseEvent (JFrame.ICONIFIED);在这里添加处理代码: Myfunc = new ();imgPth = mf.browseImage(jLabelDataPic);System.out.println(imgPth);在这里添加您的处理代码: snumber = jTextFieldSNumber.getText();String = jTextFieldFName.getText();String = jTextFieldLName.getText();String = jComboBoxGender.getSelectedItem().toString();String = jComboBoxCourse.getSelectedItem().toString();字符串年= jComboBoxYear.getSelectedItem().toString();String节= jTextAreaAddress.getText();
byte[] img = null; try { Path pth = Paths.get(imgPth); img = Files.readAllBytes(pth);
data d = new data(0, snumber, fname, lname, gender, course, year, section, img, address, 0); } (data.java)
公共类数据{
私有字符串SNumber;私有字符串FName;私有字符串LName;私有字符串性别;私有字符串课程;私有字符串年;私有字符串节;私有字节图像;私有字符串地址;私有int uid;// Alt + Insert //以生成构造函数&getter& setters公共数据() {}公共数据( int cid,字符串SNumber,字符串FName,字符串LName,字符串性别,字符串过程,字符串年,字符串节,字节图像,
字符串地址,int ){ this.cid = cid;this.SNumber = SNumber;this.FName = FName;this.LName = LName;this.Gender =性别;this.Course = Course;this.Year =this.Year= Section;this.Image = Image;this.Address = Address;this.uid = uid;}
公共int getCid() {返回cid;} public void setCid(int cid) { this.cid =this.cid;}公共字符串getSNumber() {返回SNumber;}公共空setSNumber(String SNumber) { this.SNumber = SNumber;}公共字符串getFName() {返回FName;} public void setFName(String FName) { this.FName = FName;}公共字符串getLName() {返回LName;} public void setLName(String LName) { this.LName = LName;}公共字符串getGender() {返回性别;} public void setGender(字符串性别){ this.Gender =性别;}公共字符串getCourse() {返回过程;}公共空setCourse(字符串过程){ this.Course =LName;}公共字符串getYear() {返回年;}公共空setYear(字符串年){ this.Year =年份;}公共字符串getSection() {返回节;}公共空setSection(字符串段){ this.Section =节;}公共字节getImage() {返回图像;}公共空setImage(字节图像){ this.Image =图像;}公共字符串getAddress() {返回地址;}公共空setAddress(字符串地址){ this.Address =地址;}公共int getUid() {返回地址;} setUid(int uid) { this.uid = uid;} }
发布于 2022-05-26 18:39:32
在你的构造函数中,
public data(int cid, String SNumber, String FName, String LName, String Gender, String Course, String Year, String Section, byte Image,String Address, int uid)
您期望Image为字节类型,但传递字节数组byte[] img = null;将数据类中Image属性的参数类型更改为byte[]。
https://stackoverflow.com/questions/72396235
复制相似问题