I've got a fair knowledge of Swing but I'm stuck with the following problem. I've defined a JFrame which contains 3 JPanels laid out horizontally across and a JScrollPane containing a JTable directly below. I need to dynamically replace the second JPanel depending on which Button was clicked on the Navigation Panel.A common scenario. What is the best way of doing this ? Would it be via some complex event-handling or is it a simple method call. Could someone please point me in the right direction? Thanks in advance
you could check out teh CardLayout in the java.awt package. this layout allows you to change panels like in a card deck (thus its names). if it doesnt solve your need or you dont want to use it, you can just stick to removing and adding diffrent panels all the time as the user presses the button.
You first have to get the button event. When the button is pressed get the SWING-object of your panel. Remove all components inside and then add the new items. Don't forget to initialize the new components first. If you have to do dynamic panels very often think about building an XML interface (see www.jeasy.de; run the Example and select the tabbedpane dynamic container). Is is build 100% dynamically because all GUI components are described in an XML file readed at runtime. Regards [ May 28, 2002: Message edited by: Harry Pfohl ] [ May 28, 2002: Message edited by: Harry Pfohl ]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com