Methods Summary |
---|
public javax.swing.JButton | add(javax.swing.Action a)Adds a new JButton which dispatches the action.
As of 1.3, this is no longer the preferred method for adding
Action s to a container. Instead it is recommended
to configure a control with an action using
using setAction , and then add that control directly
to the Container .
JButton b = createActionComponent(a);
b.setAction(a);
add(b);
return b;
|
protected void | addImpl(java.awt.Component comp, java.lang.Object constraints, int index)If a JButton is being added, it is initially
set to be disabled.
if (comp instanceof Separator) {
if (getOrientation() == VERTICAL) {
( (Separator)comp ).setOrientation(JSeparator.HORIZONTAL);
} else {
( (Separator)comp ).setOrientation(JSeparator.VERTICAL);
}
}
super.addImpl(comp, constraints, index);
if (comp instanceof JButton) {
((JButton)comp).setDefaultCapable(false);
}
|
public void | addSeparator()Appends a separator of default size to the end of the tool bar.
The default size is determined by the current look and feel.
addSeparator(null);
|
public void | addSeparator(java.awt.Dimension size)Appends a separator of a specified size to the end
of the tool bar.
JToolBar.Separator s = new JToolBar.Separator( size );
add(s);
|
private void | checkOrientation(int orientation)
switch ( orientation )
{
case VERTICAL:
case HORIZONTAL:
break;
default:
throw new IllegalArgumentException( "orientation must be one of: VERTICAL, HORIZONTAL" );
}
|
protected java.beans.PropertyChangeListener | createActionChangeListener(javax.swing.JButton b)Returns a properly configured PropertyChangeListener
which updates the control as changes to the Action occur,
or null if the default
property change listener for the control is desired.
As of 1.3, this is no longer the preferred method for adding
Action s to a Container .
Instead it is recommended to configure a control with an action
using setAction , and then add that control directly
to the Container .
return null;
|
protected javax.swing.JButton | createActionComponent(javax.swing.Action a)Factory method which creates the JButton for
Action s added to the JToolBar .
The default name is empty if a null action is passed.
As of 1.3, this is no longer the preferred method for adding
Action s to a Container .
Instead it is recommended to configure a control with an action
using setAction , and then add that control directly
to the Container .
String text = a!=null? (String)a.getValue(Action.NAME) : null;
Icon icon = a!=null? (Icon)a.getValue(Action.SMALL_ICON) : null;
boolean enabled = a!=null? a.isEnabled() : true;
String tooltip = a!=null?
(String)a.getValue(Action.SHORT_DESCRIPTION) : null;
JButton b = new JButton(text, icon) {
protected PropertyChangeListener createActionPropertyChangeListener(Action a) {
PropertyChangeListener pcl = createActionChangeListener(this);
if (pcl==null) {
pcl = super.createActionPropertyChangeListener(a);
}
return pcl;
}
};
if (icon !=null) {
b.putClientProperty("hideActionText", Boolean.TRUE);
}
b.setHorizontalTextPosition(JButton.CENTER);
b.setVerticalTextPosition(JButton.BOTTOM);
b.setEnabled(enabled);
b.setToolTipText(tooltip);
return b;
|
public javax.accessibility.AccessibleContext | getAccessibleContext()Gets the AccessibleContext associated with this JToolBar.
For tool bars, the AccessibleContext takes the form of an
AccessibleJToolBar.
A new AccessibleJToolBar instance is created if necessary.
if (accessibleContext == null) {
accessibleContext = new AccessibleJToolBar();
}
return accessibleContext;
|
public java.awt.Component | getComponentAtIndex(int i)Returns the component at the specified index.
int ncomponents = this.getComponentCount();
if ( i >= 0 && i < ncomponents) {
Component[] component = this.getComponents();
return component[i];
}
return null;
|
public int | getComponentIndex(java.awt.Component c)Returns the index of the specified component.
(Note: Separators occupy index positions.)
int ncomponents = this.getComponentCount();
Component[] component = this.getComponents();
for (int i = 0 ; i < ncomponents ; i++) {
Component comp = component[i];
if (comp == c)
return i;
}
return -1;
|
public java.awt.Insets | getMargin()Returns the margin between the tool bar's border and
its buttons.
if(margin == null) {
return new Insets(0,0,0,0);
} else {
return margin;
}
|
public int | getOrientation()Returns the current orientation of the tool bar. The value is either
HORIZONTAL or VERTICAL .
return this.orientation;
|
public javax.swing.plaf.ToolBarUI | getUI()Returns the tool bar's current UI.
return (ToolBarUI)ui;
|
public java.lang.String | getUIClassID()Returns the name of the L&F class that renders this component.
return uiClassID;
|
public boolean | isBorderPainted()Gets the borderPainted property.
return paintBorder;
|
public boolean | isFloatable()Gets the floatable property.
return floatable;
|
public boolean | isRollover()Returns the rollover state.
Boolean rollover = (Boolean)getClientProperty("JToolBar.isRollover");
if (rollover != null) {
return rollover.booleanValue();
}
return false;
|
protected void | paintBorder(java.awt.Graphics g)Paints the tool bar's border if the borderPainted property
is true .
if (isBorderPainted())
{
super.paintBorder(g);
}
|
protected java.lang.String | paramString()Returns a string representation of this JToolBar .
This method
is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not
be null .
String paintBorderString = (paintBorder ?
"true" : "false");
String marginString = (margin != null ?
margin.toString() : "");
String floatableString = (floatable ?
"true" : "false");
String orientationString = (orientation == HORIZONTAL ?
"HORIZONTAL" : "VERTICAL");
return super.paramString() +
",floatable=" + floatableString +
",margin=" + marginString +
",orientation=" + orientationString +
",paintBorder=" + paintBorderString;
|
public void | setBorderPainted(boolean b)Sets the borderPainted property, which is
true if the border should be painted.
The default value for this property is true .
Some look and feels might not implement painted borders;
they will ignore this property.
if ( paintBorder != b )
{
boolean old = paintBorder;
paintBorder = b;
firePropertyChange("borderPainted", old, b);
revalidate();
repaint();
}
|
public void | setFloatable(boolean b)Sets the floatable property,
which must be true for the user to move the tool bar.
Typically, a floatable tool bar can be
dragged into a different position within the same container
or out into its own window.
The default value of this property is true .
Some look and feels might not implement floatable tool bars;
they will ignore this property.
if ( floatable != b )
{
boolean old = floatable;
floatable = b;
firePropertyChange("floatable", old, b);
revalidate();
repaint();
}
|
public void | setLayout(java.awt.LayoutManager mgr)
LayoutManager oldMgr = getLayout();
if (oldMgr instanceof PropertyChangeListener) {
removePropertyChangeListener((PropertyChangeListener)oldMgr);
}
super.setLayout(mgr);
|
public void | setMargin(java.awt.Insets m)Sets the margin between the tool bar's border and
its buttons. Setting to null causes the tool bar to
use the default margins. The tool bar's default Border
object uses this value to create the proper margin.
However, if a non-default border is set on the tool bar,
it is that Border object's responsibility to create the
appropriate margin space (otherwise this property will
effectively be ignored).
Insets old = margin;
margin = m;
firePropertyChange("margin", old, m);
revalidate();
repaint();
|
public void | setOrientation(int o)Sets the orientation of the tool bar. The orientation must have
either the value HORIZONTAL or VERTICAL .
If orientation is
an invalid value, an exception will be thrown.
checkOrientation( o );
if ( orientation != o )
{
int old = orientation;
orientation = o;
firePropertyChange("orientation", old, o);
revalidate();
repaint();
}
|
public void | setRollover(boolean rollover)Sets the rollover state of this toolbar. If the rollover state is true
then the border of the toolbar buttons will be drawn only when the
mouse pointer hovers over them. The default value of this property
is false.
The implementation of a look and feel may choose to ignore this
property.
putClientProperty("JToolBar.isRollover",
rollover ? Boolean.TRUE : Boolean.FALSE);
|
public void | setUI(javax.swing.plaf.ToolBarUI ui)Sets the L&F object that renders this component.
super.setUI(ui);
|
public void | updateUI()Notification from the UIFactory that the L&F has changed.
Called to replace the UI with the latest version from the
UIFactory .
setUI((ToolBarUI)UIManager.getUI(this));
// GTKLookAndFeel installs a different LayoutManager, and sets it
// to null after changing the look and feel, so, install the default
// if the LayoutManager is null.
if (getLayout() == null) {
setLayout(new DefaultToolBarLayout(getOrientation()));
}
invalidate();
|
private void | writeObject(java.io.ObjectOutputStream s)See readObject and writeObject in
JComponent for more
information about serialization in Swing.
s.defaultWriteObject();
if (getUIClassID().equals(uiClassID)) {
byte count = JComponent.getWriteObjCounter(this);
JComponent.setWriteObjCounter(this, --count);
if (count == 0 && ui != null) {
ui.installUI(this);
}
}
|