📄 resultarea.java
字号:
import java.awt.*;
public class ResultArea extends Panel
{
PersonSelected personSelected[];
TextArea text;
ResultArea(PersonSelected personSelected[])
{
this.personSelected=personSelected;
text=new TextArea(12,40);
text.setText(null);
add(text);
}
public void setPersonSelected(PersonSelected personSelected[])
{
text.setText(null);
String str[]=new String[personSelected.length];
int count[]=new int[personSelected.length];
for(int k=0;k<str.length;k++)
{
str[k]=personSelected[k].getName();
count[k]=personSelected[k].getCount();
}
for(int k=0;k<str.length;k++)
{
for(int i=k+1;i<str.length;i++)
if(count[i]>count[k])
{
String temp=str[k];
int n=count[k];
str[k]=str[i];
str[i]=temp;
count[i]=n;
}
}
for(int k=0;k<str.length;k++)
{
text.append("\n"+str[k]+"得票:"+count[k]);
}
validate();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -