J
Jason Cavett
I'm currently in the process of creating a "tokenized" panel where a
formula can be displayed on that panel and the user can select
different tokens and add/remove them.
Currently, I am using a JPanel and I'm using a JLabel to display and
draw the formula text. (One JLabel per token.) The problem I am
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.
Does anybody have any alternative suggestions to using a JPanel w/
JLabels. So far I have come up with:
1. Write my own "JLabels" that only provide the functionality I need.
The problem is, it seems that a lot of the extra crap comes from
Component, JComponent, etc (all the stuff that JLabel needs to draw
itself). So, I'm not sure this idea would help anything.
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
the selection is taking place and do all the drawing for line
wrapping, selection, key and mouse listeners, etc, etc. This would
definitely make things more lightweight in terms of memory, but I'm
not sure that this is the best way to go due to the time involved.
If anybody has any additional suggestions, I'd appreciate it.
Basically, I need to not use as much memory with the JLabels.
Thanks
formula can be displayed on that panel and the user can select
different tokens and add/remove them.
Currently, I am using a JPanel and I'm using a JLabel to display and
draw the formula text. (One JLabel per token.) The problem I am
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.
Does anybody have any alternative suggestions to using a JPanel w/
JLabels. So far I have come up with:
1. Write my own "JLabels" that only provide the functionality I need.
The problem is, it seems that a lot of the extra crap comes from
Component, JComponent, etc (all the stuff that JLabel needs to draw
itself). So, I'm not sure this idea would help anything.
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
the selection is taking place and do all the drawing for line
wrapping, selection, key and mouse listeners, etc, etc. This would
definitely make things more lightweight in terms of memory, but I'm
not sure that this is the best way to go due to the time involved.
If anybody has any additional suggestions, I'd appreciate it.
Basically, I need to not use as much memory with the JLabels.
Thanks