-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathCSaveButton.java
More file actions
66 lines (55 loc) · 1.77 KB
/
Copy pathCSaveButton.java
File metadata and controls
66 lines (55 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved
// Copyright 2011-2012 MIT, All rights reserved
// Released under the MIT License https://raw.github.com/mit-cml/app-inventor/master/mitlicense.txt
package openblocks.codeblockutil;
import java.awt.Color;
import javax.swing.SwingUtilities;
/**
* A CSaveButton is a special CButton which provides methods to
* disable and re-enable its functionality and update its appearance
* accordingly.
*
*
*/
public class CSaveButton extends CGradientButton {
private static final boolean DEBUG = false;
private String enabledString;
private String disabledString;
public CSaveButton(String enabledString, String disabledString) {
super(BUTTON_COLOR_TOP, BUTTON_COLOR_BOTTOM, enabledString);
setTextLighting(TEXT_COLOR, Color.BLACK);
this.enabledString = enabledString;
this.disabledString = disabledString;
}
public void grayOut() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (DEBUG) {
System.out.println("Disabling " + enabledString + " button.");
}
setText(disabledString);
setEnabled(false);
setLighting(BUTTON_GRAYED_COLOR, BUTTON_GRAYED_COLOR);
setTextLighting(TEXT_GRAYED_COLOR, TEXT_GRAYED_COLOR);
revalidate();
}
});
}
public void reColor() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (DEBUG) {
System.out.println("Re-enabling " + enabledString + " button.");
}
setText(enabledString);
setEnabled(true);
setLighting(BUTTON_COLOR_TOP, BUTTON_COLOR_BOTTOM);
setTextLighting(TEXT_COLOR, Color.BLACK);
revalidate();
}
});
}
}