Fixed edwin's code in response to his bug report(#8067). Bug was caused by not setting the button sizes correctly (Dimension.setSize() is not for setting component sizes).
This commit is contained in:
Родитель
246d818095
Коммит
7d583a9908
|
@ -42,65 +42,58 @@ import grendel.widgets.ToolBarButton;
|
|||
|
||||
public class GrendelToolBar extends JToolBar {
|
||||
|
||||
private ToolBarLayout layout;
|
||||
private ToolBarLayout layout;
|
||||
|
||||
public GrendelToolBar() {
|
||||
super();
|
||||
layout = new ToolBarLayout();
|
||||
setLayout(layout);
|
||||
setFloatable(false);
|
||||
}
|
||||
public GrendelToolBar() {
|
||||
super();
|
||||
layout = new ToolBarLayout();
|
||||
setLayout(layout);
|
||||
setFloatable(false);
|
||||
}
|
||||
|
||||
public Spring makeNewSpring() {
|
||||
return layout.createSpring();
|
||||
}
|
||||
public Spring makeNewSpring() {
|
||||
return layout.createSpring();
|
||||
}
|
||||
|
||||
public void addButton(UIAction aActionListener,
|
||||
public void addButton(UIAction aActionListener,
|
||||
String aImageName,
|
||||
String aText,
|
||||
String aToolTip) {
|
||||
ToolBarButton b = new ToolBarButton();
|
||||
ToolBarButton b = new ToolBarButton();
|
||||
|
||||
b.setHorizontalTextPosition(JButton.CENTER);
|
||||
b.setVerticalTextPosition(JButton.BOTTOM);
|
||||
Font f=b.getFont();
|
||||
Font nf=new Font(f.getName(), Font.PLAIN, f.getSize()-1);
|
||||
b.setFont(nf);
|
||||
b.setText(aText);
|
||||
b.setHorizontalTextPosition(JButton.CENTER);
|
||||
b.setVerticalTextPosition(JButton.BOTTOM);
|
||||
Font f=b.getFont();
|
||||
Font nf=new Font(f.getName(), Font.PLAIN, f.getSize()-2);
|
||||
b.setFont(nf);
|
||||
b.setText(aText);
|
||||
|
||||
b.setRolloverEnabled(true);
|
||||
b.setBorder(BorderFactory.createEmptyBorder());
|
||||
b.setMargin(new Insets(0,3,0,3));
|
||||
b.setToolTipText(aToolTip);
|
||||
b.setRolloverEnabled(true);
|
||||
b.setBorder(BorderFactory.createEmptyBorder());
|
||||
b.setToolTipText(aToolTip);
|
||||
|
||||
URL iconUrl = getClass().getResource("toolbar/mozilla/" + aImageName + ".gif");
|
||||
b.setIcon(new ImageIcon(iconUrl));
|
||||
//iconUrl = getClass().getResource("toolbar/mozilla/" + aImageName + "-disabled.gif");
|
||||
//b.setDisabledIcon(new ImageIcon(iconUrl));
|
||||
//iconUrl = getClass().getResource("toolbar/mozilla/" + aImageName + "-pressed.gif");
|
||||
//b.setPressedIcon(new ImageIcon(iconUrl));
|
||||
//iconUrl = getClass().getResource("toolbar/mozilla/" + aImageName + "-rollover.gif");
|
||||
//b.setRolloverIcon(new ImageIcon(iconUrl));
|
||||
URL iconUrl = getClass().getResource("toolbar/mozilla/" + aImageName + ".gif");
|
||||
b.setIcon(new ImageIcon(iconUrl));
|
||||
|
||||
Dimension d=b.getPreferredSize();
|
||||
double w=d.getWidth();
|
||||
if (w > 48) {
|
||||
d.setSize(w, 38);
|
||||
} else {
|
||||
d.setSize(48, 38);
|
||||
}
|
||||
b.setMinimumSize(d);
|
||||
b.setMaximumSize(d);
|
||||
b.setPreferredSize(d);
|
||||
|
||||
if (aActionListener != null) {
|
||||
b.addActionListener(aActionListener);
|
||||
} else {
|
||||
b.setEnabled(false);
|
||||
}
|
||||
|
||||
add(b);
|
||||
Dimension d=b.getPreferredSize();
|
||||
double w=d.getWidth();
|
||||
if (w > 52) {
|
||||
d = new Dimension((int)w, 50);
|
||||
} else {
|
||||
d = new Dimension(52, 50);
|
||||
}
|
||||
b.setMinimumSize(d);
|
||||
b.setMaximumSize(d);
|
||||
b.setPreferredSize(d);
|
||||
|
||||
if (aActionListener != null) {
|
||||
b.addActionListener(aActionListener);
|
||||
} else {
|
||||
b.setEnabled(false);
|
||||
}
|
||||
|
||||
add(b);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче