1 package fr.ove.openmath.mfd2;
2
3 import java.awt.*;
4 import fr.ove.openmath.mfd2.OneColumnLayout;
5
6 public class Mfd2ScrollPane extends Container {
7 private Panel mainPanel;
8
9 /***
10 * The default constructor.<BR>
11 * Constructs a <CODE>Mfd2ScrollPane</CODE> with a width and height of 100
12 * and 10 row
13 */
14 public Mfd2ScrollPane() {
15 this(100, 100, 10);
16 }
17
18 /***
19 * The constructor.
20 * @param width the width of the instance
21 * @param height the height of the instance
22 * @param nbRows the number of rows of the instance
23 */
24 public Mfd2ScrollPane(int width, int height, int nbRows) {
25 super();
26 setSize(width, height);
27 setLayout(new BorderLayout(0,0));
28
29 ScrollPane scrollPane = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
30 scrollPane.setSize(width, height);
31
32 mainPanel = new Panel();
33 mainPanel.setLayout(new OneColumnLayout());
34
35 scrollPane.add(mainPanel);
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 * Removes the specified component from the instance.
49 * @param comp the component to remove
50 */
51 public void remove(Component comp) {
52 mainPanel.remove(comp);
53 }
54
55 /***
56 * Removes the component at the specified index from the instance.
57 * @param index the index of the component to remove
58 */
59 public void remove(int index) {
60 mainPanel.remove(index);
61 }
62
63 /***
64 * Removes all the components from the instance
65 */
66 public void removeAll() {
67 mainPanel.removeAll();
68 }
69
70 /***
71 * Returns all the components in the instance
72 */
73 public Component[] getAll() {
74 return mainPanel.getComponents();
75 }
76 }