Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #3502 > unrolled thread

How to display text messa

Started by"ram" <ram@THRWHITE.remove-dii-this>
First post2011-04-27 15:45 +0000
Last post2011-04-27 15:45 +0000
Articles 8 — 3 participants

Back to article view | Back to comp.lang.java.gui


Contents

  How to display text messa "ram" <ram@THRWHITE.remove-dii-this> - 2011-04-27 15:45 +0000
    Re: How to display text m "Jeff Higgins" <jeff.higgins@THRWHITE.remove-dii-this> - 2011-04-27 15:45 +0000
      Re: How to display text m "ram" <ram@THRWHITE.remove-dii-this> - 2011-04-27 15:45 +0000
        Re: How to display text m "Jeff Higgins" <jeff.higgins@THRWHITE.remove-dii-this> - 2011-04-27 15:45 +0000
      Re: How to display text m "ram" <ram@THRWHITE.remove-dii-this> - 2011-04-27 15:45 +0000
        Re: How to display text m "Jeff Higgins" <jeff.higgins@THRWHITE.remove-dii-this> - 2011-04-27 15:45 +0000
          Re: How to display text m "ram" <ram@THRWHITE.remove-dii-this> - 2011-04-27 15:45 +0000
    Re: How to display text m "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:45 +0000

#3502 — How to display text messa

From"ram" <ram@THRWHITE.remove-dii-this>
Date2011-04-27 15:45 +0000
SubjectHow to display text messa
Message-ID<text-area-20080515203241@ram.dialup.fu-berlin.de>
  To: comp.lang.java.gui
  To display text messages (as - for example - in a window with
  log messages) in a scrolling text area, there are several
  Swing components I am aware of:

http://download.java.net/jdk7/docs/api/javax/swing/JTextArea.html
http://download.java.net/jdk7/docs/api/javax/swing/JTextPane.html
http://download.java.net/jdk7/docs/api/javax/swing/JEditorPane.html

  I might want to subclass one of them for my +log area2. While
  I only think of plain text output now, more features, such as
  different typefaces or text colors might come in handy later.

  I also might want to use one of them in teaching, when showing
  how to display log messages in a GUI.
 
  It seems that JEditorPane has more features than the other two.
  So should I always use JEditorPane for such purposes, or are there
  any reasons to use one of JTextArea or JTextPane sometimes?

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [next] | [standalone]


#3505 — Re: How to display text m

From"Jeff Higgins" <jeff.higgins@THRWHITE.remove-dii-this>
Date2011-04-27 15:45 +0000
SubjectRe: How to display text m
Message-ID<ymbXj.194$Qo6.14@newsfe06.lga>
In reply to#3502
  To: comp.lang.java.gui

Stefan Ram wrote:
>  To display text messages (as - for example - in a window with
>  log messages) in a scrolling text area, there are several
>  Swing components I am aware of:
>
> http://download.java.net/jdk7/docs/api/javax/swing/JTextArea.html
> http://download.java.net/jdk7/docs/api/javax/swing/JTextPane.html
> http://download.java.net/jdk7/docs/api/javax/swing/JEditorPane.html
>
>  I might want to subclass one of them for my +log area2. While
>  I only think of plain text output now, more features, such as
>  different typefaces or text colors might come in handy later.
>

What about tabular log data?
<http://download.java.net/jdk7/docs/api/javax/swing/JTable.html>

>  I also might want to use one of them in teaching, when showing
>  how to display log messages in a GUI.

Follow the lesson plan?
Is this CS2101 The Java Language, or CS2202 Java Swing GUIs

>
>  It seems that JEditorPane has more features than the other two.
>  So should I always use JEditorPane for such purposes, or are there
>  any reasons to use one of JTextArea or JTextPane sometimes?

JTextArea has .getLineCount()
JEditorPane has .getHyperlinkListeners()
JTextPane has  .insertComponent(Component c)

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3507 — Re: How to display text m

From"ram" <ram@THRWHITE.remove-dii-this>
Date2011-04-27 15:45 +0000
SubjectRe: How to display text m
Message-ID<lesson-plan-20080516150519@ram.dialup.fu-berlin.de>
In reply to#3505
  To: comp.lang.java.gui
"Jeff Higgins" <oohiggins@yahoo.com> writes:
>Follow the lesson plan?
>Is this CS2101 The Java Language, or CS2202 Java Swing GUIs

  I am giving adult evening classes and am solely responsible
  for the lesson plan, so I do not have to follow anyone's
  lesson plan and can fit my own lesson plan to the interests
  and capabilities of the adult pupils of this adult education
  center.

  They are often beginners, and I do not have to treat a certain
  set of topics, so instead of giving an overview, I have chosen
  to teach just a few of the most fundamental aspects of the
  language, but then use enough time for each of those topics to
  do exercises until nearly everyone is able to apply it.

  My classes advance quite slowly and do cover only a small part
  of the language, but a high percentage of the pupils who
  attend the class will understand most of it, even if this is
  their first programming language.

  I will have a look at CS2101 and CS2202.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3512 — Re: How to display text m

From"Jeff Higgins" <jeff.higgins@THRWHITE.remove-dii-this>
Date2011-04-27 15:45 +0000
SubjectRe: How to display text m
Message-ID<cgkXj.22$705.9@newsfe07.lga>
In reply to#3507
  To: comp.lang.java.gui

