home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Sample.bin
/
TableExample4.java
< prev
next >
Wrap
Text File
|
1998-09-28
|
3KB
|
112 lines
import com.sun.java.swing.*;
import java.awt.*;
import com.sun.java.swing.*;
import com.sun.java.swing.table.*;
import com.symantec.itools.swing.models.StringTableModel;
/*
A GUI version of TableExample4 example from Sun.
An example of a JTable using a StringTableModel, with a combo box
for editing one of the columns.
*/
public class TableExample4 extends com.sun.java.swing.JFrame
{
public TableExample4()
{
// This code is automatically generated by Visual Cafe when you add
// components to the visual environment. It instantiates and initializes
// the components. To modify the code, only use code syntax that matches
// what Visual Cafe can generate, or Visual Cafe may be unable to back
// parse your Java file into its visual environment.
//{{INIT_CONTROLS
setTitle("Table Example 4");
setDefaultCloseOperation(com.sun.java.swing.JFrame.DISPOSE_ON_CLOSE);
getContentPane().setLayout(new BorderLayout(0,0));
getContentPane().setFont(new Font("Dialog", Font.PLAIN, 0));
setSize(405,305);
setVisible(false);
{
String[] tempString = new String[10];
tempString[0] = "Jeff,Peil,Blue";
tempString[1] = "Kevin,Kenan,Red";
tempString[2] = "Tim,Hammock,Green";
tempString[3] = "Ted,Flug,Orange";
tempString[4] = "Steve,Howard,Black";
tempString[5] = "Scott,Morrison,Purple";
tempString[6] = "Steve,Wolf,Brown";
tempString[7] = "Matthew,Hopkins,Yellow";
tempString[8] = "Todd,Edman,White";
tempString[9] = "Christopher,Bernard,Cyan";
stringTableModel1.setItems(tempString);
}
stringTableModel1.setColumnHeaders("First Name,Last Name,Favorite Color");
stringTableModel1.setEditable(true);
//$$ stringTableModel1.move(0,0);
JScrollPane1.setOpaque(true);
getContentPane().add("Center", JScrollPane1);
JScrollPane1.setBounds(0,0,405,305);
JTable1.setModel(stringTableModel1);
JScrollPane1.getViewport().add(JTable1);
JTable1.setBounds(0,0,402,283);
//}}
JComboBox jCombo = new JComboBox();
jCombo.addItem("Brown");
jCombo.addItem("Gold");
jCombo.addItem("Blue");
jCombo.addItem("Red");
jCombo.addItem("Green");
jCombo.addItem("Purple");
jCombo.addItem("Orange");
jCombo.addItem("Yellow");
jCombo.addItem("Black");
jCombo.addItem("White");
jCombo.addItem("Cyan");
TableColumn colorColumn = JTable1.getColumn("Favorite Color");
// Use the combo box as the editor in the "Favorite Color" column.
colorColumn.setCellEditor(new DefaultCellEditor(jCombo));
//{{INIT_MENUS
//}}
//{{REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow();
this.addWindowListener(aSymWindow);
//}}
}
static public void main(String args[])
{
TableExample4 te = new TableExample4();
te.setVisible(true);
}
//{{DECLARE_CONTROLS
com.symantec.itools.swing.models.StringTableModel stringTableModel1 = new com.symantec.itools.swing.models.StringTableModel();
com.sun.java.swing.JScrollPane JScrollPane1 = new com.sun.java.swing.JScrollPane();
com.sun.java.swing.JTable JTable1 = new com.sun.java.swing.JTable();
//}}
//{{DECLARE_MENUS
//}}
class SymWindow extends java.awt.event.WindowAdapter
{
public void windowClosing(java.awt.event.WindowEvent event)
{
Object object = event.getSource();
if (object == TableExample4.this)
TableExample4_windowClosing(event);
}
}
void TableExample4_windowClosing(java.awt.event.WindowEvent event)
{
System.exit(0);
}
}