1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
/*
* Toolbox.java
*
* Created on 23 February 2003, 09:59
*/
package org.tigris.toolbutton;
import java.awt.GridLayout;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JToolBar;
/**
* A toolbar where buttons are shown in a grid instead of a row.
* @author Bob Tarling
*/
public class ToolBox extends JToolBar {
private int _rows;
private int _cols;
/** Creates a new instance of ToolBox
* @param rows the number of rows to display in the toolbox
* @param cols the number of columns to display in the toolbox
*/
public ToolBox(int rows, int cols) {
this(rows, cols, false);
}
/** Creates a new instance of ToolBox
* @param rows the number of rows to display in the toolbox
* @param cols the number of columns to display in the toolbox
*/
public ToolBox(int rows, int cols, boolean rollover) {
super();
setRollover(rollover);
_rows = rows;
_cols = cols;
setLayout(new GridLayout(_rows,_cols));
setFloatable(false);
}
/**
* Turn on/off the rollover effect.
* @param rollover true to turn rollover effects on
*/
public void setRollover(boolean rollover) {
// TODO Check for JDK1.4 before calling super class setRollover
//super.setRollover(rollover);
//this._rollover = rollover;
// TODO Check for JDK1.4 before using Boolean.valueOf(rollover)
//this.putClientProperty("JToolBar.isRollover", Boolean.valueOf(rollover));
Boolean showRollover = Boolean.FALSE;
if (rollover) showRollover = Boolean.TRUE;
this.putClientProperty("JToolBar.isRollover", showRollover);
}
public JButton add(Action action) {
JButton button;
if (action instanceof ModalAction) {
button = new ModalButton(action);
add(button);
} else {
button = super.add(action);
}
return button;
}
}
|