Stefan Ram wrote:
> "Jeff Higgins" <oohiggins@yahoo.com> writes:
>>Follow the lesson plan?
>>Is this CS2101 The Java Language, or CS2202 Java Swing GUIs
>
>  I am giving adult evening classes and am solely responsible
>  for the lesson plan, so I do not have to follow anyone's
>  lesson plan and can fit my own lesson plan to the interests
>  and capabilities of the adult pupils of this adult education
>  center.

Maybe I should have said, The example code and assignments you
provide your class should follow the lesson plan.  Do you want
to have your students learn how to transform logger output to
styled text so that it may displayed in a styled text component?
From my experience there is no greater hindrance to learning than
unfocused examples and assignments.  For a example of a piss-poor
and unfocused assignment see the Purse and Coins assignment in a
recent c.l.j.? group discussion.

>
>  They are often beginners, and I do not have to treat a certain
>  set of topics, so instead of giving an overview, I have chosen
>  to teach just a few of the most fundamental aspects of the
>  language, but then use enough time for each of those topics to
>  do exercises until nearly everyone is able to apply it.
>
>  My classes advance quite slowly and do cover only a small part
>  of the language, but a high percentage of the pupils who
>  attend the class will understand most of it, even if this is
>  their first programming language.
>
>  I will have a look at CS2101 and CS2202.
>

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3508 — Re: How to display text m

From"ram" <ram@THRWHITE.remove-dii-this>
Date2011-04-27 15:45 +0000
SubjectRe: How to display text m
Message-ID<JTextPane-20080516164640@ram.dialup.fu-berlin.de>
In reply to#3505
  To: comp.lang.java.gui
"Jeff Higgins" <oohiggins@yahoo.com> writes:
>JTextArea has .getLineCount()

  OK, thanks! Apart from this operation it seems that
  overall JEditorPane and JTextPane are more powerful and
  high-level and thus often more simple to use than JTextArea.

  So it seems that usually to display text one would prefer
  JEditorPane or JTextPane. I still would appreciate if someone 
  knew even other examples than obtaining a count of lines
  for when to prefer JTextArea.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3511 — Re: How to display text m

From"Jeff Higgins" <jeff.higgins@THRWHITE.remove-dii-this>
Date2011-04-27 15:45 +0000
SubjectRe: How to display text m
Message-ID<B_hXj.9$%p3.7@newsfe02.lga>
In reply to#3508
  To: comp.lang.java.gui

Stefan Ram wrote:
> "Jeff Higgins" <oohiggins@yahoo.com> writes:
>>JTextArea has .getLineCount()
>
>  OK, thanks! Apart from this operation it seems that
>  overall JEditorPane and JTextPane are more powerful and
>  high-level and thus often more simple to use than JTextArea.
>

quoting from The Java Tutorials - Using Text Components

(JEditorPane - JTextPane)... "are powerful and multi-faceted components
suitable for high-end needs, and offer more avenues for customization
than the other text components. Because they are so powerful and flexible,
styled text components typically require more initial programming to set
up and use.
One exception is that editor panes can be easily loaded
with formatted text from a URL, which makes them useful
for displaying uneditable help information."

>  So it seems that usually to display text one would prefer
>  JEditorPane or JTextPane. I still would appreciate if someone
>  knew even other examples than obtaining a count of lines
>  for when to prefer JTextArea.
>

Prefer JTextArea for multi-line unstyled text.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3524 — Re: How to display text m

From"ram" <ram@THRWHITE.remove-dii-this>
Date2011-04-27 15:45 +0000
SubjectRe: How to display text m
Message-ID<JTextArea-20080517153019@ram.dialup.fu-berlin.de>
In reply to#3511
  To: comp.lang.java.gui
"Jeff Higgins" <oohiggins@yahoo.com> writes:
>than the other text components. Because they are so powerful and flexible,
>styled text components typically require more initial programming to set
>up and use.

  A JTextArea also has some more difficult aspects.

  For example, when one wants a line appended at the end to be
  visible (a common case), with a JTextArea in a JScrollpane,
  sometimes one needs to call +scrollRectToVisible2 with the
  offset of the last line, so one needs to call
  +getLineEndOffset(line)2, which sometimes might throw a
  BadLocationException, which also needs to be handled.

  But such boilerplate code does not matter that much when one
  is subclassing to get a custom log text area component from 
  a Swing text component, because it all can be written once 
  and then be hidden behind methods of the custom log component.

>Prefer JTextArea for multi-line unstyled text.

  JTextPane and JEditorPane also allow multi-line unstyled text,
  and when subclassing to get a custom log text window,
  boilerplate code needs only be written once (actually just
  copied from tutorials), so the difficulty to use does not
  matter that much.

  So I wonder, whether from the point of visible properties of
  the product (what one observes when the program with the log
  window is running), there would ever be a reason to prefer
  JTextArea above JTextPane or JEditorPane.

  For example, if JTextPane would be known to be slower than
  JTextArea, this would be such a reason.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3525 — Re: How to display text m

From"Roedy Green" <roedy.green@THRWHITE.remove-dii-this>
Date2011-04-27 15:45 +0000
SubjectRe: How to display text m
Message-ID<kuut245qf0kp95k31svgcvqa5theic6hv8@4ax.com>
In reply to#3502
  To: comp.lang.java.gui
On 15 May 2008 18:42:12 GMT, ram@zedat.fu-berlin.de (Stefan Ram)
wrote, quoted or indirectly quoted someone who said :

>  To display text messages (as - for example - in a window with
>  log messages) in a scrolling text area, there are several
>  Swing components I am aware of:

Another way is with a JTree.  Your treemodel need not keep all
non-visible messages in RAM.

See http://mindprod.com/jgloss/jtree.html
-- 

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web