자바 랭킹 프로그램 좀 도와주세요
조회수 1616회
public class rank extends JFrame{
static int maxX = 300, maxY = 300, ox = 0, oy = 30, width = 40, height = 20,count;
JLabel lb[]=new JLabel[5]; JLabel lc[]=new JLabel[5]; JPanel pan;
public rank() {
setTitle("랭킹");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setBounds(1200,250,500,500);
setVisible(true);
for(int i=0;i<5;i++){
lb[i]=new JLabel(i+1+"등");
lc[i]=new JLabel(0+"초");
}
setLayout(null);
setFont(new Font("Monospaced",Font.BOLD,12));
setBounds(400, 250, 150, 600); lb[0].setBounds(10, 20, width, height); lb[0].setOpaque(true); add(lb[0]); lb[1].setBounds(10, 50, width, height); lb[1].setOpaque(true); add(lb[1]); lb[2].setOpaque(true); lb[2].setBounds(10, 80, width, height); add(lb[2]); lb[3].setOpaque(true); lb[3].setBounds(10, 110, width, height); add(lb[3]); lb[4].setOpaque(true); lb[4].setBounds(10, 140, width, height); add(lb[4]);
lc[0].setBounds(60, 140, 70, height);
lc[1].setBounds(60, 110, 70, height);
lc[2].setBounds(60, 80, 70, height);
lc[3].setBounds(60, 50, 70, height);
lc[4].setBounds(60, 20, 70, height);
float[] arry = new float[5];
for(int i = 0; i < 5; i++)
{
arry[i]=ButtonMove.time[i]; }
for (int i = 0; i < arry.length; i++) { for (int j = i + 1; j < arry.length; j++) { if (arry[i] > arry[j]) { float tmep = arry[i]; arry[i] = arry[j]; arry[j] = tmep; } } }
Arrays.sort(arry);
for(int i = 0; i < arry.length; i++){
lc[i].setOpaque(true);
add(lc[i]);
lc[i].setText(arry[i]+"초");
}
}}
저는 초가 낮은 배열부터
1등 1초
2등 2초 위에 ButtonMove.time[]이 시간을 받아오는 변수에요 다른클래스에서
이런식으로 하고싶은데 자꾸 더큰숫자가 위로올라가네요 ...ㅜㅜㅜㅜ 오늘안에 도움받고싶네요..
-
(•́ ✖ •̀)
알 수 없는 사용자
댓글 입력