Revision 17656
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/buttonspanel/ButtonsPanel.java | ||
---|---|---|
18 | 18 |
*/ |
19 | 19 |
package org.gvsig.gui.beans.buttonspanel; |
20 | 20 |
|
21 |
import java.awt.Dimension; |
|
22 | 21 |
import java.awt.event.ActionEvent; |
23 | 22 |
import java.awt.event.ActionListener; |
24 |
import java.awt.geom.Rectangle2D; |
|
25 | 23 |
import java.util.ArrayList; |
26 | 24 |
import java.util.Iterator; |
27 | 25 |
|
28 |
import javax.swing.JButton; |
|
29 | 26 |
import javax.swing.JPanel; |
30 | 27 |
|
31 | 28 |
import org.gvsig.gui.beans.messages.Messages; |
29 |
import org.gvsig.gui.beans.swing.JButton; |
|
32 | 30 |
/** |
33 | 31 |
* <code>ButtonsPanel</code> ofrece un widget con un conjunto de botones |
34 | 32 |
* preestablecidos, aunque tambi?n se pueden a?adir botones con el m?todo |
... | ... | |
255 | 253 |
public void addButton(String text, int id) { |
256 | 254 |
JButton button = new JButton(); |
257 | 255 |
button.setText(text); |
258 |
|
|
256 |
/* |
|
259 | 257 |
Dimension current = new Dimension(90, 25); |
260 | 258 |
Rectangle2D rectangle = (button.getFontMetrics(button.getFont()).getStringBounds(button.getText(), button.getGraphics() )); |
261 | 259 |
Dimension extraSize = new Dimension(34, 12); |
262 | 260 |
Dimension desired = new Dimension((int)Math.max(current.getWidth(), rectangle.getWidth() + extraSize.getWidth()), (int)Math.max(current.getHeight(), rectangle.getHeight() + extraSize.getHeight())); |
263 | 261 |
|
264 | 262 |
button.setPreferredSize(desired); |
265 |
|
|
263 |
*/ |
|
266 | 264 |
buttonsList.add(button); |
267 | 265 |
button.setActionCommand(id + ""); |
268 | 266 |
button.addActionListener(new ActionListener() { |
Also available in: Unified diff