SequenceGroup seqGroup;
- ArrayList<JButton> selectedButtons;
-
ColourSchemeI oldColourScheme;
JInternalFrame frame;
}
/**
- * DOCUMENT ME!
+ * ChangeListener handler for when a colour is picked in the colour chooser.
+ * The action is to apply the colour to all selected buttons as their
+ * background colour. Foreground colour (text) is set to a lighter shade in
+ * order to highlight which buttons are selected. If 'Lower Case Colour' is
+ * active, then the colour is applied to all lower case buttons (as well as
+ * the Lower Case Colour button itself).
*
* @param evt
- * DOCUMENT ME!
*/
@Override
public void stateChanged(ChangeEvent evt)
{
- if (selectedButtons != null)
+ JButton button = null;
+ final Color newColour = colorChooser.getColor();
+ for (int i = 0; i < selectedButtons.size(); i++)
+ {
+ button = selectedButtons.get(i);
+ button.setBackground(newColour);
+ button.setForeground(ColorUtils.brighterThan(newColour));
+ }
+ if (button == lcaseColour)
{
- JButton button = null;
- final Color newColour = colorChooser.getColor();
- for (int i = 0; i < selectedButtons.size(); i++)
+ button.setForeground(Color.black);
+ for (int i = 0; i < lowerCaseButtons.size(); i++)
{
- button = selectedButtons.get(i);
+ button = lowerCaseButtons.get(i);
button.setBackground(newColour);
- button.setForeground(ColorUtils.brighterThan(newColour));
- }
- if (button == lcaseColour)
- {
- for (int i = 0; i < lowerCaseButtons.size(); i++)
- {
- button = lowerCaseButtons.get(i);
- button.setBackground(newColour);
- button.setForeground(ColorUtils.brighterThan(button
- .getBackground()));
- }
+ button.setForeground(ColorUtils.brighterThan(button.getBackground()));
}
}
}
*/
public void colourButtonPressed(MouseEvent e)
{
- if (selectedButtons == null)
- {
- selectedButtons = new ArrayList<JButton>();
- }
-
JButton pressed = (JButton) e.getSource();
if (e.isShiftDown())
@Override
public void caseSensitive_actionPerformed(ActionEvent e)
{
- resetButtonPanel(caseSensitive.isSelected());
- lcaseColour.setEnabled(caseSensitive.isSelected());
+ boolean selected = caseSensitive.isSelected();
+ resetButtonPanel(selected);
+ lcaseColour.setEnabled(selected);
+ lcaseColour.setForeground(Color.GRAY);
}
+ /**
+ * Action on clicking 'Lower case colour', which results in changing colour of
+ * all lower-case buttons when a colour is picked. A second click of the
+ * button turns off this behaviour.
+ */
@Override
public void lcaseColour_actionPerformed(ActionEvent e)
{
- if (selectedButtons == null)
+ boolean enable = !selectedButtons.contains(lcaseColour);
+ selectedButtons.clear();
+ if (enable)
{
- selectedButtons = new ArrayList<JButton>();
+ selectedButtons.add(lcaseColour);
+ lcaseColour.setForeground(lowerCaseButtons.get(0).getForeground());
+ lcaseColour.setForeground(Color.black);
}
else
{
- selectedButtons.clear();
+ lcaseColour.setBackground(Color.white);
+ lcaseColour.setForeground(Color.gray);
}
- selectedButtons.add(lcaseColour);
}
}