44 Java自定义按钮 - 雪炭网

Java自定义按钮2014-10-20 16:22:48

( 还没有投票,继续加油! )
分享:
31.3K
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.plaf.synth.SynthLookAndFeel;
            
public class MyButton {
 JFrame frame = new JFrame("Test Buttons");
 JButton jButton = new JButton("JButton"); // 按钮
 public MyButton() {
 frame.setLayout(new FlowLayout());
 frame.getContentPane().add(jButton);
 }
 public void show() {
 frame.pack();
 frame.show();
 }
 public static void main(String[] args) {
 MyButton tb = new MyButton();
 tb.show();
 SynthLookAndFeel slf = new SynthLookAndFeel();
 try {   slf.load(MyButton.class.getResourceAsStream("mybutton.xml"), MyButton.class);
   UIManager.setLookAndFeel(slf);
 } catch (Exception e) {
   e.printStackTrace();
   return;
 }
            
 }
}


style:

<synth>
 <style id="mybutton">
   <state>
    <imagePainter method="buttonBackground" path="mybutton.png" sourceInsets="3 6 12 20" paintCenter="true" stretch="true"/>
  <insets top="3" left="6" bottom="12" right="20"/>
  <font name="Aharoni" size="16"/>
 </state>
 <property key="Button.margin" type="insets" value="0 0 5 8"/>
 </style>
 <bind style="mybutton" type="region" key="Button"/>
</synth>






头像

snowcoal
  • Java
  • 自定义按纽

本文标签:

Java自定义按纽

收藏到我的私密空间

标题:Java自定义按钮

作者:花花世界

你暂未登录,请登录后才可收藏至您的私密空间 确认取消
雪炭网

键盘操作 更便捷 -雪炭网雪中送炭-乐趣无限

如果本站的内容有幸帮助到了您,建议您了解一下当页的广告内容哦,我们的进步离不开您的支持,Thank you~