So, I’m trying to create a kind of text editor for creating question lists. I’m unsure how to achieve that.
What I came up with until now is to create a JPanel which represents an A4 piece of paper. Then, I’d like to create maybe another JPanel which would contain several textboxes in which question/answers would be typed in. The problem is that I’d like to be able to add/remove questions from anywhere within my “document”. Doing it with arrays would be tedious and I’d survive that, but the main issue would be fixed array size.
My question is, is there any way to create some kind of dynamic list and what would be a way to go in my case? It’s also important to be able to pinpoint a certain “question” JPanel by simply invoking any of its textboxes (because clicking a textbox and pressing a combination of keys would add another question after the invoked one, at least that’s the plan).
Anyone?
Try using the
collections, fromjava.util.collectionpackage.1. If every question you create has a unique identifier attached to it, then try to use
Map, where let anIntegerbe your unique identifier andStringmay be the question2. If you are storing the question is in
sequence,Listmay also suffice.List<String> list = ArrayList<String>();