下面列出了怎么用javax.swing.plaf.metal.MetalToggleButtonUI的API类实例代码及写法,或者点击链接到github查看源代码。
@Nonnull
private JToggleButton makeIconButton(@Nonnull final ButtonGroup group, @Nonnull final String name) {
final JToggleButton result = Utils.UI_COMPO_FACTORY.makeToggleButton();
final Color panelColor = this.getBackground();
result.setUI(new MetalToggleButtonUI() {
@Override
@Nullable
protected Color getSelectColor() {
return panelColor.brighter();
}
});
result.setBackground(panelColor.darker());
result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(), BorderFactory.createEmptyBorder(3, 3, 3, 3)));
result.setIcon(new ImageIcon(MiscIcons.findForName(name)));
result.setName(name);
result.setFocusPainted(false);
result.setToolTipText(name);
group.add(result);
return result;
}
/**
* Getter method for embedButton
*
* @return embedButton
*/
public JToggleButton getEmbedButton() {
if (this.embedButton == null) {
this.embedButton = new JToggleButton(labelUtil.getString("gui.label.tab.dhEmbed"),
new ImageIcon(getClass().getResource("/image/EmbedIcon.png")), true);
if (toggleUiHack) {
this.embedButton.setUI(new MetalToggleButtonUI());
}
this.embedButton.setVerticalTextPosition(SwingConstants.BOTTOM);
this.embedButton.setHorizontalTextPosition(SwingConstants.CENTER);
this.embedButton.setFocusable(false);
this.actionButtonGroup.add(this.embedButton);
}
return this.embedButton;
}
/**
* Getter method for extractButton
*
* @return extractButton
*/
public JToggleButton getExtractButton() {
if (this.extractButton == null) {
this.extractButton = new JToggleButton(labelUtil.getString("gui.label.tab.dhExtract"),
new ImageIcon(getClass().getResource("/image/ExtractIcon.png")));
if (toggleUiHack) {
this.extractButton.setUI(new MetalToggleButtonUI());
}
this.extractButton.setVerticalTextPosition(SwingConstants.BOTTOM);
this.extractButton.setHorizontalTextPosition(SwingConstants.CENTER);
this.extractButton.setFocusable(false);
this.actionButtonGroup.add(this.extractButton);
}
return this.extractButton;
}
/**
* Getter method for genSigButton
*
* @return genSigButton
*/
public JToggleButton getGenSigButton() {
if (this.genSigButton == null) {
this.genSigButton = new JToggleButton(labelUtil.getString("gui.label.tab.wmGenSig"),
new ImageIcon(getClass().getResource("/image/EmbedIcon.png"))); // TODO
if (toggleUiHack) {
this.genSigButton.setUI(new MetalToggleButtonUI());
}
this.genSigButton.setVerticalTextPosition(SwingConstants.BOTTOM);
this.genSigButton.setHorizontalTextPosition(SwingConstants.CENTER);
this.genSigButton.setFocusable(false);
this.actionButtonGroup.add(this.genSigButton);
}
return this.genSigButton;
}
/**
* Getter method for signWmButton
*
* @return signWmButton
*/
public JToggleButton getSignWmButton() {
if (this.signWmButton == null) {
this.signWmButton = new JToggleButton(labelUtil.getString("gui.label.tab.wmEmbed"),
new ImageIcon(getClass().getResource("/image/EmbedIcon.png")));
if (toggleUiHack) {
this.signWmButton.setUI(new MetalToggleButtonUI());
}
this.signWmButton.setVerticalTextPosition(SwingConstants.BOTTOM);
this.signWmButton.setHorizontalTextPosition(SwingConstants.CENTER);
this.signWmButton.setFocusable(false);
this.actionButtonGroup.add(this.signWmButton);
}
return this.signWmButton;
}
/**
* Getter method for verifyWmButton
*
* @return verifyWmButton
*/
public JToggleButton getVerifyWmButton() {
if (this.verifyWmButton == null) {
this.verifyWmButton = new JToggleButton(labelUtil.getString("gui.label.tab.wmVerify"),
new ImageIcon(getClass().getResource("/image/ExtractIcon.png")));
if (toggleUiHack) {
this.verifyWmButton.setUI(new MetalToggleButtonUI());
}
this.verifyWmButton.setVerticalTextPosition(SwingConstants.BOTTOM);
this.verifyWmButton.setHorizontalTextPosition(SwingConstants.CENTER);
this.verifyWmButton.setFocusable(false);
this.actionButtonGroup.add(this.verifyWmButton);
}
return this.verifyWmButton;
}