Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.lang.java.gui > #5506
| From | Knute Johnson <nospam@rabbitbrush.frazmtn.com> |
|---|---|
| Newsgroups | comp.lang.java.gui |
| Subject | Re: Dynamic updation of a JTextArea |
| Date | 2016-12-14 15:46 -0600 |
| Organization | A noiseless patient Spider |
| Message-ID | <o2seh4$kim$1@dont-email.me> (permalink) |
| References | <0f003cf3-2058-4286-8669-a75fe3f116c3@googlegroups.com> <o2rnhu$sgf$1@dont-email.me> <c2b384b1-c28a-4c72-a742-543c638ef654@googlegroups.com> <89366421-9545-42ed-8d8e-b960310c1047@googlegroups.com> <o2scne$ect$1@dont-email.me> |
On 12/14/2016 15:15, Knute Johnson wrote:
> On 12/14/2016 10:47, abhprk3926@gmail.com wrote:
>> clientChat.ta is the common textarea for appending the messages.
>>
>
> It's not clear to me from the pieces of your code that I have seen how
> this actually is supposed to function. But that is really irrelevant,
> what we need here is an SSCCE (see http://sscce.org).
>
> What I have seen of your code though does have some problems. It would
> be good if you could provide the version of Java that you are using and
> whether the text area you are writing to is a JTextArea, an AWT TextArea
> or a JavaFX TextArea, all have different requirements for threading issues.
>
Well you did say JTextArea in the subject. So all of the calls in that
last bit you sent where things are enabled and set editable, needs to be
done on the EDT.
If you are using Java 8 you can simplify that code considerably.
Instead of:
something.addActionListener(new ActionListener() {
public void ActionPerformed(ActionEvent ae) {
new Thread(new Runnable() {
public void run() {
you can use:
something.addActionListener(ae -> {
new Thread(() -> {
To run code on the EDT:
EventQueue.invokeLater(() -> {
// this code is run on EDT
});
--
Knute Johnson
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar
Dynamic updation of a JTextArea abhprk3926@gmail.com - 2016-12-14 06:16 -0800
Re: Dynamic updation of a JTextArea Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-12-14 09:14 -0600
Re: Dynamic updation of a JTextArea abhprk3926@gmail.com - 2016-12-14 08:44 -0800
Re: Dynamic updation of a JTextArea abhprk3926@gmail.com - 2016-12-14 08:47 -0800
Re: Dynamic updation of a JTextArea Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-12-14 15:15 -0600
Re: Dynamic updation of a JTextArea Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-12-14 15:46 -0600
Re: Dynamic updation of a JTextArea abhprk3926@gmail.com - 2016-12-14 14:09 -0800
Re: Dynamic updation of a JTextArea abhprk3926@gmail.com - 2016-12-14 14:09 -0800
Re: Dynamic updation of a JTextArea Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-12-14 16:23 -0600
Re: Dynamic updation of a JTextArea Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-12-14 16:24 -0600
Re: Dynamic updation of a JTextArea abhprk3926@gmail.com - 2016-12-15 00:18 -0800
Re: Dynamic updation of a JTextArea Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-12-15 14:58 -0600
Re: Dynamic updation of a JTextArea abhprk3926@gmail.com - 2016-12-16 02:23 -0800
csiph-web