小编Luk*_*oni的帖子

如何更改鼠标上的图标?

我有白色图标,当我查看该图标时,我想要制作不同的颜色.

这是我的白色图标:

hint.setIcon(newjavax.swing.ImageIcon(getClass().getResource ("white.png")));
Run Code Online (Sandbox Code Playgroud)

当您将鼠标拖到图标上以更改颜色时,我该怎么做?

java mouse icons swing mouseover

2
推荐指数
1
解决办法
4137
查看次数

随机的颜色序列

如何选择一张不能重复的图片?

我试过这个:

我使用随机,我想删除所选的图片

String[] picture = { "blue", "white", "red", "yellow" };

   int number_picture1; 

// Random function to find a random picture

   Random ran = new Random();

   number_picture1 = ran.nextInt(picture.length);

System.out.println(picture[number_picture1]);

// There is still posibility to chose the same picture

   int number_picture2; 

   number_picture2 = ran.nextInt(picture.length);

System.out.println(picture[number_picture2]);
Run Code Online (Sandbox Code Playgroud)

java

1
推荐指数
1
解决办法
174
查看次数

如何从最小到最大数字对数字进行排序 - Java?

我如何将数字保存在列表中,我可以在其中从最小到最大排序。我创建了新字符串,我在其中插入了所有数字。比我进入 List 并对其进行排序。之后我检查一个数字,我得到颜色 od 图标。

我试过这个:

import java.util.Collections;
import java.util.ArrayList;
import java.io.*;

int colour1 = 1;
int colour2 = 3;
int colour3 = 2;
int colour4 = 3;

String rezerva =colour1, colour2, colour3, colour4;
List<String> myList = new ArrayList(rezerva);
Collections.sort(myList);

colour1 = myList.get(0);

if (colour1==1){
//change icon to red
}
else if (colour1==2){
//change icon to white
}
else {
//change icon to black
}
Run Code Online (Sandbox Code Playgroud)

java arrays sorting collections arraylist

1
推荐指数
1
解决办法
2659
查看次数

标签 统计

java ×3

arraylist ×1

arrays ×1

collections ×1

icons ×1

mouse ×1

mouseover ×1

sorting ×1

swing ×1