0 Replies Latest reply: Apr 2, 2012 1:50 PM by 928018 RSS

    Issue with JPanel as scrollable

      I am developing a java JApplet to display few 10s of check boxes in scrollable pane. I included these check boxes in JPanel and added this panel on JScrollPane which is added in current ContentPane of applet. Content pane also has few other components like JTextArea, Button and Label. I would see the scroll bar but when I do scrolling, check boxes are scrolled outside of scrollpane and laid over other adjacent components. I tried setPreferredSize() with no success. What could be the issue with scrolling?

      My code bites looks like:
      public void init(){
      contentPane = this.getContentPane();          
      GridBagLayout grrdbag = new GridBagLayout();
      GridBagConstraints components = new GridBagConstraints();
      //button, textarea and label components here

      //checkboxes here
      components = new GridBagConstraints();
      components.anchor = GridBagConstraints.EAST;
      contentPane.add(new Label("Data:", Label.RIGHT), components);          
      components = new GridBagConstraints();
      components.gridwidth = GridBagConstraints.REMAINDER;
      components.weighty = 1;
      components.fill = GridBagConstraints.BOTH;

      checkboxesPanel.setLayout(new BoxLayout(checkboxesPanel, BoxLayout.Y_AXIS));
      conflictScrollPane = new JScrollPane(checkboxesPanel,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      contentPane.add(conflictScrollPane, components);

      //create check boxes
      public void displayboxes(){
                checkboxes = new Checkbox[150];
                for(int j=0;j<150;j++){
                     checkboxes[j] = new Checkbox("This is test data for check box here.",null,false);
      //start method
      public void start() {