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

JSlider shows ugly black line when moved

XMLWordPrintable

    • windows_7

      FULL PRODUCT VERSION :
      java 1.6.0_39 and also java 1.7.0_13

      ADDITIONAL OS VERSION INFORMATION :
      windows 8 6.2

      A DESCRIPTION OF THE PROBLEM :
      When a JSlider is moved, it shows a black line on top of the whole Component.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Start the added application and move the JSlider in the JDialog. A black line is shown.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Proper painting with no ugly black lines on top of the JSlider (as under windows 7).
      ACTUAL -
      Not proper painting with an ugly black lines on top of the JSlider.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package com.classwizard.cw;


      import java.awt.BorderLayout;
      import java.awt.Container;
      import java.awt.Dimension;
      import java.awt.GridBagConstraints;
      import java.awt.GridBagLayout;
      import java.awt.event.WindowAdapter;
      import java.awt.event.WindowEvent;
      import java.io.File;

      import javax.swing.Box;
      import javax.swing.JDesktopPane;
      import javax.swing.JDialog;
      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.JPanel;
      import javax.swing.JSlider;
      import javax.swing.WindowConstants;


      public class ClassWizard extends Object
      {
          public static void main(String args[]) throws Exception
          {
              try
              {
                  DialogTest ket = new DialogTest();
                  GJApp.launch(ket, " ButtonTest " ,0,0,700,700,null);
              }
              catch (Exception e)
              {
                  System.out.println(e.getMessage());
                  e.printStackTrace();
              }
          }
      }
      class GJApp extends WindowAdapter
      {
          public static void launch(final DialogTest f, String title,final int x, final int y,final int w, int h,String propertiesFilename)
          {
              f.setTitle(title);
              f.setBounds(x,y,w,h);
              f.setVisible(true);
              f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
              f.addWindowListener(new WindowAdapter()
              {
                  public void windowClosed(WindowEvent e)
                  {
                      System.exit(0);
                  }
              });
          }
      }

      class DialogTest extends JFrame
      {
          protected JDesktopPane desktopPane = new JDesktopPane();
          SliderDialog _buttondlg = null;
          
          protected File outfile = null;
          boolean _even = true;
          int _flickercount = 0;
          javax.swing.Timer _timer = null;

          
          public DialogTest() throws Exception
          {
              String osname = System.getProperty( " os.name " );
              String osversion = System.getProperty( " os.version " );
              String java_version = System.getProperty( " java.version " );
              System.out.println(osname + " " + osversion + " java: " + java_version + "
       " );
              
              // make a dialog with a slider
              _buttondlg = new SliderDialog(this, " drag " , false);
              _buttondlg.init();
              _buttondlg.setVisible(true);
              _buttondlg.setLocation(300, 100);

          }
      }

      class SliderDialog extends JDialog
      {
          SliderDialog _dlg = null;
          DialogTest _owner = null;
          JSlider cSlider = null;
          JSlider mSlider = null;
          
          public SliderDialog(DialogTest owner, String title, boolean modal)
          {
              super(owner,title,modal);
              _owner = owner;
              _dlg = this;
          }

          public JPanel makeButtonsPanel()
          {
              GridBagLayout gbl = new GridBagLayout();
              GridBagConstraints gbc = new GridBagConstraints();

              cSlider = new JSlider(JSlider.HORIZONTAL,0,100,0);
              mSlider = new JSlider(JSlider.HORIZONTAL,0,100,0);
              JLabel labelc = new JLabel( " C " );
              JLabel labelm = new JLabel( " M " );

              JPanel paraPanel = new JPanel();
              paraPanel.setPreferredSize(new Dimension(280, 200));
              paraPanel.setLayout(gbl);

              paraPanel.add(Box.createHorizontalStrut(10));
              gbc.gridwidth = 1;
              paraPanel.add(labelc, gbc);
              paraPanel.add(Box.createHorizontalStrut(10));
              gbc.gridwidth = GridBagConstraints.REMAINDER;
              paraPanel.add(cSlider, gbc);
              
              paraPanel.add(Box.createHorizontalStrut(10));
              gbc.gridwidth = 1;
              paraPanel.add(new JLabel( " " ), gbc);
              paraPanel.add(Box.createHorizontalStrut(10));
              gbc.gridwidth = GridBagConstraints.REMAINDER;
              paraPanel.add(new JLabel( " " ), gbc);
              
              paraPanel.add(Box.createHorizontalStrut(10));
              gbc.gridwidth = 1;
              paraPanel.add(labelm, gbc);
              paraPanel.add(Box.createHorizontalStrut(10));
              gbc.gridwidth = GridBagConstraints.REMAINDER;
              paraPanel.add(mSlider, gbc);
              
              return(paraPanel);
          }
          public void init()
          {
              JPanel paraPanel2 = makeButtonsPanel();
              Container diacontent = this.getContentPane();
              diacontent.add(paraPanel2, BorderLayout.NORTH);
              setPreferredSize(new Dimension(280, 200));
              setResizable(true);
              pack();
          }
      }
          

      ---------- END SOURCE ----------

            aivanov Alexey Ivanov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: