Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6468185

Applied background color of JInternalFrame is not effecting once changes to different look and feel.



    • Subcomponent:
    • CPU:
      generic, x86
    • OS:
      linux_ubuntu, windows_xp


      I have opened a internal frame with yellow background but while changing the look and feel at runtime the background which i set is not effecting.I expected the background color (yellow) which i set should show irrespective of look and feel.

      First I launch the application in solaris platform with systems default look and feel then i can see the applied yellow color as frame background.After that i changed to different look and feel then the yellow color for background is not effecting,it shows the look and feel default background color.

      I tested the same scenario in windows with winxp look and feel.But i saw the same above behavior.

      JDK Info:
      java version "1.6.0-rc"
      Java(TM) SE Runtime Environment (build 1.6.0-rc-b98)
      Java HotSpot(TM) Client VM (build 1.6.0-rc-b98, mixed mode)

      Steps to Reproduce:
      1. Download the attached java file.
      2. Execute the java file.
      3. Click on the look and feel menu and choose the any other look and feel.

      Expected Behavior:
      The background color should be yellow which has shown by default while launching the application.

      Actual Behavior:
      The background color of the internal frame is not showing yellow.
      Adding InternalFrameBackgrnd.java here so it will be visible to
      the community:

       * InternalFrameBackgrnd.java
       * Created on September 7, 2006, 4:16 PM

       * @author vt152788
      import javax.swing.UIManager;
      import javax.swing.SwingUtilities;
      import javax.swing.UIManager.LookAndFeelInfo;
      import javax.swing.ButtonGroup;
      import javax.swing.JRadioButtonMenuItem;
      import java.awt.event.ActionListener;
      import java.awt.event.ActionEvent;
      public class InternalFrameBackgrnd extends javax.swing.JFrame {
          /** Creates new form InternalFrameBackgrnd */
          public InternalFrameBackgrnd() {
              lafInfo = UIManager.getInstalledLookAndFeels();
          /** This method is called from within the constructor to
           * initialize the form.
           * WARNING: Do NOT modify this code. The content of this method is
           * always regenerated by the Form Editor.
          // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
          private void initComponents() {
              jDesktopPane1 = new javax.swing.JDesktopPane();
              jInternalFrame1 = new javax.swing.JInternalFrame();
              jMenuBar1 = new javax.swing.JMenuBar();
              lafMenuItem = new javax.swing.JMenu();
              lafButtonGroup = new ButtonGroup();
              lafRadioMenuItems = new JRadioButtonMenuItem [lafInfo.length];
              for(int i= 0; i< lafInfo.length; i++){
                  System.out.println("laf name:" + lafInfo[i].getName());
                  lafRadioMenuItems[i]=new JRadioButtonMenuItem(lafInfo[i].getName()+" LAF");
                  lafRadioMenuItems[i].addActionListener(new ActionListener(){
                      public void actionPerformed(ActionEvent aevt_){

              jInternalFrame1.getContentPane().setLayout(new java.awt.FlowLayout());

              jInternalFrame1.setBackground(new java.awt.Color(225, 217, 51));
              jInternalFrame1.setBounds(70, 30, 190, 110);
              jDesktopPane1.add(jInternalFrame1, javax.swing.JLayeredPane.DEFAULT_LAYER);

              getContentPane().add(jDesktopPane1, java.awt.BorderLayout.CENTER);



              java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
              setBounds((screenSize.width-400)/2, (screenSize.height-300)/2, 400, 300);
          }// </editor-fold>//GEN-END:initComponents
             public void setLAF(String laf){
              final String lafName = laf;
                   SwingUtilities.invokeLater(new Runnable() {
                          public void run(){
                            }catch(Exception exp_){
              }catch(Exception exp_){
          } // end of setLAF();
           * @param args the command line arguments
          public static void main(String args[]) {
             }catch(Exception exp_){}
                      new InternalFrameBackgrnd().setVisible(true);
          // Variables declaration - do not modify//GEN-BEGIN:variables
          private javax.swing.JDesktopPane jDesktopPane1;
          private javax.swing.JInternalFrame jInternalFrame1;
          private javax.swing.JMenuBar jMenuBar1;
          private javax.swing.JMenu lafMenuItem;
          // End of variables declaration//GEN-END:variables
          private LookAndFeelInfo lafInfo[];
          private ButtonGroup lafButtonGroup;
          private JRadioButtonMenuItem lafRadioMenuItems[];
      There is also a testcase in the SQE repository at Swing_JInternalFrame/Manual/InternalFrameBackground currently failing because of this bug. Once this bug is fixed remove this test from the known failures list, and add it to the normal execution testlist.
      Swing_JInternalFrame/Manual/InternalFrameBackground is failing




            psadhukhan Prasanta Sadhukhan
            vthotasunw Vinay Thota (Inactive)
            0 Vote for this issue
            5 Start watching this issue