Unable to customize the button for my plugin

已回答

Hi Team,

I am unable to apply style (color) fully for my Button, when I try to do that it ends up coloring only the border.

Note: this button will be used in a plugin which will be deployed

Expected:

My Output:

 

My Implementation:
JButton test = new JButton("Test");
test.setPreferredSize(new Dimension(150,30));
test.setBackground(new Color(12,159,167));
jpanel.add(test);

0

Plugins should not modify the colors of the UI's Look&Feel, as these colors are customizable by Theme plugins.

0

Yann Cebron How if I need to change the button to looks like red or blue based on positive and negative action scenario? Is there any API that can be used ?

Or if it cant, is there any methods or API to configure button as Primary or Secondary like this?

0

For DialogWrapper, you can set default button via com.intellij.openapi.ui.DialogWrapper#DEFAULT_ACTION and default focused button via com.intellij.openapi.ui.DialogWrapper#FOCUSED_ACTION

0

I am copying my answer from a different ticket for findability. 


Here is the example of settings themed color for the Button: 

var outstandingBgColor = namedColor("UI.focusColor"); 
myButton.putClientProperty("JButton.backgroundColor", outstandingBgColor); 

To find the example code, I opened IntelliJ Community repo and looked for "button.background" text. The result was com/intellij/ide/bookmark/actions/BookmarkTypeChooser.kt:199 
To find the example color name, I opened src/main/resources/themes/Dracula.theme.json and looked for an outstanding color.

0

请先登录再写评论。