I am trying to write a program with 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.)
So the problem is that when I write jlblWarning and put a dot here, I can not see setText suggestion. 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.