Java小白一个CMD编译报错使用了未经检查或不安全的操作~求各位大佬指点一下帮看看~代码如下
1个回答
展开全部
import java.awt.GridLayout;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
public class Test31 extends JFrame{
private static final long serialVersionUID = 1L;
JLabel bq1,bq2;
JPanel mb1,mb2;
JComboBox<String> xlk;
JList<String> lb;
JScrollPane gd;
public Test31() {
mb1=new JPanel();
mb2=new JPanel();
bq1=new JLabel("籍贯");
bq2=new JLabel("学历");
String []jg= {"上海","天津","北京","湖南"};
xlk =new JComboBox<>(jg);
String []xj= {"大学","高中","初中","小学"};
lb = new JList<>(xj);
lb.setVisibleRowCount(3);
gd = new JScrollPane(lb);
this.setLayout(new GridLayout(2,1));
mb1. add(bq1);
mb1. add(xlk);
mb2. add(bq2);
mb2. add(gd);
this.add(mb1);
this.add(mb2);
this.setTitle("用户界面");
this.setSize(240, 200);
this.setLocation(300,250);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String[] args) {
@SuppressWarnings("unused")
Test31 q = new Test31();
}
}
//该加的泛型没有加,定义的类也没有使用,所以会有警告,但这都不影响程序的正常运行
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
public class Test31 extends JFrame{
private static final long serialVersionUID = 1L;
JLabel bq1,bq2;
JPanel mb1,mb2;
JComboBox<String> xlk;
JList<String> lb;
JScrollPane gd;
public Test31() {
mb1=new JPanel();
mb2=new JPanel();
bq1=new JLabel("籍贯");
bq2=new JLabel("学历");
String []jg= {"上海","天津","北京","湖南"};
xlk =new JComboBox<>(jg);
String []xj= {"大学","高中","初中","小学"};
lb = new JList<>(xj);
lb.setVisibleRowCount(3);
gd = new JScrollPane(lb);
this.setLayout(new GridLayout(2,1));
mb1. add(bq1);
mb1. add(xlk);
mb2. add(bq2);
mb2. add(gd);
this.add(mb1);
this.add(mb2);
this.setTitle("用户界面");
this.setSize(240, 200);
this.setLocation(300,250);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String[] args) {
@SuppressWarnings("unused")
Test31 q = new Test31();
}
}
//该加的泛型没有加,定义的类也没有使用,所以会有警告,但这都不影响程序的正常运行
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询