home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / VCAFE.3.0A / Sample.bin / TableExample4.java < prev    next >
Text File  |  1998-09-28  |  3KB  |  112 lines

  1. import com.sun.java.swing.*;
  2. import java.awt.*;
  3. import com.sun.java.swing.*;
  4. import com.sun.java.swing.table.*;
  5. import com.symantec.itools.swing.models.StringTableModel;
  6.  
  7. /*
  8.      A GUI version of  TableExample4 example from Sun.
  9.    
  10.     An example of a JTable using a  StringTableModel, with a combo box
  11.     for editing one of the columns.
  12. */
  13.  
  14. public class TableExample4 extends com.sun.java.swing.JFrame
  15. {
  16.     public TableExample4()
  17.     {
  18.         // This code is automatically generated by Visual Cafe when you add
  19.         // components to the visual environment. It instantiates and initializes
  20.         // the components. To modify the code, only use code syntax that matches
  21.         // what Visual Cafe can generate, or Visual Cafe may be unable to back
  22.         // parse your Java file into its visual environment.
  23.         //{{INIT_CONTROLS
  24.         setTitle("Table Example 4");
  25.         setDefaultCloseOperation(com.sun.java.swing.JFrame.DISPOSE_ON_CLOSE);
  26.         getContentPane().setLayout(new BorderLayout(0,0));
  27.         getContentPane().setFont(new Font("Dialog", Font.PLAIN, 0));
  28.         setSize(405,305);
  29.         setVisible(false);
  30.         {
  31.             String[] tempString = new String[10];
  32.             tempString[0] = "Jeff,Peil,Blue";
  33.             tempString[1] = "Kevin,Kenan,Red";
  34.             tempString[2] = "Tim,Hammock,Green";
  35.             tempString[3] = "Ted,Flug,Orange";
  36.             tempString[4] = "Steve,Howard,Black";
  37.             tempString[5] = "Scott,Morrison,Purple";
  38.             tempString[6] = "Steve,Wolf,Brown";
  39.             tempString[7] = "Matthew,Hopkins,Yellow";
  40.             tempString[8] = "Todd,Edman,White";
  41.             tempString[9] = "Christopher,Bernard,Cyan";
  42.             stringTableModel1.setItems(tempString);
  43.         }
  44.         stringTableModel1.setColumnHeaders("First Name,Last Name,Favorite Color");
  45.         stringTableModel1.setEditable(true);
  46.         //$$ stringTableModel1.move(0,0);
  47.         JScrollPane1.setOpaque(true);
  48.         getContentPane().add("Center", JScrollPane1);
  49.         JScrollPane1.setBounds(0,0,405,305);
  50.         JTable1.setModel(stringTableModel1);
  51.         JScrollPane1.getViewport().add(JTable1);
  52.         JTable1.setBounds(0,0,402,283);
  53.         //}}
  54.         
  55.         JComboBox jCombo = new JComboBox();
  56.         jCombo.addItem("Brown");
  57.         jCombo.addItem("Gold");
  58.         jCombo.addItem("Blue");
  59.         jCombo.addItem("Red");
  60.         jCombo.addItem("Green");
  61.         jCombo.addItem("Purple");
  62.         jCombo.addItem("Orange");
  63.         jCombo.addItem("Yellow");
  64.         jCombo.addItem("Black");
  65.         jCombo.addItem("White");
  66.         jCombo.addItem("Cyan");
  67.  
  68.         TableColumn colorColumn = JTable1.getColumn("Favorite Color");
  69.         // Use the combo box as the editor in the "Favorite Color" column.
  70.         colorColumn.setCellEditor(new DefaultCellEditor(jCombo));
  71.  
  72.  
  73.         //{{INIT_MENUS
  74.         //}}
  75.     
  76.         //{{REGISTER_LISTENERS
  77.         SymWindow aSymWindow = new SymWindow();
  78.         this.addWindowListener(aSymWindow);
  79.         //}}
  80.     }
  81.  
  82.     static public void main(String args[])
  83.     {
  84.         TableExample4 te = new TableExample4();
  85.         te.setVisible(true);
  86.     }
  87.  
  88.     //{{DECLARE_CONTROLS
  89.     com.symantec.itools.swing.models.StringTableModel stringTableModel1 = new com.symantec.itools.swing.models.StringTableModel();
  90.     com.sun.java.swing.JScrollPane JScrollPane1 = new com.sun.java.swing.JScrollPane();
  91.     com.sun.java.swing.JTable JTable1 = new com.sun.java.swing.JTable();
  92.     //}}
  93.     
  94.     //{{DECLARE_MENUS
  95.     //}}
  96.  
  97.  
  98.     class SymWindow extends java.awt.event.WindowAdapter
  99.     {
  100.         public void windowClosing(java.awt.event.WindowEvent event)
  101.         {
  102.             Object object = event.getSource();
  103.             if (object == TableExample4.this)
  104.                 TableExample4_windowClosing(event);
  105.         }
  106.     }
  107.  
  108.     void TableExample4_windowClosing(java.awt.event.WindowEvent event)
  109.     {
  110.         System.exit(0);
  111.     }
  112. }