I'm making my first java desktop application (which explains the lack of knowledge), when I run the project, the default output comes in the console instead of the actual project, wheras when the field is filled in correctly, it shows the output on the application/project.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String name = textBoxName.getText();
switch (textBoxName.getText()) {
case "":
System.out.println("Name field cannot be blank!");
break;
default:
Message.setText(name);
}
}
Using System.out.println("your message here"); you are writing in the console, which is usually used to debug things. If you want to show the message to the user in a GUI interface, there is an useful class in Swing.
Instead of System.out.println(); try
JOptionPane.showMessageDialog(null, "Name field cannot be blank!");
which will create a dialog with your message inside it and a button to close it. You can also specify a title of the dialog and the type of dialog like this:
JOptionPane.showMessageDialog(null, "Name field cannot be blank!", "Title of the message", JOptionPane.PLAIN_MESSAGE);
where instead of JOptionPane.PLAIN_MESSAGE you can also put ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE or QUESTION_MESSAGE.