001: package wingset;
002:
003: import org.wings.*;
004: import org.wings.style.CSSProperty;
005: import org.wings.style.CSSStyleSheet;
006: import org.wings.util.SStringBuilder;
007:
008: import java.awt.event.ActionEvent;
009: import java.awt.*;
010:
011: public class DesktopPaneExample extends WingSetPane {
012:
013: private SIcon windowIcon;
014:
015: private static final int FRAME_COUNT = 5;
016: private ComponentControls controls;
017: private SDesktopPane desktopPane = new SDesktopPane();
018:
019: protected SComponent createControls() {
020: controls = new DesktopPaneControls();
021: return controls;
022: }
023:
024: protected SComponent createExample() {
025: windowIcon = new SResourceIcon("org/wings/icons/window.png");
026:
027: for (int i = 0; i < FRAME_COUNT; i++) {
028: SInternalFrame iFrame = new SInternalFrame();
029: iFrame.getContentPane().setLayout(
030: new SBoxLayout(SConstants.VERTICAL));
031: iFrame.getContentPane().setHorizontalAlignment(
032: SConstants.LEFT_ALIGN);
033: iFrame.getContentPane().setPreferredSize(
034: SDimension.FULLWIDTH);
035: iFrame.setTitle("A Long Title of Frame " + (i + 1));
036: iFrame.setIcon(windowIcon);
037: desktopPane.add(iFrame);
038: fillFrame(iFrame);
039: // set some special contents & icons
040: if ((i % 2) == 0) {
041: SStringBuilder labelText = new SStringBuilder(
042: "some extra label...");
043: for (int j = 0; j <= i; j++) {
044: labelText.append("extra-");
045: iFrame.getContentPane().add(
046: new SLabel(labelText.toString()));
047: }
048: labelText.append("long.");
049: iFrame.getContentPane().add(
050: new SLabel(labelText.toString()));
051: }
052: }
053:
054: desktopPane.setVerticalAlignment(SConstants.TOP_ALIGN);
055: return desktopPane;
056: }
057:
058: private void fillFrame(SInternalFrame frame) {
059: STextField c = new STextField();
060: c.setHorizontalAlignment(SConstants.LEFT_ALIGN);
061: frame.getContentPane().add(c);
062: frame.getContentPane().add(new SLabel("This is a label"));
063: }
064:
065: private class DesktopPaneControls extends ComponentControls {
066:
067: public DesktopPaneControls() {
068: final SComboBox titleColor = new SComboBox(COLORS);
069: titleColor
070: .addActionListener(new java.awt.event.ActionListener() {
071: public void actionPerformed(ActionEvent e) {
072: Color color = (Color) ((Object[]) titleColor
073: .getSelectedItem())[1];
074: for (int i = 0; i < desktopPane
075: .getComponents().length; i++) {
076: SComponent component = desktopPane
077: .getComponents()[i];
078: component.setAttribute(
079: SInternalFrame.SELECTOR_TITLE,
080: CSSProperty.BACKGROUND_COLOR,
081: CSSStyleSheet
082: .getAttribute(color));
083: }
084: }
085: });
086: titleColor.setRenderer(new ObjectPairCellRenderer());
087: addControl(new SLabel(" title"));
088: addControl(titleColor);
089:
090: final SComboBox contentColor = new SComboBox(COLORS);
091: contentColor
092: .addActionListener(new java.awt.event.ActionListener() {
093: public void actionPerformed(ActionEvent e) {
094: Color color = (Color) ((Object[]) contentColor
095: .getSelectedItem())[1];
096: for (int i = 0; i < desktopPane
097: .getComponents().length; i++) {
098: SComponent component = desktopPane
099: .getComponents()[i];
100: component
101: .setAttribute(
102: SInternalFrame.SELECTOR_CONTENT,
103: CSSProperty.BACKGROUND_COLOR,
104: CSSStyleSheet
105: .getAttribute(color));
106: }
107: }
108: });
109: contentColor.setRenderer(new ObjectPairCellRenderer());
110: addControl(new SLabel(" content"));
111: addControl(contentColor);
112: }
113: }
114: }
|