Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

[Java] Best container to use?

Options
  • 01-03-2006 9:28pm
    #1
    Registered Users 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 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 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 Posts: 383 ✭✭cherrio


    Sweet :) Thx for the help.


Advertisement