Tag Archives: list

Java KeyListener stutters

Questions: I’m making a very simple pong game in java and I’m doing this using KeyListener. I want it so when the user presses the right or left keys on the keypad, the pong block goes in that direction. This is a simple enough task, but what I’m finding out is that when the user… Read More »

Difference between List and Array [duplicate]

Questions: Possible Duplicate: Primitive Array vs ArrayList What is the difference between List and Array in java? or the difference between Array and Vector! Answers: In general (and in Java) an array is a data structure generally consisting of sequential memory storing a collection of objects. List is an interface in Java, which means that… Read More »

Randomly select an item from a list

Questions: How can I randomly select an item from a list in java? eg. I have List<String> list = new ArrayList<String>(); list.add(“One”); list.add(“Two”); etc…. How can I randomly select from this list using the Random myRandomizer = new Random(); Answers: Something like this? Random randomizer = new Random(); String random = list.get(randomizer.nextInt(list.size())); Questions: Answers: Clean… Read More »

ActionListener for a specific text inside a JTextArea?

Questions: I have in my app a chat component which has a JTextArea on it. Now, how can I add an ActionListener-like event for a specific text (like student://xxxx)? So when I click on that text (student://xxxx) something will happen. Thank you. Answers: Here try this small program, try to click at the start of… Read More »

How can I get a list of trusted root certificates in Java?

Questions: I would like to be able to get access to all trusted root certificates programmatically in a Java app. I was looking at the keystore interface, but I’m hoping to get the list of trusted roots that’s implicit with the JRE. Is this accessible anywhere? Answers: There’s an example at Example Depot that shows… Read More »

ArrayList contains case sensitivity

Questions: I am currently using the contains method belonging to the ArrayList class for making a search. Is there a way to make this search case insensitive in java? I found that in C# it is possible to use OrdinalIgnoreCase. Is there a java equivalent, or another way to do this? Thanks. Answers: You can… Read More »

Java key listener to track all keystrokes [closed]

Questions: I want to build a key listener in Java as part of my project. It should track all the key presses pressed in every window. Is it possible to make such a thing? In all windows and all programs. Answers: http://ksquared.de/blog/releases/stable/keyboard_hook-0.3.zip This link contains the required source codes and binaries. You can get a… Read More »