Re: [cp-patches] FYI: Swing demo optimization
This patch is not quite right, it causes an additional 'Close' button to appear on the Swing activity board - this is only supposed to appear when the individual demos are run independently. I'll fix this now... Regards, Dave Roman Kennke wrote: Obviously we had a problem with our Swing demo. At startup all the demos createContent() methods were called twice, once when the constructor was executed and then again by the Demo itself. So we built nearly the whole GUI twice. This is corrected by this patch. Should greatly increase the startup time of the Demo. 2006-01-27 Roman Kennke [EMAIL PROTECTED] * examples/gnu/classpath/examples/swing/ButtonDemo.java (createContent): Only create new content if we don't have one already. * examples/gnu/classpath/examples/swing/ComboBoxDemo.java (createContent): Only create new content if we don't have one already. * examples/gnu/classpath/examples/swing/FileChooserDemo.java (createContent): Only create new content if we don't have one already. * examples/gnu/classpath/examples/swing/ScrollBarDemo.java (createContent): Only create new content if we don't have one already. * examples/gnu/classpath/examples/swing/SliderDemo.java (createContent): Only create new content if we don't have one already. * examples/gnu/classpath/examples/swing/TableDemo.java (createContent): Only create new content if we don't have one already. * examples/gnu/classpath/examples/swing/TextFieldDemo.java (createContent): Only create new content if we don't have one already. /Roman Index: examples/gnu/classpath/examples/swing/ButtonDemo.java === RCS file: /cvsroot/classpath/classpath/examples/gnu/classpath/examples/swing/ButtonDemo.java,v retrieving revision 1.4 diff -u -r1.4 ButtonDemo.java --- examples/gnu/classpath/examples/swing/ButtonDemo.java 29 Oct 2005 05:04:23 - 1.4 +++ examples/gnu/classpath/examples/swing/ButtonDemo.java 27 Jan 2006 21:50:29 - @@ -46,6 +46,8 @@ implements ActionListener { + private JPanel content; + private JCheckBox buttonState; private JButton button1; private JButton button2; @@ -95,13 +97,16 @@ */ JPanel createContent() { -JPanel content = new JPanel(new BorderLayout()); -JPanel panel = new JPanel(new GridLayout(4, 1)); -panel.add(createButtonPanel()); -panel.add(createTogglePanel()); -panel.add(createCheckBoxPanel()); -panel.add(createRadioPanel()); -content.add(panel); +if (content == null) + { +content = new JPanel(new BorderLayout()); +JPanel panel = new JPanel(new GridLayout(4, 1)); +panel.add(createButtonPanel()); +panel.add(createTogglePanel()); +panel.add(createCheckBoxPanel()); +panel.add(createRadioPanel()); +content.add(panel); + } return content; } Index: examples/gnu/classpath/examples/swing/ComboBoxDemo.java === RCS file: /cvsroot/classpath/classpath/examples/gnu/classpath/examples/swing/ComboBoxDemo.java,v retrieving revision 1.5 diff -u -r1.5 ComboBoxDemo.java --- examples/gnu/classpath/examples/swing/ComboBoxDemo.java 29 Oct 2005 05:04:23 - 1.5 +++ examples/gnu/classpath/examples/swing/ComboBoxDemo.java 27 Jan 2006 21:50:29 - @@ -69,6 +69,7 @@ } } + private JPanel content; private JCheckBox comboState1; private JComboBox combo1; private JComboBox combo2; @@ -120,15 +121,18 @@ */ JPanel createContent() { -JPanel content = new JPanel(new BorderLayout()); -JPanel panel = new JPanel(new GridLayout(6, 1)); -panel.add(createPanel1()); -panel.add(createPanel2()); -panel.add(createPanel3()); -panel.add(createPanel4()); -panel.add(createPanel5()); -panel.add(createPanel6()); -content.add(panel); +if (content == null) + { +content = new JPanel(new BorderLayout()); +JPanel panel = new JPanel(new GridLayout(6, 1)); +panel.add(createPanel1()); +panel.add(createPanel2()); +panel.add(createPanel3()); +panel.add(createPanel4()); +panel.add(createPanel5()); +panel.add(createPanel6()); +content.add(panel); + } return content; } Index: examples/gnu/classpath/examples/swing/FileChooserDemo.java === RCS file: /cvsroot/classpath/classpath/examples/gnu/classpath/examples/swing/FileChooserDemo.java,v retrieving revision 1.1 diff -u -r1.1 FileChooserDemo.java --- examples/gnu/classpath/examples/swing/FileChooserDemo.java 9 Nov 2005 16:37:56 - 1.1 +++
[cp-patches] FYI: Swing demo optimization
Obviously we had a problem with our Swing demo. At startup all the demos createContent() methods were called twice, once when the constructor was executed and then again by the Demo itself. So we built nearly the whole GUI twice. This is corrected by this patch. Should greatly increase the startup time of the Demo. 2006-01-27 Roman Kennke [EMAIL PROTECTED] * examples/gnu/classpath/examples/swing/ButtonDemo.java (createContent): Only create new content if we don't have one already. * examples/gnu/classpath/examples/swing/ComboBoxDemo.java (createContent): Only create new content if we don't have one already. * examples/gnu/classpath/examples/swing/FileChooserDemo.java (createContent): Only create new content if we don't have one already. * examples/gnu/classpath/examples/swing/ScrollBarDemo.java (createContent): Only create new content if we don't have one already. * examples/gnu/classpath/examples/swing/SliderDemo.java (createContent): Only create new content if we don't have one already. * examples/gnu/classpath/examples/swing/TableDemo.java (createContent): Only create new content if we don't have one already. * examples/gnu/classpath/examples/swing/TextFieldDemo.java (createContent): Only create new content if we don't have one already. /Roman Index: examples/gnu/classpath/examples/swing/ButtonDemo.java === RCS file: /cvsroot/classpath/classpath/examples/gnu/classpath/examples/swing/ButtonDemo.java,v retrieving revision 1.4 diff -u -r1.4 ButtonDemo.java --- examples/gnu/classpath/examples/swing/ButtonDemo.java 29 Oct 2005 05:04:23 - 1.4 +++ examples/gnu/classpath/examples/swing/ButtonDemo.java 27 Jan 2006 21:50:29 - @@ -46,6 +46,8 @@ implements ActionListener { + private JPanel content; + private JCheckBox buttonState; private JButton button1; private JButton button2; @@ -95,13 +97,16 @@ */ JPanel createContent() { -JPanel content = new JPanel(new BorderLayout()); -JPanel panel = new JPanel(new GridLayout(4, 1)); -panel.add(createButtonPanel()); -panel.add(createTogglePanel()); -panel.add(createCheckBoxPanel()); -panel.add(createRadioPanel()); -content.add(panel); +if (content == null) + { +content = new JPanel(new BorderLayout()); +JPanel panel = new JPanel(new GridLayout(4, 1)); +panel.add(createButtonPanel()); +panel.add(createTogglePanel()); +panel.add(createCheckBoxPanel()); +panel.add(createRadioPanel()); +content.add(panel); + } return content; } Index: examples/gnu/classpath/examples/swing/ComboBoxDemo.java === RCS file: /cvsroot/classpath/classpath/examples/gnu/classpath/examples/swing/ComboBoxDemo.java,v retrieving revision 1.5 diff -u -r1.5 ComboBoxDemo.java --- examples/gnu/classpath/examples/swing/ComboBoxDemo.java 29 Oct 2005 05:04:23 - 1.5 +++ examples/gnu/classpath/examples/swing/ComboBoxDemo.java 27 Jan 2006 21:50:29 - @@ -69,6 +69,7 @@ } } + private JPanel content; private JCheckBox comboState1; private JComboBox combo1; private JComboBox combo2; @@ -120,15 +121,18 @@ */ JPanel createContent() { -JPanel content = new JPanel(new BorderLayout()); -JPanel panel = new JPanel(new GridLayout(6, 1)); -panel.add(createPanel1()); -panel.add(createPanel2()); -panel.add(createPanel3()); -panel.add(createPanel4()); -panel.add(createPanel5()); -panel.add(createPanel6()); -content.add(panel); +if (content == null) + { +content = new JPanel(new BorderLayout()); +JPanel panel = new JPanel(new GridLayout(6, 1)); +panel.add(createPanel1()); +panel.add(createPanel2()); +panel.add(createPanel3()); +panel.add(createPanel4()); +panel.add(createPanel5()); +panel.add(createPanel6()); +content.add(panel); + } return content; } Index: examples/gnu/classpath/examples/swing/FileChooserDemo.java === RCS file: /cvsroot/classpath/classpath/examples/gnu/classpath/examples/swing/FileChooserDemo.java,v retrieving revision 1.1 diff -u -r1.1 FileChooserDemo.java --- examples/gnu/classpath/examples/swing/FileChooserDemo.java 9 Nov 2005 16:37:56 - 1.1 +++ examples/gnu/classpath/examples/swing/FileChooserDemo.java 27 Jan 2006 21:50:29 - @@ -63,7 +63,9 @@ return false; } } - + + private JPanel content; + /** A label to display the selected file. */ JLabel selectedFileLabel; @@ -102,52 +104,56 @@ * added if this demo is being run as a standalone demo). */ JPanel