Bug 48597 - Support add(Factory.createComponent()) ;
Summary: Support add(Factory.createComponent()) ;
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: VE (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: VE Bugzilla inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-11 16:22 EST by Gili Mendel CLA
Modified: 2011-06-13 11:37 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gili Mendel CLA 2003-12-11 16:22:16 EST
==============

import javax.swing.Box;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;


public class MyGUI extends JPanel {

   private Box box = null;
   private JLabel label = null;
   private JButton button = null;
   private JList list = null;
   private DefaultListModel model = null;
   
   /**
    * This method initializes 
    * 
    */
   public MyGUI() {
      super();
      initialize();
   }
   /**
    * This method initializes this
    * 
    * @return void
    */
   private void initialize() {
        this.add(getBox());
        this.setSize(538, 247);
         
   }
   /**
    * Returns the box.
    * @return Box
    */
   public Box getBox() {
      if (box==null) {
         box = Box.createHorizontalBox();
         box.add(getLabel());
         box.add(Box.createHorizontalStrut(15));
         box.add(getButton());
         box.add(Box.createHorizontalStrut(15));
         box.add(getList());
      }
      return box;
   }

   /**
    * Sets the box.
    * @param box The box to set
    */
   public void setBox(Box box) {
      this.box = box;
   }

   /**
    * Returns the button.
    * @return JButton
    */
   public JButton getButton() {
      if (button==null) {
         button=new JButton("OK");
      }
      return button;
   }

   /**
    * Returns the label.
    * @return JLabel
    */
   public JLabel getLabel() {
      if (label==null) {
         label = new JLabel("My label");
      }
      return label;
   }

   /**
    * Sets the button.
    * @param button The button to set
    */
   public void setButton(JButton button) {
      this.button = button;
   }

   /**
    * Sets the label.
    * @param label The label to set
    */
   public void setLabel(JLabel label) {
      this.label = label;
   }

   /**
    * Returns the list.
    * @return JList
    */
   public JList getList() {
      if (list==null) {
         list = new JList();
         list.setSize(30, 42);
         list.setModel(getModel());
      }
      return list;
   }

   /**
    * Sets the list.
    * @param list The list to set
    */
   public void setList(JList list) {
      this.list = list;
   }

   /**
    * Returns the model.
    * @return DefaultListModel
    */
   public DefaultListModel getModel() {
      if (model==null) {
         model = new DefaultListModel();
         model.addElement("red");
         model.addElement("yellow");
         model.addElement("green");            
      }
      return model;
   }

   /**
    * Sets the model.
    * @param model The model to set
    */
   public void setModel(DefaultListModel model) {
      this.model = model;
   }

}  //  @jve:visual-info  decl-index=0 visual-constraint="0,0"