如何解决这个问题?

时间:2017-06-08 08:19:05

标签: java swing

this is my code
package pack;
import java.awt.*;
import javax.swing.*;
public class MySwing
{
MySwing()
{

    JFrame.setDefaultLookAndFeelDecorated(true);
JFrame f = new JFrame("This is my Frame");
JTabbedPane jtb= new JTabbedPane();
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JPanel p3 = new JPanel();jtb.addTab("employee Info", p1);
jtb.addTab("employee Dept", p2); jtb.addTab("employee Salary", p3);
f.add(jtb);
JLabel l = new JLabel("User Name");
l.setForeground(Color.blue);
JTextField tf = new JTextField(20); tf.setFont(new Font("Coronet",Font.BOLD,20));
tf.setHorizontalAlignment(JTextField.RIGHT); tf.setBackground(Color.black);
tf.setForeground(Color.yellow);
JLabel l1 = new JLabel("Password: ");
JPasswordField pf = new JPasswordField(20);
JTextArea ta = new JTextArea(10,20);
JScrollPane sp = new JScrollPane(ta); 
String str[]={"select the city","Noida","Delhi","Faridabad"};
JComboBox c= new JComboBox(str);
JList li = new JList(str);
JCheckBox cb1= new JCheckBox("I.Sc",true);
JCheckBox cb2= new JCheckBox("B.Sc"); JCheckBox cb3= new JCheckBox("M.Sc");

    ButtonGroup cbg = new ButtonGroup(); JRadioButton cb4= new JRadioButton("Male",true);
JRadioButton cb5= new JRadioButton("Female",false);
cbg.add(cb4);cbg.add(cb5);
JButton b = new JButton("save");
p1.add(l);p1.add(tf);p1.add(l1);p1.add(pf);p2.add(sp);p2.add(c);p2.add(li);p2.add(cb1);p2.add(cb2);p2.add(cb3);
p3.add(cb4);p3.add(cb5);p3.add(b);
f.setSize(600,400); f.setLocation(200,100);
f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String arg[])
{

    new MySwing();
}
}

这是问题所在 MySwing.java使用未经检查或不安全的操作 使用-xlint重新编译:取消选中以获取详细信息 帮我解决这个问题 这不是错误 但是我的系统没有运行它 解决它

1 个答案:

答案 0 :(得分:1)

首先你可以做

JComboBox<String> c= new JComboBox<String> (str);
JList<String> li = new JList<String>(str);

了解泛型