posted 8 years ago
@OP
What is it that you have in mind? At first I thought you wanted to create a JPanel
with a gridlayout, N x M in size. Well, to me that is what I would expect
from a GUI representing a crossword puzzle.
If that is indeed the goal, then I fail to see how you would achieve this by using
a textfield, or a textarea. Maybe you, or other people that suggested similar,
can explain that to me.
My advice is what I already wrote above. In each cell of the grid, you place a JLabel.
Attach a mouselistener to each label, its only task being to register which label
has the so called 'input focus'.
To the panel, attach a keylistener. When a key is typed, put the text of the 'input
focus' jlabel equal to the key. If arrow keys are typed, then adjust the input focus
label.
Unwritable labels are excluded from above. No mouse listener, unable to
gain the input focus, and with a black or so background.
This is the easiest I can think of.
Greetz,
Piet
There are three kinds of actuaries: those who can count, and those who can't.