请完成下列Java程序;实现JComboBox,包含3个选项,分别是java、c++、vb,以及1个文本区,用于显示选择结果。注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。源程序文件代码清单如下:import java.awt.event.*;import javax.swing.*;import java.awt.*;public class ex14_2 extends JFrame. implements ItemListener{BorderLayout bLay = new BorderLayout();JTextField jtf = new JTextField(27);JComboBox jcb = new JComboBox();public ex14_2(){super ("ex14_2");//调用当前类ex14_2的父类JFrame的构造方法。jcb.addItemListener(this);jcb.addItem("java");jcb.addItem("c++");jcb.addItem("vb");jcb.setEditable(false);jtf.setHorizontalAlignment(SwingConstants.CENTER);jtf.setEditable(false);JPanel jp = new JPanel();jp.setLayout(bLay);jp.add(jtf, "South");jp.add(jcb, "Center");setContentPane(jp);}public static void main(String[] args){JFrame. frame. = new ex14_2();frame.pack();frame.setVisible(true);}public void itemStateChahged(ItemEvent ie){Object o =if (o == job){Object newO;______;jtf.setText(newO.toString()+"被选中!");}repaint();}}
请完成下列Java程序;实现JComboBox,包含3个选项,分别是java、c++、vb,以及1个文本区,用于显示选择结果。
注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。
源程序文件代码清单如下:
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class ex14_2 extends JFrame. implements ItemListener
{
BorderLayout bLay = new BorderLayout();
JTextField jtf = new JTextField(27);
JComboBox jcb = new JComboBox();
public ex14_2()
{
super ("ex14_2");//调用当前类ex14_2的父类JFrame的构造方法。
jcb.addItemListener(this);
jcb.addItem("java");
jcb.addItem("c++");
jcb.addItem("vb");
jcb.setEditable(false);
jtf.setHorizontalAlignment(SwingConstants.CENTER);
jtf.setEditable(false);
JPanel jp = new JPanel();
jp.setLayout(bLay);
jp.add(jtf, "South");
jp.add(jcb, "Center");
setContentPane(jp);
}
public static void main(String[] args)
{
JFrame. frame. = new ex14_2();
frame.pack();
frame.setVisible(true);
}
public void itemStateChahged(ItemEvent ie)
{
Object o =
if (o == job)
{
Object newO;
______;
jtf.setText(newO.toString()+"被选中!");
}
repaint();
}
}