首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不兼容类型;不能将byte[]转换为字节。

不兼容类型;不能将byte[]转换为字节。
EN

Stack Overflow用户
提问于 2022-05-26 18:09:18
回答 1查看 251关注 0票数 0

(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();

代码语言:javascript
复制
 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;} }

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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[]

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72396235

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档