summaryrefslogtreecommitdiffstats
path: root/libjava/javax/swing/JToolBar.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/javax/swing/JToolBar.java')
-rw-r--r--libjava/javax/swing/JToolBar.java186
1 files changed, 111 insertions, 75 deletions
diff --git a/libjava/javax/swing/JToolBar.java b/libjava/javax/swing/JToolBar.java
index ebc469212c8..e6db8720c2c 100644
--- a/libjava/javax/swing/JToolBar.java
+++ b/libjava/javax/swing/JToolBar.java
@@ -40,7 +40,9 @@ package javax.swing;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
+import java.awt.GridLayout;
import java.awt.Insets;
+import java.awt.LayoutManager;
import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.io.ObjectOutputStream;
@@ -59,58 +61,46 @@ import javax.swing.plaf.ToolBarUI;
public class JToolBar extends JComponent
implements SwingConstants, Accessible
{
-
- //-------------------------------------------------------------
- // Classes ----------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * AccessibleJToolBar
- */
- protected class AccessibleJToolBar extends AccessibleJComponent {
-
- //-------------------------------------------------------------
- // Initialization ---------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * Constructor AccessibleJToolBar
- * @param component TODO
- */
- protected AccessibleJToolBar(JToolBar component) {
- super(component);
- // TODO
- } // AccessibleJToolBar()
-
-
- //-------------------------------------------------------------
- // Methods ----------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * getAccessibleStateSet
- * @returns AccessibleStateSet
- */
- public AccessibleStateSet getAccessibleStateSet() {
- return null; // TODO
- } // getAccessibleStateSet()
-
- /**
- * getAccessibleRole
- * @returns AccessibleRole
- */
- public AccessibleRole getAccessibleRole() {
- return AccessibleRole.TOOL_BAR;
- } // getAccessibleRole()
-
-
- } // AccessibleJToolBar
+ /**
+ * AccessibleJToolBar
+ */
+ protected class AccessibleJToolBar extends AccessibleJComponent
+ {
+ private static final long serialVersionUID = -5516888265903814215L;
+
+ /**
+ * Constructor AccessibleJToolBar
+ */
+ protected AccessibleJToolBar()
+ {
+ }
+
+ /**
+ * getAccessibleStateSet
+ * @return AccessibleStateSet
+ */
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ return null; // TODO
+ }
+
+ /**
+ * getAccessibleRole
+ * @return AccessibleRole
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.TOOL_BAR;
+ }
+ }
/**
* Separator
*/
public static class Separator extends JSeparator {
+ private static final long serialVersionUID = -1656745644823105219L;
+
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
@@ -196,7 +186,27 @@ public class JToolBar extends JComponent
} // Separator
-
+// /**
+// * DefaultJToolBarLayout
+// */
+// private class DefaultJToolBarLayout {
+//
+// private void DefaultJToolBarLayout() {
+// }
+//
+// private LayoutManager getLayout() {
+// switch (JToolBar.this.getOrientation()) {
+// case HORIZONTAL: setLayout(new GridLayout(1, 0, 4, 4));
+// break;
+// case VERTICAL: setLayout(new GridLayout(0, 1, 4, 4));
+// break;
+// }
+// }
+// } // DefaultJToolBarLayout
+
+
+ private static final long serialVersionUID = -1269915519555129643L;
+
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
@@ -224,8 +234,13 @@ public class JToolBar extends JComponent
/**
* orientation
*/
- private int orientation;
+ private int orientation = HORIZONTAL;
+
+// protected transient DefaultJToolBarLayout toolbarLayout;
+ /** Fired in a PropertyChangeEvent when the "orientation" property changes.
+ */
+ public static final String ORIENTATION_CHANGED_PROPERTY = "orientation";
//-------------------------------------------------------------
// Initialization ---------------------------------------------
@@ -235,32 +250,37 @@ public class JToolBar extends JComponent
* Constructor JToolBar
*/
public JToolBar() {
- // TODO
+ this(null);
} // JToolBar()
/**
* Constructor JToolBar
- * @param orientation TODO
+ * @param orientation JToolBar orientation (HORIZONTAL or VERTICAL)
*/
public JToolBar(int orientation) {
- // TODO
+ this(null, orientation);
} // JToolBar()
/**
* Constructor JToolBar
- * @param name TODO
+ * @param name Name assigned to undocked tool bar.
*/
public JToolBar(String name) {
- // TODO
+ this(name, HORIZONTAL);
} // JToolBar()
/**
* Constructor JToolBar
- * @param name TODO
- * @param orientation TODO
+ * @param name Name assigned to undocked tool bar.
+ * @param orientation JToolBar orientation (HORIZONTAL or VERTICAL)
*/
public JToolBar(String name, int orientation) {
- // TODO
+ setName(name);
+ if (orientation != HORIZONTAL && orientation != VERTICAL)
+ throw new IllegalArgumentException(orientation + " is not a legal orientation");
+ this.orientation = orientation;
+// toolbarLayout = new DefaultJToolBarLayout();
+ updateUI();
} // JToolBar()
@@ -299,6 +319,7 @@ public class JToolBar extends JComponent
* @returns ToolBarUI
*/
public ToolBarUI getUI() {
+ System.out.println("ui = " + ui);
return (ToolBarUI) ui;
} // getUI()
@@ -314,8 +335,7 @@ public class JToolBar extends JComponent
* updateUI
*/
public void updateUI() {
- setUI((ToolBarUI) UIManager.get(this));
- invalidate();
+ setUI((ToolBarUI)UIManager.getUI(this));
} // updateUI()
/**
@@ -397,15 +417,31 @@ public class JToolBar extends JComponent
* @returns int
*/
public int getOrientation() {
- return 0; // TODO
+ return this.orientation;
} // getOrientation()
/**
+ * setLayout
+ * @param mgr
+ */
+ public void setLayout(LayoutManager mgr) {
+ super.setLayout(mgr);
+ } // setLayout()
+
+ /**
* setOrientation
- * @param orientation TODO
+ * @param orientation
*/
public void setOrientation(int orientation) {
- // TODO
+ if (orientation != HORIZONTAL && orientation != VERTICAL)
+ throw new IllegalArgumentException(orientation + " is not a legal orientation");
+ if (orientation != this.orientation)
+ {
+ int oldOrientation = this.orientation;
+ this.orientation = orientation;
+ firePropertyChange(ORIENTATION_CHANGED_PROPERTY, oldOrientation,
+ this.orientation);
+ }
} // setOrientation()
/**
@@ -447,10 +483,11 @@ public class JToolBar extends JComponent
* @param constraints TODO
* @param index TODO
*/
+ /*
protected void addImpl(Component component, Object constraints, int index) {
// TODO
} // addImpl()
-
+ */
/**
* paramString
* @returns String
@@ -459,16 +496,15 @@ public class JToolBar extends JComponent
return null; // TODO
} // paramString()
- /**
- * getAccessibleContext
- * @returns AccessibleContext
- */
- public AccessibleContext getAccessibleContext() {
- if (accessibleContext == null) {
- accessibleContext = new AccessibleJToolBar(this);
- } // if
- return accessibleContext;
- } // getAccessibleContext()
-
-
-} // JToolBar
+ /**
+ * getAccessibleContext
+ * @return AccessibleContext
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ if (accessibleContext == null)
+ accessibleContext = new AccessibleJToolBar();
+
+ return accessibleContext;
+ }
+}
OpenPOWER on IntegriCloud