summaryrefslogtreecommitdiff
path: root/javax/swing/BoxLayout.java
diff options
context:
space:
mode:
authorRonald Veldema <rveldema@cs.vu.nl>2002-03-11 15:48:06 +0000
committerRonald Veldema <rveldema@cs.vu.nl>2002-03-11 15:48:06 +0000
commit5158e5cd020ca88753de8793a40dcda66f3ea8ae (patch)
treee8ff44926abd1e1fd9f058139dc1476c54d24f9c /javax/swing/BoxLayout.java
parenteed4707c499f072d7e36d8499638b859a370fc57 (diff)
downloadclasspath-5158e5cd020ca88753de8793a40dcda66f3ea8ae.tar.gz
Added my embryonic javax.swing implementation,
since there are no makefiles for it yet nobody should notice its addition (it shouldn't break anything by adding it this early) R.
Diffstat (limited to 'javax/swing/BoxLayout.java')
-rw-r--r--javax/swing/BoxLayout.java107
1 files changed, 107 insertions, 0 deletions
diff --git a/javax/swing/BoxLayout.java b/javax/swing/BoxLayout.java
new file mode 100644
index 000000000..3ee0f344c
--- /dev/null
+++ b/javax/swing/BoxLayout.java
@@ -0,0 +1,107 @@
+package javax.swing;
+
+import java.awt.*;
+
+public class BoxLayout implements LayoutManager2
+{
+ GridLayout gridbag;
+
+ final static int X_AXIS = 0;
+ final static int Y_AXIS = 1;
+
+ int way = X_AXIS;
+
+ BoxLayout(JComponent p,
+ int way)
+ {
+ int width = 0;
+ int height = 0;
+
+ this.way = way;
+
+ if (way == X_AXIS)
+ {
+ width = 1;
+ }
+ else
+ {
+ height = 1;
+ }
+
+
+ gridbag = new GridLayout(width, height);
+ }
+
+ BoxLayout(int way)
+ {
+ this(null,way);
+ }
+
+
+ public void addLayoutComponent(String name, Component comp)
+ {
+ if (way == X_AXIS)
+ {
+ gridbag.setColumns( gridbag.getColumns() + 1);
+ }
+ else
+ {
+ gridbag.setRows( gridbag.getRows() + 1);
+ }
+ }
+
+ public void removeLayoutComponent(Component comp)
+ {
+ gridbag.removeLayoutComponent(comp);
+ if (way == X_AXIS)
+ {
+ gridbag.setColumns( gridbag.getColumns() - 1);
+ }
+ else
+ {
+ gridbag.setRows( gridbag.getRows() - 1);
+ }
+ }
+
+ public Dimension preferredLayoutSize(Container parent)
+ {
+ return gridbag.preferredLayoutSize(parent);
+ }
+
+ public Dimension minimumLayoutSize(Container parent)
+ {
+ return gridbag.minimumLayoutSize(parent);
+ }
+
+ public void layoutContainer(Container parent)
+ {
+ gridbag.layoutContainer(parent);
+ }
+
+ public void addLayoutComponent ( Component child, Object constraints )
+ {
+ addLayoutComponent("", child);
+ }
+
+ public float getLayoutAlignmentX ( Container parent )
+ {
+ return 0;
+ }
+
+ public float getLayoutAlignmentY ( Container parent )
+ {
+ return 0;
+ }
+
+ public void invalidateLayout ( Container parent )
+ {
+ }
+
+ public Dimension maximumLayoutSize ( Container parent )
+ {
+ return preferredLayoutSize(parent);
+ }
+}
+
+
+