To be able to map the sentence to a, say, JPanel , using GridLayout(1,0) [i.e. only one line / line], and then be able to draw a syntax tree (or similar) above it, I want to show the sentence as a string of String s, each of which contains one word.
Then a single String must be selected (as in the JList ), or I should at least get their location on the JPanel via getLocation() .
Until now, I tried the following options and had the following problems: - A single String like JLabel s: JLabel stretched to fill the width of the JPanel , reformatting them to match the single String that they display seems complicated. However, I would like to be able to do this so that the proposal looks like a proposal, and not like a poorly laid out table. - JList : all the functionality that I want, but I do not know about the ability to resize the "cells" of a single String (see JLabel above). Also, I am having difficulty limiting the JList display to one line / line (see another one of my questions ). - JTextArea : I couldn't figure out how to get the location of the only String that I added to JTextArea .
I know drawString() may be an option, but I'm afraid to use it since I don't want to mix AWT and Swing. In addition, I will need to calculate int values ββfor x and y for each String . And I'm not sure if I can get their locations at all (although I could, of course, save them int on a map or vector, since I still have to figure them out).
Thanks for any suggestions! Thanks!
source share