Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #28182
| From | markspace <markspace@nospam.nospam> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Java Swing text as a grid? |
| Date | 2014-04-22 08:22 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <lj61gl$1fp$1@dont-email.me> (permalink) |
| References | <8c3ea48c-26d5-4ef8-869b-08f46023b953@googlegroups.com> |
On 4/22/2014 7:50 AM, rupertlssmith@googlemail.com wrote:
> Hi,
>
> I'd like a text UI component that lets me place monospaced text
> within it, using row/column addressing. The built-in text controls
I would just keep a separate structure, an array of lines, and then
index into that.
public class MyTextArray {
private JTextArea text = ...
private ArrayList<String> lines = ...
public void addText( String line ) {
lines.add( line );
text.add( line );
}
public char get( int row, int column ) {
if( row > lines.size() ) throw new IllegalArgumentException();
String s = lines.get( row );
if( column >= s.length() ) throw new IllegalArgumentException();
return s.charAt( column );
}
}
Flavor to taste.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Java Swing text as a grid? rupertlssmith@googlemail.com - 2014-04-22 07:50 -0700
Re: Java Swing text as a grid? markspace <markspace@nospam.nospam> - 2014-04-22 08:22 -0700
Re: Java Swing text as a grid? Jeff Higgins <jeff@invalid.invalid> - 2014-04-22 11:45 -0400
Re: Java Swing text as a grid? Jeff Higgins <jeff@invalid.invalid> - 2014-04-22 15:03 -0400
Re: Java Swing text as a grid? Rupert Smith <rupertlssmith@googlemail.com> - 2014-04-23 00:56 -0700
Re: Java Swing text as a grid? Roedy Green <see_website@mindprod.com.invalid> - 2014-04-23 19:49 -0700
Re: Java Swing text as a grid? Rupert Smith <rupertlssmith@googlemail.com> - 2014-04-25 02:13 -0700
Re: Java Swing text as a grid? Arne Vajhøj <arne@vajhoej.dk> - 2014-04-28 20:26 -0400
csiph-web