Next, you will edit the source code to add the status codes that are displayed in the combo box.
To add the status codes:
1- Return to the Code Editor and find the jbInit() function.
2- Click just before, on, or following the opening curly brace.
Notice that the opening brace appears now highlighted in a different color. Its matching closing brace is highlighted in the same color, at the same time. If you cannot see the closing brace, scroll down until you come to it.
This brace-matching feature is very useful when you have long or nested conditional statements or parentheses, and you want to make sure you have matched them all correctly. If the editor finds a mismatching brace or parenthesis, it highlights the mismatch in a different color.
You can customize this and other highlighting features in the Preferences dialog. From the main menu, choose Tools | Preferences. Expand the Code Editor node and select Syntax Colors. To work with highlighting features, in the Category list, select Highlights. Choose foreground and background colors for the current selection in the Available Styles list.
In the Code Editor, after the line this.getContentPane().add(jLabel2, null); add the following code:
// Status Code
jComboBox1.addItem("0");
jComboBox1.addItem("1");
jComboBox1.addItem("2");
jComboBox1.addItem("3");
jComboBox1.addItem("4");
jComboBox1.addItem("5");
jComboBox1.addItem("6");
jComboBox1.addItem("7");
jComboBox1.addItem("8");
jComboBox1.addItem("9");
jComboBox1.addItem("10");
You can copy the code directly into the Code Editor by highlighting it above and using (on Windows) Ctrl+C and Ctrl+V.
This is the code for the order status codes that will be displayed in the combo box. Notice that the strings enclosed in quotes appear in one color and that the comment line appears in another. As with the brace matching, you can change these settings in the Syntax Colors page of the Preferences dialog. To work with Java syntax highlighting, in the Category list, select Java.
From the main menu, choose File | Save All to save your changes before continuing.
Next, you will create an event so that when the user clicks OK, the message associated with the status code is displayed.