Hello I have a game where you can have a shop and buy stuff. when you press enter the shop stock menu opens. I want to be able to show all of the items available and I want to be able to scroll threw them all with a jscrollpane or jscrollbar. I don't know how I would approach this please help me and please don't take this question down mods and admins because tis will be very helpful for me. here is my code if you need to see it:
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JScrollPane;
public class stock {
static Image img;
public static int money = 1000;
public static ArrayList<item> item = new ArrayList<item>();
public static JScrollPane j = new JScrollPane();
public static void tick(){
if(Keys.isPressed(Keys.ESCAPE)){
options.stockopen = false;
}
for (int i = 0; i < item.toArray().length; i++) {
item.get(i).tick();
}
item.add(new item(200,100,8,"Melon"));
item.add(new item(200,150,2,"Bread"));
item.add(new item(200,200,1,"Milk"));
}
public static void render(Graphics g){
ImageIcon i2 = new ImageIcon("res/stockscreen.png");
img = i2.getImage();
g.drawImage(img,0,0, null);
g.setColor(Color.yellow);
g.setFont(new Font("italic", Font.BOLD, 20));
g.drawString("€ "+money, 13, 30);
for (int i = 0; i < item.toArray().length; i++) {
item.get(i).render(g);
//if (item.get(i).isrem) {
//}
}
}
}