Results 1 to 5 of 5
- 07-27-2012, 07:52 PM #1
Member
- Join Date
- Jul 2012
- Posts
- 9
- Rep Power
- 0
Problems with Swing JLayer (calling repaint() doesn't update my layerUI)
Hy folks, it's my first post here, i hope i fill find a solution for my problem because it gives me headaches.
Ok i'll try to explain my problem correctly.
What i am trying to do: Make a Animated Busy Indicator like this one from the Java Turorial (see bottom of the page)Click Here.
ok, i changed the original signature of the WaitLayerUI class like this :
You can see also what ListViewCell is.Java Code:class WaitLayerUI extends LayerUI<ListViewCell> implements ActionListener {}
The problem i have starts in this method of the WaitLayerUIJava Code:class ListViewCell extends JPanel implements ListCellRenderer
the repaint() method call should call the WaitLayerUI's "paint(Graphics g, JComponent j)" when a "tick" event occurs and some changes should occur (the indicator should spin).Java Code:@Override public void applyPropertyChange(PropertyChangeEvent pce, JLayer l) { if ("tick".equals(pce.getPropertyName())) { l.repaint(); } }
The problem is that my paint method is called only once. and i don't understand the problem.
I have to mention that the event arrives every tick so the repaint() is called every "tick", the problem is what repaint does.
That JLayer and LayerUI are created and instantiated in this method of my ListViewCell
I can't understand why repaint doesn't call the paint method every "tick"Java Code:public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { WaitLayerUI layerUI = new WaitLayerUI(); JLayer<ListViewCell> jlayer = new JLayer<ListViewCell>(this, layerUI); }
- 07-27-2012, 09:17 PM #2
Re: Problems with Swing JLayer (calling repaint() doesn't update my layerUI)
To get better help sooner, post a SSCCE (Short, Self Contained, Correct (Compilable), Example) that demonstrates the problem.
What if it does? The renderer has already done its job.the repaint() method call should call the WaitLayerUI's "paint(Graphics g, JComponent j)"dbJava Code:class ListViewCell extends JPanel implements ListCellRenderer
Why do they call it rush hour when nothing moves? - Robin Williams
- 07-27-2012, 10:15 PM #3
Member
- Join Date
- Jul 2012
- Posts
- 9
- Rep Power
- 0
Re: Problems with Swing JLayer (calling repaint() doesn't update my layerUI)
So the problem is that after the first paint is done, the panel is returned by the renderer to the JList as it was after the first paint and the layer is updated but not rendered again in the JList?
I will try to post a SSCCE soon.
PS. Ok seems that's the problem, i am looking now for solutions for adding an animated JLayer to a JList Cell.Last edited by doru.chiulan; 07-27-2012 at 10:57 PM.
- 07-28-2012, 04:52 AM #4
Re: Problems with Swing JLayer (calling repaint() doesn't update my layerUI)
You will need to repaint() the component that uses the renderer -- in this case, the JList.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 07-28-2012, 11:13 PM #5
Member
- Join Date
- Jul 2012
- Posts
- 9
- Rep Power
- 0
Similar Threads
-
Problems with LayerUI on Mac
By pete051 in forum New To JavaReplies: 4Last Post: 02-14-2012, 08:51 PM -
repaint() and revalidate() doesn't work in my JContentPane
By bigjo in forum AWT / SwingReplies: 3Last Post: 11-20-2011, 05:50 PM -
panel wont update when repaint is called
By yemista in forum AWT / SwingReplies: 3Last Post: 10-25-2011, 06:58 PM -
Java Swing repaint
By sz20b in forum Advanced JavaReplies: 1Last Post: 10-04-2010, 02:59 PM -
Repaint calling Statement Doesn't Work in my code ?
By nitin_daviet88 in forum CLDC and MIDPReplies: 2Last Post: 07-24-2010, 03:09 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks