0

I´d try to add a scrollbar to a pane that is inside a jtabbedPane but nothing works, hope someone can help.

This is what i had try:

        JPanel panel_3 = new JPanel();
        panel_3.setBackground(Color.WHITE);

        JScrollPane scroll = new JScrollPane(panel_3);
        scroll.setPreferredSize(new Dimension(643, 900));

        tabbedPane.add(scroll, "test");
        panel_3.setLayout(null);

Demostration IMAGE

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
HARRY
  • 1
  • 1
  • Do you call panel3.add(tabbedPane); somewhere? – Paul MacGuiheen Feb 22 '18 at 21:52
  • yes i did! but the problem is no scrollbar is shown! – HARRY Feb 22 '18 at 23:31
  • There are two problems in that uncompilable code snippet. 1) `scroll.setPreferredSize(new Dimension(643, 900));` See [Should I avoid the use of set(Preferred|Maximum|Minimum)Size methods in Java Swing?](http://stackoverflow.com/q/7229226/418556) (Yes.) 2) `panel_3.setLayout(null);` Java GUIs have to work on different OS', screen size, screen resolution etc. using different PLAFs in different locales. As such, they are not conducive to pixel perfect layout. .. – Andrew Thompson Feb 23 '18 at 05:10
  • 1
    .. Instead use layout managers, or [combinations of them](http://stackoverflow.com/a/5630271/418556) along with layout padding and borders for [white space](http://stackoverflow.com/a/17874718/418556). **More general advice:** For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). – Andrew Thompson Feb 23 '18 at 05:11

0 Answers0