The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

// Set keyboard mnemonics
jbtLeft.setMnemonic('L'); // When a key is pressed on the keyboard,
//only the menu item that has the mnemonic matching the pressed key will fire an action event.
jbtRight.setMnemonic('R');

/** 1.Add a text field labeled “New Message.\uFFFD
* Upon typing a new message in the text field and pressing the Enter
* key, the new message is displayed in the message panel.
*/
jpButtons.add(new JLabel("Enter a new message"));
jpButtons.add(jtfNewMessage);

jtfNewMessage.addActionListener(this);

/** 2. Add a combo box label “Interval\uFFFD that enables the user to select a
* new interval for moving the message. The selection values range from
* 10 to 100 with interval 5. The user can also type a new
* interval in the combo box.
*/
jpButtons.add(new JLabel("Select an interval"));
jpButtons.add(jcboInterval);
for (int interval = 5; interval <= 100; interval += 5) {
jcboInterval.addItem(interval + "");
}

jcboInterval.addActionListener(this);

/**
* 3. Add three radio buttons that enable the user to select the foreground
* color for the message as Red, Green, and Blue.
*/
JPanel panel = new JPanel();
getContentPane().add(panel, BorderLayout.NORTH);