18
18
import com .intellij .openapi .util .Condition ;
19
19
import com .intellij .openapi .util .Key ;
20
20
import com .intellij .openapi .util .SystemInfo ;
21
+ import com .intellij .ui .JBColor ;
21
22
import com .intellij .util .ModalityUiUtil ;
22
23
import icons .FlutterIcons ;
23
24
import io .flutter .FlutterBundle ;
29
30
import org .jetbrains .annotations .Nullable ;
30
31
31
32
import javax .swing .*;
33
+ import java .awt .Component ;
32
34
import java .util .*;
33
35
34
36
public class DeviceSelectorAction extends ComboBoxAction implements DumbAware {
@@ -45,6 +47,39 @@ public class DeviceSelectorAction extends ComboBoxAction implements DumbAware {
45
47
return ActionUpdateThread .BGT ;
46
48
}
47
49
50
+ @ Override
51
+ public @ NotNull JComponent createCustomComponent (@ NotNull Presentation presentation , @ NotNull String place ) {
52
+ final JComponent component = super .createCustomComponent (presentation , place );
53
+ // Set component to be transparent to match other toolbar actions
54
+ component .setOpaque (false );
55
+ // Update child components.
56
+ updateComponentChildrenStyles (component );
57
+ return component ;
58
+ }
59
+
60
+ private void updateComponentChildrenStyles (@ NotNull JComponent parent ) {
61
+ final @ Nullable Component [] children = parent .getComponents ();
62
+ if (children == null ) {
63
+ return ;
64
+ }
65
+
66
+ for (Component child : children ) {
67
+ if (child instanceof JComponent jComponent ) {
68
+ jComponent .setOpaque (false );
69
+
70
+ if (child instanceof JButton jButton ) {
71
+ jButton .setBorderPainted (false );
72
+ jButton .setRolloverEnabled (true );
73
+ // Make sure the button uses correct background & foreground.
74
+ jButton .setBackground (JBColor .background ());
75
+ jButton .setForeground (JBColor .foreground ());
76
+ }
77
+
78
+ updateComponentChildrenStyles (jComponent );
79
+ }
80
+ }
81
+ }
82
+
48
83
@ Override
49
84
protected @ NotNull DefaultActionGroup createPopupActionGroup (@ NotNull JComponent button , @ NotNull DataContext dataContext ) {
50
85
final DefaultActionGroup group = new DefaultActionGroup ();
0 commit comments