BrownBird Posted September 29, 2014 Share Posted September 29, 2014 So what I want to do is I have a GUI made up that and the user can choose to loot 6 different items. So, if they want to loot items 1-4 they choose those items, but how would I generate a list in String format so the getItems.closest(lootItem); can read it.. I currently am using an ArrayList to get a list of items but the method can't read it Link to comment Share on other sites More sharing options...
Swizzbeat Posted September 29, 2014 Share Posted September 29, 2014 String[] arrayLoot = list.toArray(new String[list.size()]); 1 Link to comment Share on other sites More sharing options...
Joseph Posted September 29, 2014 Share Posted September 29, 2014 If you make a jlist fast it with an object type, allow multiple selection, you could get an array of selected indexes or object you're if you casted it Link to comment Share on other sites More sharing options...
BrownBird Posted September 29, 2014 Author Share Posted September 29, 2014 String[] arrayLoot = list.toArray(new String[list.size()]); I have this but it still won't pick up any loot at all.. If you make a jlist fast it with an object type, allow multiple selection, you could get an array of selected indexes or object you're if you casted it I have made my own GUI (interactable paint) so can I still use this mehthod? Link to comment Share on other sites More sharing options...
Swizzbeat Posted September 29, 2014 Share Posted September 29, 2014 I have this but it still won't pick up any loot at all.. I have made my own GUI (interactable paint) so can I still use this mehthod? Then there's another issue besides creating the array. Most likely you haven't configured the GUI correctly to configure the users loot selections. Link to comment Share on other sites More sharing options...
BrownBird Posted September 29, 2014 Author Share Posted September 29, 2014 Then there's another issue besides creating the array. Most likely you haven't configured the GUI correctly to configure the users loot selections. This is what I've got: Var: ArrayList<String> itemLoot = new ArrayList<String>(); String[] lootItem = new String[itemLoot.size()]; Method: GroundItem loot = groundItems.closest(lootItem); GUI: if(law) { g.drawImage(img5, 48, 201, null); String l1 = "Law rune"; itemLoot.add(l1); } if(death) { g.drawImage(img5, 48, 221, null); String l2 = "Death rune"; itemLoot.add(l2); } if(nature) { g.drawImage(img5, 48, 242, null); String l3 = "Nature rune"; itemLoot.add(l3); } if(chaos) { g.drawImage(img5, 48, 262, null); String l4 = "Chaos rune"; itemLoot.add(l4); } if(bones){ g.drawImage(img5, 48, 281, null); String l5 = "Big bones"; itemLoot.add(l5); } Link to comment Share on other sites More sharing options...
Joseph Posted September 30, 2014 Share Posted September 30, 2014 This is what I've got: Var: ArrayList<String> itemLoot = new ArrayList<String>(); String[] lootItem = new String[itemLoot.size()]; Method: GroundItem loot = groundItems.closest(lootItem); GUI: if(law) { g.drawImage(img5, 48, 201, null); String l1 = "Law rune"; itemLoot.add(l1); } if(death) { g.drawImage(img5, 48, 221, null); String l2 = "Death rune"; itemLoot.add(l2); } if(nature) { g.drawImage(img5, 48, 242, null); String l3 = "Nature rune"; itemLoot.add(l3); } if(chaos) { g.drawImage(img5, 48, 262, null); String l4 = "Chaos rune"; itemLoot.add(l4); } if(bones){ g.drawImage(img5, 48, 281, null); String l5 = "Big bones"; itemLoot.add(l5); } alright is there anything wrong with it? seems good Link to comment Share on other sites More sharing options...
BrownBird Posted September 30, 2014 Author Share Posted September 30, 2014 That's why I'm getting confused Link to comment Share on other sites More sharing options...
Swizzbeat Posted September 30, 2014 Share Posted September 30, 2014 This is what I've got: Var: ArrayList<String> itemLoot = new ArrayList<String>(); String[] lootItem = new String[itemLoot.size()]; Method: GroundItem loot = groundItems.closest(lootItem); GUI: if(law) { g.drawImage(img5, 48, 201, null); String l1 = "Law rune"; itemLoot.add(l1); } if(death) { g.drawImage(img5, 48, 221, null); String l2 = "Death rune"; itemLoot.add(l2); } if(nature) { g.drawImage(img5, 48, 242, null); String l3 = "Nature rune"; itemLoot.add(l3); } if(chaos) { g.drawImage(img5, 48, 262, null); String l4 = "Chaos rune"; itemLoot.add(l4); } if(bones){ g.drawImage(img5, 48, 281, null); String l5 = "Big bones"; itemLoot.add(l5); } Things not pertaining to your question: Program to the interface (ArrayList -> List) Your variable naming is terrible plus they're singular when they're representing a multitude of items Those if statements are disgusting and impossible to maintain. Create an enum of whatever your checking for (loot, runes, idk), assign the constants their corresponding properties, iterate over all the enum values in a clean for-each loop and execute your handler code On topic: Log whether your ground item instance is null, make sure the item name is correct, confirm whatever code your using to interact with the item is being executed, etc. There are lots of factors at play here that you're not telling us about. Link to comment Share on other sites More sharing options...