0

I can not get the effect you intend to, or adding sliders JPanel if the elements do not fit in sight.

So I create a JPanel and conjure a method that will place the JLabel etc.

panelHome = new JPanel();
    panelHome.setBounds(151, 81, 873, 688);
    panelHome.setBackground(Color.GRAY);
    panelHome.setLayout(null);

    add(panelHome);


    Home home = new Home(this, panelHome, "qwerty");
    home.showHome();

The method we receive through

JPanel panelHome;

and I add them to the panel elements. Dumped element JLabel distance 1500 Y and try to do to the slider, but I can not figure out how to do it. I'm looking at different sides, to something and I do not give advice. How will add something, it's just the elements cease to appear so. How do I do?

PS: I help myself with Google Translate. My English is medium.

Q. One
  • 17
  • 3
  • Oracle Java tutorials: [https://docs.oracle.com/javase/tutorial/uiswing/components/scrollpane.html](https://docs.oracle.com/javase/tutorial/uiswing/components/scrollpane.html) – jhamon Sep 22 '16 at 22:49
  • 2
    Don't use a `null` layout! Swing was made to work on different OS', screen sizes and PLAFs, consider using a Layout Manger or [combinations of them](https://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html) long with layout padding and borders for [white space](http://stackoverflow.com/a/17874718/418556). See [Null Layout is Evil](http://www.leepoint.net/GUI/layouts/nulllayout.html) and [Why is it frowned upon to use a null layout in swing?](http://stackoverflow.com/questions/6592468/why-is-it-frowned-upon-to-use-a-null-layout-in-swing) – Frakcool Sep 22 '16 at 22:56
  • 1
    Also for better help sooner please post a [mcve] where you show the issue while also following the above recommendations as well as the link provided by @jhamon – Frakcool Sep 22 '16 at 22:57
  • If this is not a duplicate, please edit your question to include a [mcve] that shows your revised approach, for [example](http://stackoverflow.com/a/34319260/230513). – trashgod Sep 22 '16 at 23:12
  • 1
    Don't use a null layout. The scrollbars will appear automatically when the preferred size of the panel is greater than the size of the scroll pane. Since you are using a null layout the panel doesn't have a proper preferred size so the scrollbars are never display. Use [Layout Managers](http://docs.oracle.com/javase/tutorial/uiswing/layout/index.html)!!! – camickr Sep 23 '16 at 00:14

0 Answers0