Skip to content

Commit

Permalink
improved resposiveness
Browse files Browse the repository at this point in the history
  • Loading branch information
i-make-robots committed Jul 10, 2024
1 parent cf31b46 commit 05167f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ public class SelectColor extends Select {
* @param labelValue
* @param defaultValue
*/
public SelectColor(String internalName,String labelValue,Color defaultValue,final Component parentComponent) {
public SelectColor(String internalName, String labelValue, Color defaultValue, final Component parentComponent) {
super(internalName);

JLabel label = new JLabel(labelValue,JLabel.LEADING);
label.setName(internalName+".label");

chooseButton = new BackgroundPaintedButton("");
chooseButton.setName(internalName+".button");
chooseButton.setOpaque(true);
chooseButton.setMinimumSize(new Dimension(80,20));
chooseButton.setMaximumSize(chooseButton.getMinimumSize());
Expand All @@ -34,6 +36,7 @@ public SelectColor(String internalName,String labelValue,Color defaultValue,fina
Color c = JColorChooser.showDialog(parentComponent, label.getText(), chooseButton.getBackground());
if ( c != null ){
chooseButton.setBackground(c);
firePropertyChange("color",null,c);
fireSelectEvent(null,c);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ public void validate() {

if(timer!=null) timer.cancel();
timer = new Timer("Delayed response");
timer.schedule(new TimerTask() {
timer.schedule(new TimerTask() {
public void run() {
fireSelectEvent(oldValue,newValue);
SwingUtilities.invokeLater(() -> {
fireSelectEvent(oldValue, newValue);
firePropertyChange("value", oldValue, newValue);
});
}
}, 100L); // brief delay in case someone is typing fast
}
Expand Down

0 comments on commit 05167f2

Please sign in to comment.