Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/jls/elem/StateMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@ private class StateEditor extends JDialog
private Point movingPoint;
private boolean nameChange;
private StateMachine machine;
private boolean creating;

/**
* Set up create dialog window.
Expand All @@ -824,6 +825,7 @@ private StateEditor(StateMachine machine, boolean creating) {
// save reference to me
currentDialog = this;
this.machine = machine;
this.creating = creating;

// set not canceled
canceled = false;
Expand Down Expand Up @@ -1058,6 +1060,20 @@ public void actionPerformed(ActionEvent event) {
else {
nameChange = true;
}
if (creating) {
String message = "";
if (states.isEmpty() && name.trim().isEmpty()) {
message = "You need a name and at least one state.";
} else if (states.isEmpty()) {
message = "You need at least one state.";
} else if (name.trim().isEmpty()) {
message = "You need a name.";
}
if (!message.isEmpty()) {
JOptionPane.showMessageDialog(this, message, "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
dispose();
}
else if (event.getSource() == cancel) {
Expand Down