0
如何存儲圖形的ArrayList以便我可以在特定的ArrayList位置上調用drawString()命令?圖形的Java數組列表
例如,這是我想要的東西,但沒有代碼的工作:(
ArrayList<Graphics> list= new ArrayList<Graphics>();
//create a certain number of graphics
for (int i = 0; i < 5; i++) {
list.add(new Graphics[i] = null);
}
//run drawString on a certain array value independently of the others
((Graphics) columns.get(2)).drawString("v", 50, 50);
((Graphics) columns.get(4)).drawString("xx", 10, 100);
通常情況下,您會從Panel或BufferedImage等對象中獲取圖形,而不是使用構造函數創建它。另外,您似乎將圖形陣列存儲在該列表中。爲什麼你想要一堆圖形,而不是一個? –
因爲我想一次在屏幕上顯示多個文本,因此多個圖像。但是我想自己移動每一段文本,因此也是這個數組。 – Ricco