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); } }
@Override public void setContainer(SContainer c) { container = c; if (container != null) { container.setPreferredSize(this.preferredSize); } }
/** * Sets the container for the contentPane. * * @param container the container for the contentPane. */ public void setContentPane(SContainer container) { SContainer oldVal = this.contentPane; if (this.contentPane != null) { super.remove(contentPane); } this.contentPane = container; super.addComponent(this.contentPane, null, 0); propertyChangeSupport.firePropertyChange("contentPane", oldVal, this.contentPane); }
/** * Removes all components from the container. */ public void removeAll() { while (getComponentCount() > 0) { remove(0); } }
/** * Removes the component at the given position from the container. * * @param index remove the component at position <i>index</i> * from this container */ public void remove(int index) { SComponent c = getComponent(index); remove(c); }
@Override public void add(SComponent c, Object constraint) { getContentPane().add(c, constraint); }
private SFrame createControllerFrame() { SFrame frame = new SFrame(); frame .setPreferredSize(new SDimension(frameWidth, frameHeight/* WingsUtil.FULL_DIM_PERCENT */)); cardPanel = new SPanel(new SCardLayout()); cardPanel.setPreferredSize(SDimension.FULLAREA); frame.getContentPane().add(createApplicationMenuBar(), SBorderLayout.NORTH); frame.getContentPane().add(cardPanel, SBorderLayout.CENTER); frame.getContentPane().setPreferredSize(SDimension.FULLAREA); return frame; }
imageLabel.setToolTipText(null); optionData.setPreferredSize(SDimension.FULLWIDTH); contents.add(imageLabel, SBorderLayout.WEST); contents.add(optionData, SBorderLayout.CENTER); optionButtons.add(optionNo, "NO"); optionButtons.add(optionCancel, "CANCEL"); optionButtons.add(optionYes, "YES"); optionButtons.add(optionOK, "OK"); optionButtons.setPreferredSize(SDimension.FULLWIDTH); optionButtons.setStyle("SOptionPaneButtons");
/** * Sets the component at <i>index</i> to <i>component</i> which must not be null. * An internal exception is raised if there is no tab at that index. * * @param index the tab index where the title should be set * @param component the component for the tab * @see #getComponentAt */ public void setComponentAt(int index, SComponent component) { contents.remove(index); SComponent oldVal = ((Page) pages.get(index)).component; ((Page) pages.get(index)).component = component; contents.add(component, component.getName(), index); component.setVisible(getSelectedIndex() == index); reload(); propertyChangeSupport.firePropertyChange("componentAt", oldVal, ((Page) pages.get(index)).component); }
public void showOption(SComponent c, String title, Object message) { if (title != null) setTitle(title); optionData.removeAll(); if (message instanceof SComponent) { optionData.add((SComponent) message); } else if (message != null) { StringTokenizer stringTokenizer = new StringTokenizer(message.toString(), "\n"); while (stringTokenizer.hasMoreElements()) { SLabel label = new SLabel(stringTokenizer.nextElement().toString()); if (SOptionPane.defaultSize != null && SOptionPane.defaultSize.getWidthInt() != SDimension.AUTO_INT) { label.setWordWrap(true); } optionData.add(label); } } setOwner(c); show(); }
/** * Adds a component to the container with the given constraint at * the given index. * * @param c the component to add * @param index the index of the component */ public void add(SComponent c, Object constraint, int index) { addComponent(c, constraint, index); }
/** * CAVEAT this did not work yet... We need to clone the layout manager as * well, so SLayoutManager must be Cloneable */ @Override public Object clone() { try { SContainer erg = (SContainer) super.clone(); // uiuiui, layout manager must be cloned as well,... // componentList and constraintList contain references to the // original components / constraints erg.getComponentList().clear(); erg.getConstraintList().clear(); for (int i = 0; i < getComponentCount(); i++) { erg.addComponent((SComponent) getComponent(i).clone()); } return erg; } catch (Exception e) { log.error("Unable to clone container", e); return null; } }
} else { c.getParent().remove(c); index = getComponentList().size(); getComponentList().add(index, c); getConstraintList().add(index, constraint); c.setParent(this); fireContainerEvent(SContainerEvent.COMPONENT_ADDED, c); reload();
public SComponent[] getComponents() { return layout.getContainer().getComponents(); } }
STemplateLayout layout = new STemplateLayout(resourcePath); final SFrame errorFrame = new SFrame(); errorFrame.getContentPane().setLayout(layout); errorFrame.getContentPane().add(errorStackTraceLabel, "EXCEPTION_STACK_TRACE"); errorFrame.getContentPane().add(errorMessageLabel, "EXCEPTION_MESSAGE"); errorFrame.getContentPane().add(versionLabel, "WINGS_VERSION");
public void setCG(PanelCG cg) { super.setCG(cg); } }
/** * Removes the component from the content pane. */ @Override public void remove(SComponent c) { contentPane.remove(c); }
/** * 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); } }
public void removeWindow(SWindow window) { if (!windowsPane.getComponentList().contains(window)) { return; } getSession().getReloadManager().setSuppressMode(true); windowsPane.remove(window); getSession().getReloadManager().setSuppressMode(false); if (isUpdatePossible() && SRootContainer.class.isAssignableFrom(getClass())) { update(((RootContainerCG) getCG()).getRemoveWindowUpdate(windowsPane, window)); } else { windowsPane.reload(); } }
/** * Adds a component to the container with the given constraint at the end * of the internal list. * * @param c the component to add * @param constraint the constraint for this component * @return the added component */ public SComponent addComponent(SComponent c, Object constraint) { return addComponent(c, constraint, getComponentList().size()); }