* remove transparency effect on continue button

This commit is contained in:
Reinhard Pointner 2009-07-20 11:46:51 +00:00
parent 46764f7d63
commit cb7200434d
1 changed files with 15 additions and 94 deletions

View File

@ -6,11 +6,8 @@ import static java.util.Collections.*;
import static net.sourceforge.filebot.FileBotUtilities.*;
import static net.sourceforge.tuned.ui.TunedUtilities.*;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.util.AbstractList;
@ -37,10 +34,6 @@ class ValidateDialog extends JDialog {
private final JList list;
private final Action validateAction = new ValidateAction();
private final Action continueAction = new ContinueAction();
private final Action cancelAction = new CancelAction();
private String[] model;
private boolean cancelled = true;
@ -66,7 +59,7 @@ class ValidateDialog extends JDialog {
content.add(new JScrollPane(list), "grow, wrap 2mm");
content.add(new JButton(validateAction), "align center");
content.add(new AlphaButton(continueAction), "gap related");
content.add(new JButton(continueAction), "gap related");
content.add(new JButton(cancelAction), "gap 12mm");
installAction(content, KeyStroke.getKeyStroke("released ESCAPE"), cancelAction);
@ -95,14 +88,7 @@ class ValidateDialog extends JDialog {
}
private class ValidateAction extends AbstractAction {
public ValidateAction() {
putValue(NAME, "Validate");
putValue(SMALL_ICON, ResourceManager.getIcon("dialog.continue"));
putValue(SHORT_DESCRIPTION, "Remove invalid characters");
}
private final Action validateAction = new AbstractAction("Validate", ResourceManager.getIcon("dialog.continue")) {
@Override
public void actionPerformed(ActionEvent e) {
@ -114,94 +100,29 @@ class ValidateDialog extends JDialog {
// update view
list.repaint();
// switch icon
continueAction.putValue(SMALL_ICON, getValue(SMALL_ICON));
continueAction.putValue(ContinueAction.ALPHA, 1.0f);
// disable action
// disable this action
setEnabled(false);
}
}
private class ContinueAction extends AbstractAction {
public static final String ALPHA = "alpha";
public ContinueAction() {
putValue(NAME, "Continue");
putValue(SMALL_ICON, ResourceManager.getIcon("dialog.continue.invalid"));
putValue(ALPHA, 0.75f);
}
};
private final Action continueAction = new AbstractAction("Continue", ResourceManager.getIcon("dialog.continue.invalid")) {
@Override
public void actionPerformed(ActionEvent e) {
finish(false);
}
}
protected class CancelAction extends AbstractAction {
public CancelAction() {
putValue(NAME, "Cancel");
putValue(SMALL_ICON, ResourceManager.getIcon("dialog.cancel"));
}
};
private final Action cancelAction = new AbstractAction("Cancel", ResourceManager.getIcon("dialog.cancel")) {
@Override
public void actionPerformed(ActionEvent e) {
finish(true);
}
}
protected static class AlphaButton extends JButton {
private float alpha;
public AlphaButton(Action action) {
super(action);
}
@Override
protected void configurePropertiesFromAction(Action action) {
super.configurePropertiesFromAction(action);
alpha = getAlpha(action);
}
@Override
protected void actionPropertyChanged(Action action, String propertyName) {
super.actionPropertyChanged(action, propertyName);
if (propertyName.equals(ContinueAction.ALPHA)) {
alpha = getAlpha(action);
}
}
private float getAlpha(Action action) {
Object value = action.getValue(ContinueAction.ALPHA);
if (value instanceof Float) {
return (Float) value;
}
return 1.0f;
}
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.setComposite(AlphaComposite.SrcOver.derive(alpha));
super.paintComponent(g2d);
}
}
};
public static boolean validate(Component parent, List<String> source) {