01: /*
02: * Created on Sep 29, 2004
03: *
04: * @author ctaylor
05: *
06: */
07: package com.pk.script.ui;
08:
09: import java.awt.Color;
10: import java.awt.Dimension;
11: import java.awt.event.ActionListener;
12: import java.util.List;
13:
14: import javax.swing.BorderFactory;
15: import javax.swing.JPanel;
16: import javax.swing.JScrollPane;
17: import javax.swing.JTable;
18: import javax.swing.ListSelectionModel;
19: import javax.swing.event.ListSelectionListener;
20:
21: import com.pk.script.Script;
22:
23: /**
24: * @author ctaylor
25: *
26: */
27: public class CommandTablePanel extends JPanel {
28: /**
29: *
30: */
31: private static final long serialVersionUID = 405442575432649568L;
32: private JTable commandTable;
33: private Script script;
34:
35: /**
36: *
37: */
38: public CommandTablePanel(ActionListener argActionListener) {
39: this .setSize(500, 300);
40: commandTable = new JTable(new CommandTableModel(this ));
41: commandTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
42: commandTable
43: .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
44: commandTable.setSize(new Dimension(500, 500));
45: commandTable.getColumnModel().getColumn(0).setPreferredWidth(
46: 500);
47: commandTable.getSelectionModel().addListSelectionListener(
48: (ListSelectionListener) argActionListener);
49: JScrollPane scrollPane = new JScrollPane(commandTable);
50: commandTable.setPreferredScrollableViewportSize(new Dimension(
51: 650, 300));
52:
53: this .add(scrollPane);
54: this .setBorder(BorderFactory.createLineBorder(Color.black));
55: }
56:
57: /**
58: * @return Returns the commands.
59: */
60: public List getCommands() {
61: return getScript().getCommands();
62: }
63:
64: /**
65: * @return Returns the script.
66: */
67: public Script getScript() {
68: if (script == null) {
69: script = new Script();
70: }
71: return script;
72: }
73:
74: /**
75: * @param script The script to set.
76: */
77: public void setScript(Script script) {
78: this .script = script;
79: }
80:
81: /**
82: * @return Returns the commandTable.
83: */
84: public JTable getCommandTable() {
85: return commandTable;
86: }
87: }
|