From 2b211cb4b1c9af6e69a6dfc24842c673214843ec Mon Sep 17 00:00:00 2001 From: mdb Date: Fri, 12 Oct 2001 18:21:27 +0000 Subject: [PATCH] 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 --- .../robodj/src/java/robodj/chooser/EntryList.java | 15 ++++++++------- .../src/java/robodj/chooser/PlaylistPanel.java | 14 +++++++------- .../src/java/robodj/importer/ImporterFrame.java | 12 +++++++----- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/projects/robodj/src/java/robodj/chooser/EntryList.java b/projects/robodj/src/java/robodj/chooser/EntryList.java index 69e889db..d813fd9f 100644 --- a/projects/robodj/src/java/robodj/chooser/EntryList.java +++ b/projects/robodj/src/java/robodj/chooser/EntryList.java @@ -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; @@ -203,9 +203,8 @@ public class EntryList // where we were... oh the complication. clearScrollPosition(); - // we've removed and added components and swing won't properly - // repaint automatically - _bpanel.repaint(); + // we've removed and added components so we need to revalidate + revalidate(); } protected void populateSong (Entry entry) @@ -275,9 +274,8 @@ public class EntryList // the song list clearScrollPosition(); - // we've removed and added components and swing won't properly - // repaint automatically - _bpanel.repaint(); + // we've removed and added components so we need to revalidate + revalidate(); } protected void clearScrollPosition () @@ -336,6 +334,9 @@ public class EntryList // what's up _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 TaskMaster.invokeMethodTask("readEntries", this, this); } diff --git a/projects/robodj/src/java/robodj/chooser/PlaylistPanel.java b/projects/robodj/src/java/robodj/chooser/PlaylistPanel.java index 0e65f296..9423ad16 100644 --- a/projects/robodj/src/java/robodj/chooser/PlaylistPanel.java +++ b/projects/robodj/src/java/robodj/chooser/PlaylistPanel.java @@ -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; @@ -108,9 +108,9 @@ public class PlaylistPanel // what's up _bpanel.removeAll(); _bpanel.add(new JLabel("Loading...")); - // we've removed and added components and swing won't properly - // repaint automatically - _bpanel.repaint(); + // swing doesn't automatically validate after adding/removing + // children + _bpanel.revalidate(); // start up the task that reads the CD info from the database TaskMaster.invokeMethodTask("readPlaylist", this, this); @@ -265,9 +265,9 @@ public class PlaylistPanel _bpanel.add(new JLabel("Nothing playing.")); } - // we've removed and added components and swing won't properly - // repaint automatically - _bpanel.repaint(); + // swing doesn't automatically validate after adding/removing + // children + _bpanel.revalidate(); } protected void highlightPlaying () diff --git a/projects/robodj/src/java/robodj/importer/ImporterFrame.java b/projects/robodj/src/java/robodj/importer/ImporterFrame.java index 9ba5299f..389ba273 100644 --- a/projects/robodj/src/java/robodj/importer/ImporterFrame.java +++ b/projects/robodj/src/java/robodj/importer/ImporterFrame.java @@ -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; @@ -68,16 +68,18 @@ public class ImporterFrame extends JFrame abutton.setActionCommand(command); abutton.addActionListener(target); _buttonPanel.add(abutton); - // swing doesn't properly repaint after adding/removing children - _buttonPanel.repaint(); + // swing doesn't automatically validate after adding/removing + // children + _buttonPanel.revalidate(); return abutton; } public void clearControlButtons () { _buttonPanel.removeAll(); - // swing doesn't properly repaint after adding/removing children - _buttonPanel.repaint(); + // swing doesn't automatically validate after adding/removing + // children + _buttonPanel.revalidate(); } protected ImporterPanel _panel;