group = new ButtonGroup();
ImageIcon ii;
int i;
for (i = 1; i < 13; i++) {
ii = createIcon(new BasicStroke(i), 50, 20, true);
button = new JRadioButtonMenuItem(" ", ii, (int) width == i);//without the space as a parameter these instances look strange with some Look&Feel
button.setActionCommand(String.valueOf(i));
group.add(button);
button.addActionListener(listener);
button.setMargin( new java.awt.Insets(0,10,0,10));
button.setPreferredSize(new java.awt.Dimension(70,20));
widthMenu.add(button);
}
//////// Dash Pattern
JMenu dashMenu = new JMenu(i18n.get(BasicStrokeEditorMenu.class, "Dash_Pattern", "Dash Pattern"));
listener = new ActionListener() {
public void actionPerformed(ActionEvent ae) {
String command = ae.getActionCommand();
try {
setDash(stringToDashArray(command));
resetStroke();
} catch (NumberFormatException e) {
}
}
};
group = new ButtonGroup();
String[] patterns = new String[] { NONE, "1.0 3.0", "3.0 3.0", "12.0 10.0",
"12.0 10.0 6.0 10.0", "20.0 10.0", "20.0 10.0 6.0 10.0", "20.0 10.0 6.0 10.0 6.0 10.0" };
String currentDash = dashArrayToString(getDash());
for (i = 0; i < patterns.length; i++) {
BasicStroke dashStroke = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, stringToDashArray(patterns[i]), 0.0f);
ii = createIcon(dashStroke, 90, 10, true);
button = new JRadioButtonMenuItem(" ", ii, currentDash.equals(patterns[i]));
button.setActionCommand(patterns[i]);
group.add(button);