java - Scroll bars not appearing in one of three scrollPanes -


i have simple program contains 3 scrollpanes. have set scroll bars visible. reason, scroll bars visible on 2 of 3 panes though code 3 same. difference between them third (pane problem) in south region of border layout.

code:

package swingassign2;  import java.awt.dimension; import java.awt.eventqueue;  import javax.swing.borderfactory; import javax.swing.jframe; import javax.swing.jlabel; import javax.swing.jpanel; import javax.swing.jscrollpane; import javax.swing.jtextpane;  import java.awt.borderlayout;  import javax.swing.jcombobox; import javax.swing.jtextfield;  import java.awt.flowlayout; import javax.swing.swingconstants; import java.awt.gridlayout;  public class swingassign2 {      private jframe frame;     private jtextfield textfield;      /**      * launch application.      */     public static void main(string[] args) {         eventqueue.invokelater(new runnable() {             public void run() {                 try {                     swingassign2 window = new swingassign2();                     window.frame.setvisible(true);                 } catch (exception e) {                     e.printstacktrace();                 }             }         });     }      /**      * create application.      */     public swingassign2() {         initialize();     }      /**      * initialize contents of frame.      */     private void initialize() {         frame = new jframe();         frame.setsize(600, 500);         frame.setdefaultcloseoperation(jframe.exit_on_close);          jpanel paneltop = new jpanel();         flowlayout fl_paneltop = (flowlayout) paneltop.getlayout();         fl_paneltop.setalignment(flowlayout.left);         frame.getcontentpane().add(paneltop, borderlayout.north);         //panel.setlayout(new flowlayout(flowlayout.left, 5, 5));          jcombobox combobox = new jcombobox();         paneltop.add(combobox);         combobox.setpreferredsize(new dimension(100, 20));          textfield = new jtextfield();         paneltop.add(textfield);         textfield.setcolumns(20);          jpanel panelbottom = new jpanel();         frame.getcontentpane().add(panelbottom, borderlayout.south);         panelbottom.setlayout(new borderlayout(0, 0));          jlabel status = new jlabel("status");         status.sethorizontalalignment(swingconstants.center);         panelbottom.add(status, borderlayout.south);         status.setborder(borderfactory.createloweredbevelborder());          jtextpane btext = new jtextpane();         jscrollpane jscrollpane3 = new jscrollpane();         jscrollpane3.sethorizontalscrollbarpolicy(                 jscrollpane.horizontal_scrollbar_always);         jscrollpane3.setverticalscrollbarpolicy(                 jscrollpane.vertical_scrollbar_always);         panelbottom.add(btext, borderlayout.north);         btext.setpreferredsize(new dimension(200, 200));         //btext.setborder(borderfactory.createloweredbevelborder());          jpanel panelcenter = new jpanel();         frame.getcontentpane().add(panelcenter, borderlayout.center);         panelcenter.setlayout(new gridlayout(0, 2, 0, 0));          jtextpane textpane_0 = new jtextpane();         jscrollpane jscrollpane1 = new jscrollpane();         jscrollpane1.sethorizontalscrollbarpolicy(                 jscrollpane.horizontal_scrollbar_always);         jscrollpane1.setverticalscrollbarpolicy(                 jscrollpane.vertical_scrollbar_always);         panelcenter.add(jscrollpane1);          jtextpane textpane_1 = new jtextpane();         jscrollpane jscrollpane2 = new jscrollpane(textpane_1);         jscrollpane2.sethorizontalscrollbarpolicy(                 jscrollpane.horizontal_scrollbar_always);         jscrollpane2.setverticalscrollbarpolicy(                 jscrollpane.vertical_scrollbar_always);         panelcenter.add(jscrollpane2);      }  } 

because of silly mistake.

panelbottom.add(btext, borderlayout.north); 

should be

panelbottom.add(jscrollpane3, borderlayout.north); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -