本文介绍了Java GUI无法找到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞!package kalkulacka;import java.awt.*;import javax.swing.*;public class Lalala extends JFrame {private JTextField vloz1;private JButton stlac;private JTextField vloz2;private JLabel label_vysledok;private JPanel lajna1;private JPanel lajna2;public Lalala(){super ("Kalkulacka");FlowLayout layout = new FlowLayout();setLayout(layout);lajna1 = new JPanel();lajna1.setBackground(Color.blue);add(lajna1);lajna2 = new JPanel();lajna2.setBackground(Color.LIGHT_GRAY);add(lajna2);vloz1 = new JTextField();lajna1.add(vloz1);vloz2 = new JTextField();lajna1.add(vloz2);stlac = new JButton();lajna1.add(stlac);label_vysledok = new JLabel();lajna2.add(label_vysledok);}}package kalkulacka;import javax.swing.JFrame;public class Kalkulacka {public static void main(String[] args) {Lalala okno = new Lalala();okno.setVisible(true);okno.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);okno.setLocationRelativeTo(null);}} 我尝试了什么: 一个代码是kalkulacka的GUI(Lalala)。我尝试将类参数添加到类Lala方法中。然后我尝试更改setBackground和其他方法的位置。没有任何效果。 Eclipse告诉我这个问题:What I have tried:One code is a GUI (Lalala) of kalkulacka. I tried add a parameters to class Lala methods. Then I tried change position of setBackground and other methods. Nothing worked. Eclipse saying me this problem:The serializable class Lalala does not declare a static final serialVersionUID field of type long但我不知道Eclipse是什么意思.. 我在没有结果的情况下解决了这个问题两个小时。 but I dont know what Eclipse mean..I am solving this problem for two hour without a result.推荐答案只需在类定义中添加以下行:Just add the following line in your class definition:private static final long serialVersionUID = 1L; 这篇关于Java GUI无法找到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-27 12:13