java 中当文本域无输入内容时用 getText()取得的是什么值???
java中当文本域无输入内容时用getText()取得的是什么值???是“null”还是其他?
package thread_437601; import java.awt.event.*; import javax.swing.*; public class GetTextTest { public static void main(String args[]) { MyFrame myframe = new MyFrame(); } } class MyFrame extends JFrame { public MyFrame() { this.getContentPane().setLayout(null); jtextfield.setBounds(10, 10, 100, 20); jbutton.setBounds(10, 40, 100, 20); jbutton.addActionListener((ActionEvent e) -> { String jtextfield_text = jtextfield.getText(); if ("".equals(jtextfield_text)) { JOptionPane.showMessageDialog(null, "2楼说的对", "无输入内容时getText()取得值", JOptionPane.PLAIN_MESSAGE); } else if (null == jtextfield_text) { JOptionPane.showMessageDialog(null, "3楼说的对", "无输入内容时getText()取得值", JOptionPane.PLAIN_MESSAGE); } else { JOptionPane.showMessageDialog(null, "2楼和3楼都不对", "无输入内容时getText()取得值", JOptionPane.PLAIN_MESSAGE); } }); this.getContentPane().add(jtextfield); this.getContentPane().add(jbutton); this.setSize(120, 120); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.setVisible(true); } private JTextField jtextfield = new JTextField(); private final JButton jbutton = new JButton("Button"); }