Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

[Java] Best container to use?

  • 01-03-2006 09:28PM
    #1
    Registered Users, Registered Users 2 Posts: 383 ✭✭


    OK, need advice on the best Swing container to use. Basically I have JPanels appearing on "the container", this container has to be able to scroll.

    Its for an application similar to Rational Rose. Any suggestions?


Comments

  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Put your JPanels inside a JScrollPane. Voila, scrolling.


  • Registered Users, Registered Users 2 Posts: 383 ✭✭cherrio


    thanks for the quick reply :)

    Trying that at the moment, but its refusing to scroll. Even setting the setHorizontalScrollBarPolicy() the scroll bar remain inactive. Any suggestions?

    	private JScrollPane getScrPnl() {
    		if (scrPnl == null) {
    			scrPnl = new JScrollPane();
    			scrPnl.setViewportView(getPnlXMLScreen());
    			scrPnl.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    			scrPnl.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    		}
    		return scrPnl;
    	}
    


  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Are you making sure to make the JPanel larger that the size of the container window?


  • Registered Users, Registered Users 2 Posts: 383 ✭✭cherrio


    setting pnlXMLScreen.setPreferredSize(new Dimension(1000, 1000));

    Gets the scroll bars to appear and function. But the elements cannot be put outside that area. Is dynamically changing the PreferredSize as I add componets the way to do it?


  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Yep.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 383 ✭✭cherrio


    Sweet :) Thx for the help.


Advertisement