求助JAVA高手,JTabbedPane默认选中的是0标签,让其默认选中为1?

内部窗口有JTabbedPane,有两个标签;我想通过外部的两个不同的按钮监听,直接进入内部窗口对应的标签... 内部窗口有JTabbedPane,有两个标签;
我想通过外部的两个不同的按钮监听,直接进入内部窗口对应的标签
展开
 我来答
匿名用户
2016-07-02
展开全部
import java.io.*;
import java.util.*;
public class Exam3_2 {
public static void main(String[] args) {
if(args.length != 1){
System.out.println("参数数量错误,必须是一个参数");
return;
}
String fileName = "h:\\roster.dat";
RandomAccessFile file;
String temp;
String[] arr;
int i;
double avg;
Student1 stu;
ArrayList list = new ArrayList();

try {
file = new RandomAccessFile(fileName,"r");
while((temp = file.readLine()) != null){
arr = temp.split(" ");
for(i=2, avg=0; i<arr.length; i++){
avg += Integer.parseInt(arr[i]);
}
avg /= 4;
stu = new Student1(arr[0], arr[1], Integer.parseInt(arr[2]), Integer.parseInt(arr[3]), Integer.parseInt(arr[4]),Integer.parseInt(arr[5]), avg);
list.add(stu);
}
file.close();
}
catch (Exception e) {
e.printStackTrace();
}

if(args[0].equals("n")){
Collections.sort(list, new Comparator<Student1>(){
@Override
public int compare(Student1 stu1, Student1 stu2) {
return stu1.getLastName().compareTo(stu2.getLastName());
}
});
}
else if(args[0].equals("s")){
Collections.sort(list, new Comparator<Student1>(){
@Override
public int compare(Student1 stu1, Student1 stu2) {
return stu1.getAvg().compareTo(stu2.getAvg());
}
});
}
else{
System.out.println("参数类型错误,必须'n'或's'");
return;
}
System.out.println("firstname\tlastname\tscore1\tscore2\tscore3\tscore4\tavg");
for(i=list.size()-1; i>=0; i--){
System.out.println(((Student1)list.get(i)).toString());
}
}
}
class Student1{
protected String firstName;
protected String lastName;
protected int score1;
protected int score2;
protected int score3;
protected int score4;
protected double avg;

public Student1(){
}

public Student1(String firstName, String lastName, int score1, int score2, int score3, int score4, double avg2){
this.firstName = firstName;
this.lastName = lastName;
this.score1 = score1;
this.score2 = score2;
this.score3 = score3;
this.score4 = score4;
this.avg = avg2;
}

public String getLastName(){
return this.lastName;
}

public Double getAvg(){
return this.avg;
}

public String toString(){
return firstName + "\t" + lastName + "\t" + score1 + "\t" + score2 + "\t" + score3 + "\t" + score4 + "\t" + avg;
匿名用户
2016-07-02
展开全部
<html>
<head>
</head>
<select id="ss">
<option >aa</option>
<option >aa1</option>
<option >aa2</option>
</select>
<body>
<script >
var ss = document.getElementById('ss');
ss[2].selected = true;//选中
</script>
</html>
追问
不在JS中,在JAVA中怎么实现呢?
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式