如何检查是否JTextfield为空以返回true或false并设置焦点?我已经尝试检查该字段是否等于null但是这不起作用.我所做的与此问题有关的内容可以在注释// THIS SECTION OF CODE和它下面的布尔值下找到
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DollarStore extends Applet implements ActionListener
{
public JLabel n1 = new JLabel("Enter sales person number (1-4): ");
public JTextField tf1 = new JTextField(5);
public JLabel n2 = new JLabel("Enter product number (1-5): ");
public JTextField tf2 = new JTextField(5);
public JLabel n3 = new JLabel("Enter sales amount (0.01-0.99): ");
public JTextField tf3 = new JTextField(5);
public JTextArea ta = new JTextArea (8,58);
public …Run Code Online (Sandbox Code Playgroud) 我希望用户输入strrev的字符串来反转但是当用户输入字符串空格时由于某种原因是不允许的,所以如果有人输入你好我的名字是stan.输出只是nats,我怎样才能获得接受空格的功能?
#include<iostream>
#include <cstring>
#include<string.h>
using namespace std;
int main()
{
char str[] = "This is a c-StyleString";
//cout <<"Enter the string:" << endl;
//cin >> str;
cout << "Reverse of the given string is: " << strrev(str);
return 0;
}
Run Code Online (Sandbox Code Playgroud)