Re: JLabels Are Big



Jason Cavett wrote:
noticing is that JLabels chew up memory. If 20 or more tokens are
created (which is quite possible given the functionality of the
application), memory starts loading up and the application bogs down.

I agree with Daniel, 20 labels is not a lot. You likely have some other resource issue here. Better fix that first.


2. I could also write a JPanel of sorts and have it render its text
directly in the panel rather than through the JLabels. Then, when the
user clicked the JPanel, I would have to do the work to check where

This is more or less what I would do. Create your own java.awt.Component that just displays what you want. You might be able to subclass Image and then just draw the formula with Graphics2D operations, and then update in the usual way for Images.

However, you might check out JEditorPane. It might be possible to compose your formula in HTML, and then just use setText. HTML also might be more portable. JEditorPanes are already editable, so you might be able to leverage that instead of do the all the code for editing from mouse click and keyboard presses yourself.
.



Relevant Pages

  • Re: previous document in JEditorPane has lingering state, how to avoid that?
    ... I am using a JEditorPane to open plain text file and html file alternately. ... The "content type of this editor" referred to is determined by what you ...
    (comp.lang.java.programmer)
  • Re: chopping of string
    ... comments in HTML, as rendered by JEditorPane) ... of course the Java Glossary was in the top 5 hits, ... "This Page Is Valid HTML 4.01 Transitional!" ... how much/little screen space is devoted to it. ...
    (comp.lang.java.programmer)
  • Re: HyperlinkListener and < ahref="xy.html" target="framexy" >
    ... JEditorPane automatically installs an EditorKit based on the content-type ... I just tried displaying some FrameSets and it appears to work somewhat, ... errors when I tried to load the main J2SE JavaDocs. ... since I tried using a JEditorPane for serious HTML, ...
    (comp.lang.java.gui)
  • Re: JEditorPane: Enhancing...
    ... |>> You will find some horror stories. ... |> I also use JEditorPane for displaying html. ...
    (comp.lang.java.gui)
  • Re: Text in JTextArea als html darstellen ?
    ... Michael Hüttermann schrieb: ... Muss dazu eine Eigenschaft der JTextArea geändert werden? ... JEditorPane htmlDisplay = new JEditorPane; ... Es gibt aber AFAIK kommerzielle Komponenten, die HTML sauberer rendern ...
    (de.comp.lang.java)