ContentPane To make the content pane visible to (Web host)
ContentPane To make the content pane visible to the application, declare the getContentPane() method as public. In addition, insert the initialization of the sliders into this method. Also, you can now insert all setLabelFor() methods, because after the execution of the method body, you can be sure that all target objects of setLabelFor() exist. public javax.swing.JPanel getContentPane() { if(contentPane == null) { contentPane = new javax.swing.JPanel(); contentPane.setLayout(new java.awt.BorderLayout()); contentPane.add(getControlAreaPane(), java.awt.BorderLayout.CENTER); contentPane.add(getTextAndButtonPanel(), java.awt.BorderLayout.SOUTH); contentPane.setSize(new java.awt.Dimension(600,500)); volumeLabel.setLabelFor(volumeSlider); speedLabel.setLabelFor(speedSlider); pitchLabel.setLabelFor(pitchSlider); rangeLabel.setLabelFor(rangeSlider); textAreaLabel.setLabelFor(textInputArea); updateSliders(); } return contentPane; } The updateSliders() method is defined as follows: private void updateSliders() { // Volume int volume = (int) playerModel.getVolume(); if (volume >= 0) volumeSlider.setValue(volume); // Speed int rate = (int) playerModel.getSpeakingRate(); if (rate >= 0) speedSlider.setValue(rate); // Pitch int pitch = (int) playerModel.getPitch(); if (pitch >= 0) pitchSlider.setValue(pitch); // Variation int range = (int) playerModel.getRange(); if (range >= 0) rangeSlider.setValue(range); } Listing 5.7 contains the complete source code of the PlayerPanel class as generated by the Visual Editor, with the necessary source code modifications applied. 96 Chapter 5
We strive to offer the highest quality service while maintaining a cheap and discount price structure. For your company, ecommerce, or personal web hosting needs, we offer the best solution.Trust us and please check quality web hosting services.