1 package fr.ove.openmath.mathematica;
2
3 import javax.swing.*;
4 import java.awt.*;
5 import fr.ove.openmath.mfd2.OneColumnLayout;
6
7 /***
8 * The work sheet.
9 */
10 public class WorkSheet extends JPanel {
11 private JPanel mainPanel;
12
13 /***
14 * The default constructor.<BR>
15 * Constructs a <CODE>WorkSheet</CODE> with a width and height of 100
16 */
17 public WorkSheet() {
18 this(100, 100);
19 }
20
21 /***
22 * The constructor.
23 * @param width the width of the instance
24 * @param height the height of the instance
25 */
26 public WorkSheet(int width, int height) {
27 super();
28 setSize(width, height);
29 setLayout(new BorderLayout(0,0));
30
31 mainPanel = new JPanel();
32 mainPanel.setLayout(new OneColumnLayout());
33
34 JScrollPane scrollPane = new JScrollPane(mainPanel);
35 scrollPane.setBackground(Color.white);
36 super.add(scrollPane);
37 }
38
39 /***
40 * Adds a component to the instance.
41 * @param comp the component to add
42 */
43 public Component add(Component comp) {
44 return mainPanel.add(comp);
45 }
46
47 /***
48 * Adds a component to the instance at the specified index.
49 * @param comp the component to add.
50 * @param index the specified index.
51 */
52 public Component add(Component comp, int index) {
53 return mainPanel.add(comp, index);
54 }
55
56 /***
57 * Removes the specified component from the instance.
58 * @param comp the component to remove
59 */
60 public void remove(Component comp) {
61 mainPanel.remove(comp);
62 }
63
64 /***
65 * Removes the component at the specified index from the instance.
66 * @param index the index of the component to remove
67 */
68 public void remove(int index) {
69 mainPanel.remove(index);
70 }
71
72 /***
73 * Removes all the components from the instance
74 */
75 public void removeAll() {
76 mainPanel.removeAll();
77 }
78
79 /***
80 * Returns all the components in the instance
81 */
82 public Component[] getAll() {
83 return mainPanel.getComponents();
84 }
85 }