java - Target JTextArea Wrapped in JScrollPane in Hashmap Styling Loop -
java - Target JTextArea Wrapped in JScrollPane in Hashmap Styling Loop -
given i've got jtextarea wrapped in jscrollpane, , hashmap total of jscrollpanes:
protected static jtextarea jta1 = new jtextarea(); protected static jscrollpane jts1 = new jscrollpane(jta1, jscrollpane.vertical_scrollbar_as_needed, jscrollpane.horizontal_scrollbar_never); public static hashtable<integer, jscrollpane> textareas = new hashtable<integer, jscrollpane>(); textareas.put(1, jts1);
how can style inner jtextarea , outer jscrollpane in same for
loop hashmap has jscrollpanes included?:
for (jscrollpane item : textareas.values()) { item.setpreferredsize(new dimension(540, 200)); // jscrollpane item.setlinewrap(true); // jtextarea attribute <---- item.setborder(borderfactory.creatematteborder(1, 1, 1, 1, settings.site_orange)); // jscrollpane }
i have no problem targeting outer jscrollpane jtextarea wrapping in, item.setlinewrap(true)
applies inner jtextarea how can select it? can't cast jtextarea ((jtextarea) item).setlinewrap(true);
, tried first.
you have access viewport using getviewport() method on jscrollpane phone call getview() method on returned jviewport, component returned should jtextarea, need cast component jtextarea able phone call setlinewrap on it
((jtextarea) item.getviewport().getview()).setlinewrap(true)
java swing jscrollpane jtextarea
Comments
Post a Comment