简体   繁体   English

放置点不显示建议 Java Swing GUI

[英]Putting dot doesnt show the suggestions Java Swing GUI

I am trying to write a program with Java Swing GUI.我正在尝试使用 Java Swing GUI 编写程序。 My purpose is to check whether tables are available or not.我的目的是检查表是否可用。 So I tried such code as:所以我尝试了这样的代码:

JButton btnNewButton = new JButton("Send!");
btnNewButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {    
        int numberofpeople = Integer.parseInt(numberppltxtField.getText());
        
        if (numberofpeople ==1) {
            if (tables1.getTables() > 0) { /* I have a object tables1 which represent the number of 1 person tables )
            table1.setTables(tables1.getTables() -1 );
        }
        
        else {
        jlblWarning.setText("We're full!"); } /* to change the label under the button.*/
    }

JLabel lblNewLabel_11 = new JLabel("New label");
lblNewLabel_11.setFont(new Font("Times New Roman", Font.BOLD, 12));
lblNewLabel_11.setBounds(876, 463, 197, 30);
frame.getContentPane().add(lblNewLabel_11);

(Note: lblNewLabel_11 is equal to jlblWarning . I tried to create again.) (注意: lblNewLabel_11等于jlblWarning 。我尝试再次创建。)

So the problem is that when I write jlblWarning and put a dot here, I can not see setText suggestion.所以问题是当我写 jlblWarning 并在这里放一个点时,我看不到 setText 建议。 Also, when I write it without suggestion, I still have error.此外,当我在没有建议的情况下编写它时,我仍然有错误。 Can you please help me?你能帮我么?

Note: There might be little syntax error since I write the code here again, not copy paste.注意:由于我在这里再次编写代码,而不是复制粘贴,因此可能会有一些语法错误。

You have to define jlblWarning first您必须先定义jlblWarning

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM