/** * Make sure that the Container really has a CardLayout installed. * Otherwise havoc can ensue! */ void checkLayout(SContainer parent) { if (parent.getLayout() != this) { throw new IllegalArgumentException("wrong parent for CardLayout"); } }
/** * {@inheritDoc} */ @Override protected void showCardInPanel(SComponent cardsPeer, String cardName) { ((SCardLayout) ((SContainer) cardsPeer).getLayout()).show( (SContainer) cardsPeer, cardName); }
private static void rebuildPanel(SContainer oldPanel, SContainer newPanel) { SLayoutManager layoutManager = oldPanel.getLayout(); SComponent[] components = oldPanel.getComponents(); ArrayList constraints = oldPanel.getConstraintList(); oldPanel.removeAll(); oldPanel.setLayout(null); newPanel.setLayout(layoutManager); for (int i = 0; i < components.length; i++) { SComponent component = components[i]; Object constraint = constraints.get(i); newPanel.add(component, constraint); } }
/** * Renders a container using its Layout manager or fallback just one after another. */ public static void renderContainer(Device d, SContainer c) throws IOException { final SLayoutManager layout = c.getLayout(); if (layout == null) { d.print("<tbody><tr><td>"); // just write out the components one after another for (int i = 0; i < c.getComponentCount(); i++) { c.getComponent(i).write(d); } d.print("</td></tr></tbody>"); } else { layout.write(d); } }
@Override public void writeInternal(final Device device, final SComponent component) throws java.io.IOException { final SContainer container = (SContainer) component; final SLayoutManager layout = container.getLayout();