We have to call revalidate() rather than repaint() when adding or removing

children or Swing doesn't quite do the right thing.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@352 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2001-10-12 18:21:27 +00:00
parent 0c23daaeb6
commit 2b211cb4b1
3 changed files with 22 additions and 19 deletions
@@ -1,5 +1,5 @@
// //
// $Id: EntryList.java,v 1.8 2001/09/21 03:09:01 mdb Exp $ // $Id: EntryList.java,v 1.9 2001/10/12 18:21:27 mdb Exp $
package robodj.chooser; package robodj.chooser;
@@ -203,9 +203,8 @@ public class EntryList
// where we were... oh the complication. // where we were... oh the complication.
clearScrollPosition(); clearScrollPosition();
// we've removed and added components and swing won't properly // we've removed and added components so we need to revalidate
// repaint automatically revalidate();
_bpanel.repaint();
} }
protected void populateSong (Entry entry) protected void populateSong (Entry entry)
@@ -275,9 +274,8 @@ public class EntryList
// the song list // the song list
clearScrollPosition(); clearScrollPosition();
// we've removed and added components and swing won't properly // we've removed and added components so we need to revalidate
// repaint automatically revalidate();
_bpanel.repaint();
} }
protected void clearScrollPosition () protected void clearScrollPosition ()
@@ -336,6 +334,9 @@ public class EntryList
// what's up // what's up
_bpanel.add(new JLabel("Loading...")); _bpanel.add(new JLabel("Loading..."));
// we need to revalidate the component because we added a child
revalidate();
// start up the task that reads the CD info from the database // start up the task that reads the CD info from the database
TaskMaster.invokeMethodTask("readEntries", this, this); TaskMaster.invokeMethodTask("readEntries", this, this);
} }
@@ -1,5 +1,5 @@
// //
// $Id: PlaylistPanel.java,v 1.8 2001/09/21 03:09:01 mdb Exp $ // $Id: PlaylistPanel.java,v 1.9 2001/10/12 18:21:27 mdb Exp $
package robodj.chooser; package robodj.chooser;
@@ -108,9 +108,9 @@ public class PlaylistPanel
// what's up // what's up
_bpanel.removeAll(); _bpanel.removeAll();
_bpanel.add(new JLabel("Loading...")); _bpanel.add(new JLabel("Loading..."));
// we've removed and added components and swing won't properly // swing doesn't automatically validate after adding/removing
// repaint automatically // children
_bpanel.repaint(); _bpanel.revalidate();
// start up the task that reads the CD info from the database // start up the task that reads the CD info from the database
TaskMaster.invokeMethodTask("readPlaylist", this, this); TaskMaster.invokeMethodTask("readPlaylist", this, this);
@@ -265,9 +265,9 @@ public class PlaylistPanel
_bpanel.add(new JLabel("Nothing playing.")); _bpanel.add(new JLabel("Nothing playing."));
} }
// we've removed and added components and swing won't properly // swing doesn't automatically validate after adding/removing
// repaint automatically // children
_bpanel.repaint(); _bpanel.revalidate();
} }
protected void highlightPlaying () protected void highlightPlaying ()
@@ -1,5 +1,5 @@
// //
// $Id: ImporterFrame.java,v 1.5 2001/07/26 00:24:22 mdb Exp $ // $Id: ImporterFrame.java,v 1.6 2001/10/12 18:21:27 mdb Exp $
package robodj.importer; package robodj.importer;
@@ -68,16 +68,18 @@ public class ImporterFrame extends JFrame
abutton.setActionCommand(command); abutton.setActionCommand(command);
abutton.addActionListener(target); abutton.addActionListener(target);
_buttonPanel.add(abutton); _buttonPanel.add(abutton);
// swing doesn't properly repaint after adding/removing children // swing doesn't automatically validate after adding/removing
_buttonPanel.repaint(); // children
_buttonPanel.revalidate();
return abutton; return abutton;
} }
public void clearControlButtons () public void clearControlButtons ()
{ {
_buttonPanel.removeAll(); _buttonPanel.removeAll();
// swing doesn't properly repaint after adding/removing children // swing doesn't automatically validate after adding/removing
_buttonPanel.repaint(); // children
_buttonPanel.revalidate();
} }
protected ImporterPanel _panel; protected ImporterPanel _panel;