线程“AWT-EventQueue-0”中的异常java.lang.NumberFormatException:对于输入字符串:“”

时间:2017-03-22 20:56:54

标签: java swing integer actionlistener jtextfield

我知道有很多这样的话题,但我找不到我的错误,因为我觉得我做的一切都还好。简单地说,我想做的是创建一个gui,它会想要一个来自我的数字让我们说它是“x”,如果x< 50它会说“Geçtin”别的“Kaldın”但它看起来我不能在“文本”上设置任何东西。 那是我的鳕鱼,

Guibaslatma.java

公共类Guibaslatma {

@media print{
body:not(#myModal){
    display:none;
    visibility:hidden;
}
#myModal{ /*shouldn't have to but doesn't work anyway */
    display:block;
    visibility:visible;
}
}

Gui.java

    public static void main(String[]args) {
    gui a = new gui();
    a.guii();






    }
}

Action.java#`import javax.swing。*;

import java.awt.event.ActionEvent; import java.awt.event.ActionListener;

public class Action实现ActionListener {

 import javax.swing.*;  

public class gui extends JFrame {

    JButton tıkla = new JButton("Tıkla beni");
    JTextField Text = new JTextField();

  public  void guii() {

      this.setTitle("Ahmet");
      this.setLayout(null);
      this.setSize(1000,1000);
      this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      this.setVisible(true);

      Text.setSize(200,50);
      Text.setLocation(250,250);
      Text.setVisible(true);
      Text.setVisible(true);

      this.getContentPane().add(Text);


      tıkla.addActionListener(new Action());
      tıkla.setSize(100,100);
      tıkla.setLocation(250,350);
      tıkla.setVisible(true);
      this.getContentPane().add(tıkla);

      String getText = JOptionPane.showInputDialog(null,"Bir sayı gir");
      Text.setText(getText);
    }
}

0 个答案:

没有答案