001: package org.wings.example;
002:
003: import org.wings.*;
004: import org.wings.plaf.WingSetExample;
005: import org.wings.border.SLineBorder;
006:
007: import java.awt.event.*;
008:
009: /**
010: * @author <a href="mailto:haaf@mercatis.de">Armin Haaf</a>
011: */
012: public class SplitPaneExample implements WingSetExample {
013: //private SplitPaneControls controls;
014: private SSplitPane splitPane;
015:
016: /*
017: protected SComponent createControls() {
018: controls = new SplitPaneControls();
019: return controls;
020: }
021: */
022:
023: public void activateExample() {
024: SLabel left = new SLabel("left");
025: left.setPreferredSize(SDimension.FULLAREA);
026: left.setBorder(new SLineBorder(1));
027: SLabel right = new SLabel("right");
028: right.setPreferredSize(SDimension.FULLAREA);
029: right.setBorder(new SLineBorder(1));
030: splitPane = new SSplitPane(SSplitPane.HORIZONTAL_SPLIT, left,
031: right) {
032: public void fireIntermediateEvents() {
033: super .fireIntermediateEvents();
034: //controls.dividerLocationTextField.setText("" + getDividerLocation());
035: }
036: };
037: splitPane.setPreferredSize(SDimension.FULLAREA);
038:
039: //controls.addControllable(splitPane);
040: }
041:
042: public void passivateExample() {
043: //To change body of implemented methods use File | Settings | File Templates.
044: }
045:
046: public SComponent getExample() {
047: return splitPane;
048: }
049:
050: public String getExampleName() {
051: return "SplitPane";
052: }
053:
054: public String getExampleGroup() {
055: return "Experiment";
056: }
057:
058: /*
059: class SplitPaneControls
060: extends ComponentControls {
061: private final String[] ORIENTATIONS = new String[] { "horizontal", "vertical" };
062: public STextField dividerLocationTextField;
063:
064: public SplitPaneControls() {
065: widthTextField.setText("100%");
066: heightTextField.setText("100%");
067:
068: final SComboBox orientationCombo = new SComboBox(ORIENTATIONS);
069: orientationCombo.addItemListener(new ItemListener() {
070: public void itemStateChanged(ItemEvent e) {
071: if (ORIENTATIONS[0].equals(orientationCombo.getSelectedItem())) {
072: splitPane.setOrientation(SSplitPane.HORIZONTAL_SPLIT);
073: }
074: else if (ORIENTATIONS[1].equals(orientationCombo.getSelectedItem())) {
075: splitPane.setOrientation(SSplitPane.VERTICAL_SPLIT);
076: }
077: }
078: });
079:
080: final STextField dividerSizeTextField = new STextField();
081: dividerSizeTextField.setText("4");
082: dividerSizeTextField.setColumns(1);
083: dividerSizeTextField.setToolTipText("length only (example: '4')");
084: dividerSizeTextField.addActionListener(new ActionListener() {
085: public void actionPerformed(ActionEvent event) {
086: try {
087: int dividerSize = Integer.parseInt(dividerSizeTextField.getText());
088: splitPane.setDividerSize(dividerSize);
089: }
090: catch (NumberFormatException e) {}
091: }
092: });
093:
094: dividerLocationTextField = new STextField();
095: dividerLocationTextField.setText("-1");
096: dividerLocationTextField.setColumns(3);
097: dividerLocationTextField.setToolTipText("length only (example: '4')");
098: dividerLocationTextField.addActionListener(new ActionListener() {
099: public void actionPerformed(ActionEvent event) {
100: try {
101: int dividerSize = Integer.parseInt(dividerLocationTextField.getText());
102: splitPane.setDividerLocation(dividerSize);
103: }
104: catch (NumberFormatException e) {}
105: }
106: });
107:
108: addControl(new SLabel(" orientation"));
109: addControl(orientationCombo);
110: addControl(new SLabel(" divider size"));
111: addControl(dividerSizeTextField);
112: addControl(new SLabel(" divider location"));
113: addControl(dividerLocationTextField);
114: }
115: }
116: */
117: }
|