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

adding JScrollPane in JTabbedPane will crush in ubuntu but not in windows

XMLWordPrintable

    • x86_64
    • linux_ubuntu

      ADDITIONAL SYSTEM INFORMATION :
      Ubuntu 20.04 LTS
      i72600k 2nd gen
      openjdk version "1.8.0_312"
      OpenJDK Runtime Environment (build 1.8.0_312-8u312-b07-0ubuntu1~20.04-b07)
      OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode)


      A DESCRIPTION OF THE PROBLEM :
      Hi,,i am not very good in programming and operating systems.
      Just that i think i discovered a bug for jdk of ubuntu.
      I installed ubuntu 20.04 LTS and one application (swing) crashes.
      I found the problem meaning i can solve it .
      But i am just sending this report because there is a different behaviur in win7 and ubuntu.

      Copy and test the following simple code to see that it runs on window but crashes in ubuntu.

      The problem is that
      if we add a javax.swing.JScrollPane
      to a javax.swing.JTabbedPane that is NOT VISIBLE
      then the application crashes....in Ubuntu 20.04 LTS(not in windows)

      But if we add some other component like javax.swing.JTextArea
      to a javax.swing.JTabbedPane that is NOT VISIBLE
      then is ok.....

      But is all ok if the JTabbedPane is Visible (via its frame)
      when we add any Component either JScrollPane


      ---------- BEGIN SOURCE ----------

      import java.awt.BorderLayout;
      import java.awt.Component;
      import javax.swing.JFrame;
      import javax.swing.JOptionPane;
      import javax.swing.JPanel;
      import javax.swing.JScrollPane;
      import javax.swing.JTabbedPane;
      import javax.swing.JTextArea;

      public class UbuntuCrashWhenAddJScrollPaneToJTabbedPaneNotBeingVisible {

          public static void main(String[] args) {
              // TODO code application logic here
              JFrame jfr=new JFrame("Ubuntu bug tester JTabbedPane-JScrollPane");
              jfr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              jfr.setBounds(111,111,333,333);
              
              /**
               * If this command (jfr.setVisible(true);)
               * is BEFORE we add to JTabbedPane DIRECTLY a JScrollpane
               * then all working fine
               * So i have commented to see what is happening
               * if we call JTabbedPane.addTab("",someJScrollPane)
               * BEFORE this JTAbbepPane is visible
               *
               * But all those are running OK in windows 7
               * Just in Ubuntu i have the problem
               */
              //jfr.setVisible(true);//uncomment this and use below false->run and true->run to see its ok in both cases
              
              JTabbedPane jtp=new JTabbedPane();
              jfr.getContentPane().add(jtp);
              //jfr.validate();//no need for this ...may
              
              System.out.println("adding the JScrollPane");
              boolean methodStyle=true;
              int answer=JOptionPane.showConfirmDialog(null,"Would you like to see the bug ?"
                      + "\nby crashing jdk of Ubuntu 20.04 LTS ...?"
                      + "\n\nYou must see a JFrame after this..."
                      + "\nIf not see then app is crashed ."
                      + "\n Press NO to see the NOT CRASHED APPLICATION"
                      + "\nPress YES (just enter) and do this "
                      + "once in windows and once in ubuntu 20.04 LTS"
                      + "\n\n\nYES will add a JScrollPane directly to JTabbedPane with jtp.addTab(\"\",somScrollPane)"
                      + "\nNO will add this JScrollPane NOT DIRECTLY but via a new JPanel that has child the JScrollPane"
                      ,"mes:Enter or press No",JOptionPane.YES_NO_OPTION);
              
              methodStyle = answer != JOptionPane.YES_OPTION;

              //methodStyle=false;//UN-COMMENT THIS IN UBUNTU AND YOU GET A CRASH
              addScrollableComponent(methodStyle,jtp, new JTextArea("ok"));
              //jtp.addTab("*",new JTextArea("single area"));
              System.out.println("JScrollPane added ok!");
              
              jfr.setVisible(true);
              System.out.println("JFrame is Visible ok");
              
          }
          static void addScrollableComponent(boolean createJPanelSTyle,JTabbedPane jtp,Component c){
              JScrollPane jscr=new JScrollPane(c);
              Component compToAdd=jscr;
              if(createJPanelSTyle){
                  JPanel jp=new JPanel(new BorderLayout());
                  jp.add(BorderLayout.CENTER,jscr);
                  compToAdd=jp;
              }
              
              
              jtp.addTab("*",compToAdd);
              //jtp.validate();
          }

          
      }

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

      FREQUENCY : always


            pnarayanaswa Praveen Narayanaswamy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: